Ask coding questions

← Back to all posts
JS Assignment 9: Intro to Arrays
maximussallam (4)

// Exercise One: Create a variable called 'numbersArray',
// assign it to an array containing 5 numbers (any numbers).
const numbersArray = ['0', '1', '2', '3', '4'];

Expected 'string' to be 'number'.

Why is this wrong?

Answered by malvoliothegood (183) [earned 5 cycles]
View Answer
Commentshotnewtop
malvoliothegood (183)

The quote marks around your numbers turns them into text representations of number. You need const numbersArray = [0, 1, 2, 3, 4];