freeCodeCamp/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/store-multiple-values-in-one-variable-using-javascript-arrays.english.md
Randell Dawson e0e6334628
fix(curriculum): Consolidated comments for JavaScript Algorithms and Data Structures challenges - part 3 of 4 (#38264)
* fix: remove example code from challenge seed

* fix: remove declaration from solution

* fix: added sum variable back in

* fix: reverted description back to original version

* fix: added examples to description section

* fix: added complete sentence

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: corrected typo

Co-Authored-By: Manish Giri <manish.giri.me@gmail.com>

* fix: reverted to original desc with formatted code

* fix: removed unnecessary code example from description section

Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* fix: failiing test on iterate through array with for loop

* fix: changed to Only change this line

Co-Authored-By: Manish Giri <manish.giri.me@gmail.com>

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Manish Giri <manish.giri.me@gmail.com>
Co-authored-by: moT01 <tmondloch01@gmail.com>
2020-03-25 16:07:13 +01:00

1.7 KiB

id, title, challengeType, videoUrl, forumTopicId
id title challengeType videoUrl forumTopicId
bd7993c9c69feddfaeb8bdef Store Multiple Values in one Variable using JavaScript Arrays 1 https://scrimba.com/c/crZQWAm 18309

Description

With JavaScript 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

Modify the new array myArray so that it contains both a string and a number (in that order). Hint
Refer 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');
  - text: The first item in <code>myArray</code> should be a <code>string</code>.
    testString: assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');
  - text: The second item in <code>myArray</code> should be a <code>number</code>.
    testString: assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');

Challenge Seed

// Only change code below this line
var myArray = [];

After Test

(function(z){return z;})(myArray);

Solution

var myArray = ["The Answer", 42];