Skip to content

About

Practical Assignment No. 0 on Hexlet. JS practice tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

JavaScript Practice Tasks

Run Tests Runtime JavaScript

A structured collection of practical JavaScript tasks focusing on strings, arrays, and loops. Built using the Bun runtime and fully covered by unit tests via bun:test.


📂 Project Structure

├── .github/
│   └── workflows/
│       └── test.yml          # GitHub Actions CI pipeline
├── src/
│   ├── strings.js            # String manipulation solutions
│   ├── arrays.js             # Array manipulation solutions
│   └── loops.js              # Loop and iteration solutions
├── tests/
│   ├── strings.test.js       # Unit tests for string tasks
│   ├── arrays.test.js        # Unit tests for array tasks
│   └── loops.test.js         # Unit tests for loop tasks
├── index.js                  # Interactive runner & showcase
├── bun.lock
├── package.json
└── README.md

📋 Task Checklist

1. Strings (src/strings.js)

  • capitalizeFirstLetter(str) — Capitalize the first letter of a string while leaving the rest unchanged.
  • reverseString(str) — Reverse the input string.
  • countVowels(str) — Count vowels (a, e, i, o, u) case-insensitively.
  • truncateText(str, maxLength) — Truncate string to maxLength and append ... if exceeded.
  • removeSpaces(str) — Remove all whitespace characters from a string.

2. Arrays (src/arrays.js)

  • sumArray(arr) — Calculate the sum of all numbers in an array.
  • filterEvenNumbers(arr) — Return a new array containing only even numbers.
  • findMax(arr) — Find and return the maximum value in a non-empty numeric array.
  • flattenArray(arr) — Flatten a nested array by one level depth.
  • uniqueValues(arr) — Return unique elements while preserving the original order.

3. Loops (src/loops.js)

  • printNumbers(n) — Print numbers from 1 to n inclusive using a loop.
  • calculateFactorial(n) — Calculate the factorial of n using an iterative loop.
  • generateMultiplicationTable(n) — Output the multiplication table for n from 1 to 10.
  • sumOfDigits(num) — Compute the sum of digits of a given positive integer.
  • repeatString(str, count) — Replicate a string count times without using .repeat().

🚀 Getting Started

Prerequisites

Ensure you have Bun installed:

curl -fsSL [https://bun.sh/install](https://bun.sh/install) | bash

Installation

Clone the repository and install dependencies:

git clone [https://github.com/hdmi1519/hexly_js_practice_tasks.git](https://github.com/hdmi1519/hexly_js_practice_tasks.git)
cd hexly_js_practice_tasks
bun install

🛠️ Usage & Testing

  • Run interactive showcase:

    bun start
  • Run unit tests:

    bun test
  • Run tests in watch mode:

    bun test --watch
  • Check and format code:

    bun run format

About

Practical Assignment No. 0 on Hexlet. JS practice tasks.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages