Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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