Skip to content

#150 All Array Items to String

Adam Kubiś edited this page Oct 28, 2026 · 1 revision

150 All Array Items to String

Create a function that takes an array of integers and strings.

Convert integers to strings and return the new array.

Current source and tests | Catalog | Testing and tooling

Run this solution

From the cloned repository root, after installing dependencies:

node "Edabit/150 All Array Items to 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.

Current implementation and tests

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 integers and strings.
//Convert integers to strings and return the new array.
function parseArray(arr) {
    return arr.map(String);
}
import { assertEquals } from '../testHelper.js';
assertEquals(parseArray([1, 2, "a", "b"]), ['1', '2', "a", "b"])
assertEquals(parseArray([1, 2, 3, 17, 24, 3, "a", "123b"]), ['1', '2', '3', '17', '24', '3', 'a', '123b'])
assertEquals(parseArray(["abc", 123, "def", 456]), ['abc', '123', 'def', '456'])
assertEquals(parseArray([]), [])

Clone this wiki locally