Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

How to create an Array?

Create an array named data and store any 3 numbers in it.

I created an array and stored 3 numbers inside. I checked my work and got this message; Bummer! There was an error with your code. Syntax error; parse error.

What am I doing wrong?

var data = [
<!DOCTYPE html>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
<script src="script.js"></script>

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Close! Really close... but not quite. First, the elements in your array need to be separated by commas. But secondly and most importantly... those aren't numbers. I know... I know... they look like numbers, but because they are in quotes they're now strings. They are the kind of numbers we might use in a street address, telephone number, or social security number. It's nothing we would ever do any mathematical operations on. I've reformatted your array so it works. Take a look:

var data = [7, 15, 26];

Oops. I forgot, a string is enclosed in quotes, numbers aren't. I have the notes for numbers and strings, somewhere. I'll need to go back and look, to what makes a string and what makes a number.

Thank you so much for your help, Jennifer.

Victor Albarran
Victor Albarran
4,662 Points

I forgot too about that anything in quotes is a string and number do not need strings

thank you