Repository navigation
#137 Array to a String
Adam Kubiś edited this page Oct 28, 2026
·
1 revision
Create a function that takes an array of numbers or letters and returns a string.
Current source and tests | Catalog | Testing and tooling
From the cloned repository root, after installing dependencies:
node "Edabit/137 Array to a String.js"Assertions are kept alongside the implementation and throw on failure. A successful run exits with code 0. Run every exercise with npm test or both lint and tests with npm run check.
This is the complete executable file, including its imports and inline test cases. Run it from the repository, not as an isolated file copied out of the wiki. Line endings and trailing whitespace are normalized; executable tokens are unchanged.
//Create a function that takes an array of numbers or letters and returns a string.
function arrayToString(arr) {
return arr.join('');
}
import { assertEquals } from '../testHelper.js';
assertEquals(arrayToString([1, 2, 3, 4, 5, 6]), "123456")
assertEquals(arrayToString(['a', 'b', 'c', 'd', 'e', 'f']), "abcdef")
assertEquals(arrayToString([1, 2, 3, 'a', 's', 'd']), "123asd")
assertEquals(arrayToString(['a', 's', 'd', 'f', 'e', 'r', 1, 2, 3, 4, 5, 0]), "asdfer123450")
assertEquals(arrayToString(['A', 'D', 'F', 'G', 'H', 'Y', 'TR', 'NNHJK']), "ADFGHYTRNNHJK")