So FCC’s solution to this challenge is to call upon the array with “arr”
as in arr.push or arr.unshift… however in the documentation provided for this lesson,
we are taught we can reference the name of the array to perform .push & .unshift as shown below with the instructor* using romanNumeral.push…
in the lesson, the array is called ‘mixedNumbers’ but we can’t utilize push or unshift as is taught by the description. The solution says to use shorthand… |:
is this indictive of an error or can you call upon arrays as such using their name.?
**should probaly fix for future slow learners like me (’:
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];
romanNumerals.unshift('XIX', 'XX');
romanNumerals would have the value ['XIX', 'XX', 'XXI', 'XXII'] .
romanNumerals.push(twentyThree);
function mixedNumbers(arr) {
// Only change code below this line
mixedNumbers.push(7,'VIII',9);
mixedNumbers.unshift('I',2,'three');
// Only change code above this line
return arr;
}
console.log(mixedNumbers(['IV', 5, 'six']));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Challenge: Add Items to an Array with push() and unshift()
function mixedNumbers(arr) {
// Only change code below this line
arr.push(7, 'VIII', 9);
arr.unshift('I', 2, 'three');
// Only change code above this line
return arr;
}
console.log(mixedNumbers(['IV', 5, 'six']));
as is stated in the lesson, see when they use romanNumerals,push?
when you goto use the name of the array (mixedNumbers) to push or unshift, it doesnt work /= it would rather you use shorthand notation or whatever as in “arr”…
arr is the totality of elements that the mixedNumbers have… If you don’t use arr, it is undefined, so mixedNumbers is undefined, so the tests are failing…
function mixedNumbers (arr) {
// Only change code below this line
mixedNumbers.push(7,'VIII',9);
mixedNumbers.unshift('I',2,'three');
// Only change code above this line
return arr;
}
console.log(mixedNumbers(['IV', 5, 'six']));
because this:
This isn’t correct. I understand why you’ve written what you’ve written, but you’re misunderstanding a basic thing here – I’ll not expand on that yet, just try to answer these questions:
What type of thing has been given the name mixedNumbers?
So, after tinkering around with the console i found that you can push or unshift with the given titles of created arrays! hooray!!
if only the lesson and the challenge coincided more coherently.
the challenge’s array is made up as a different kind of tree, distinct from the lesson, It certainly throws off eggheads like myself! thank you sm!!