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

david Ramirez
david Ramirez
Pro Student 2,797 Points

i dont understand the question

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

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

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.

Jeremy Hill
Jeremy Hill
20,424 Points
var data = [1, 2, 3,]
var assorted = ["one", 2, true]