mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-23 12:03:28 -05:00
1.3 KiB
1.3 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 660f0a55847d6cc485f29ba5 | Step 26 | 1 | step-26 |
--description--
A method in JavaScript is a function that's associated with certain values or objects. An example you've already encountered is the .log() method, which is part of the console object.
Arrays have their own methods, and the first you will explore is the .push() method. This allows you to "push" a value to the end of an array. Here is an example to add the number 12 to the end of an array:
array.push(12);
Use .push() to add the string "freeCodeCamp" to the end of your rows array. Add this code before your console.log so you can see the change you made to your array.
--hints--
You should use .push() in your code.
assert.match(__helpers.removeJSComments(code), /\.push\(/);
You should use the .push() method of your rows array.
assert.match(__helpers.removeJSComments(code), /rows\.push\(/);
You should pass the string "freeCodeCamp" to your .push() method.
assert.match(__helpers.removeJSComments(code), /rows\.push\(\s*('|")freeCodeCamp\1\s*\);?/)
--seed--
--seed-contents--
let character = 'Hello';
let count = 8;
--fcc-editable-region--
let rows = ["Naomi", "Quincy", "CamperChan"];
console.log(rows);
--fcc-editable-region--