* feat(curriculum): Add Basic JS Scrimba links * Fix: Add missing video url. * fix: update videoUrl
1.9 KiB
1.9 KiB
id, title, challengeType, videoUrl
id | title | challengeType | videoUrl |
---|---|---|---|
bd7993c9c69feddfaeb8bdef | Store Multiple Values in one Variable using JavaScript Arrays | 1 | https://scrimba.com/c/crZQWAm |
Description
array
variables, we can store several pieces of data in one place.
You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this:
var sandwich = ["peanut butter", "jelly", "bread"]
.
Instructions
myArray
so that it contains both a string
and a number
(in that order).
HintRefer to the example code in the text editor if you get stuck.
Tests
tests:
- text: <code>myArray</code> should be an <code>array</code>.
testString: assert(typeof myArray == 'object', '<code>myArray</code> should be an <code>array</code>.');
- text: The first item in <code>myArray</code> should be a <code>string</code>.
testString: assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string', 'The first item in <code>myArray</code> should be a <code>string</code>.');
- text: The second item in <code>myArray</code> should be a <code>number</code>.
testString: assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number', 'The second item in <code>myArray</code> should be a <code>number</code>.');
Challenge Seed
// Example
var ourArray = ["John", 23];
// Only change code below this line.
var myArray = [];
After Test
(function(z){return z;})(myArray);
Solution
var myArray = ["The Answer", 42];