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

david Ramirez
PLUS
david Ramirez
Courses Plus Student 2,798 Points

i dont understand the question

array string with a value string , a number value, and a boolean

script.js
var data = [1 ,2 ,3]
var asssorted [ i , 4 , 0 < i];
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

You may be having trouble with the syntax for JavaScript datatypes Lets take a closer look at your answer:

var assorted = [ i, 4, 0 < i ] 

You're on the right track but lets break it down further to what you thought were valid values.

The question is asking for an array with a String, Number, Boolean values respectively

String: you put i for string was incorrect because i is interpreted as a variable by JavaScript but "i" with quotes makes it a string. Usually beginners have trouble with this. But you were on the right track.

Number: 4 was correct datatype. Nice!

Boolean: 0 < i there are two right answers to this true or false these are reserved keywords in JavaScript and have a special meaning, the answer you gave is a Boolean Expression

I thought this was a cool way how you answer with a Boolean Expression and I tested it and it actually passes in the interpreter but what actually gets stored is the Boolean value it equates to, either true or false not the Expression.

var data = [1, 2, 3,]
var assorted = ["one", 2, true]