JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Create an Array

kelsey hayden
kelsey hayden
14,238 Points

Help with create an array code challenge

Im not sure what i am missing here? bug? error says i am still missing 3 numbers

script.js
var data = ["23", "45", "65",];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

1 Answer

Jasper Bloem
Jasper Bloem
22,420 Points

Hey Kelsey,

You used symbols to make your number a string, remove the quotes and you should be fine.

This will be your answer:

var data = [23, 45, 65];
kelsey hayden
kelsey hayden
14,238 Points

Thanks for the help! Must have missed that part in the video.

John Erickson
John Erickson
Full Stack JavaScript Techdegree Student 3,916 Points

It can be confusing, trust me I know as I'm new to javaScript. As Jasper has already explained, a number and a string are totally different. Anything placed inside quotes will be considered a string even if the value is a number i.e. "23". You can always use the typeof operator to help determine what value you're using. For example:

typeof( data[0] );

This will return "string" rather than number.

However as Jasper explained above:

var data = [23, 45, 65]; typeof( data[0] );

This will return "number" rather than string.

Hopefully this helps.