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.
├── .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
-
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 tomaxLengthand append...if exceeded. -
removeSpaces(str)— Remove all whitespace characters from a string.
-
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.
-
printNumbers(n)— Print numbers from1toninclusive using a loop. -
calculateFactorial(n)— Calculate the factorial ofnusing an iterative loop. -
generateMultiplicationTable(n)— Output the multiplication table fornfrom 1 to 10. -
sumOfDigits(num)— Compute the sum of digits of a given positive integer. -
repeatString(str, count)— Replicate a stringcounttimes without using.repeat().
Ensure you have Bun installed:
curl -fsSL [https://bun.sh/install](https://bun.sh/install) | bashClone 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-
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