Conversation
|
|
||
| // TODO: write code in this function body to pass the tests | ||
|
|
||
| if (true) alert('Well done, you passed!') |
There was a problem hiding this comment.
the function is asking to check if the value that has been passed to the getResult function is true or false, and return a different string.
if(didPass === true) {
return "Well done, you passed!"
}
| function isArrayEmpty (array) { | ||
|
|
||
| // TODO: write code in this function body to pass the tests | ||
| if (array === []) { |
There was a problem hiding this comment.
what you have coded will work; you can also choose to do the following:
if(array.length === 0) to test if the array is empty
|
|
||
| // Set fourthCity to the 4th element in the cities array | ||
| const fourthCity = '' | ||
| const fourthCity = 'Delhi' |
There was a problem hiding this comment.
the exercise here is asking you to set fourthCity to the 4th element of the cities array.
The elements of an array are numbered from 0 onwards, with 0 being the first element, 1 being the second. Hence the 4th element has an index of 3.
I can then do the following: fourthCity = cities[3] which means, take the 3rd element in the cities list and assign it to the variable called fourthCity
|
|
||
| // Set firstCity to the 1st element in the cities array | ||
| const firstCity = '' | ||
| const firstCity = 'London' |
|
|
||
| // Use an array method to remove the first item from colours | ||
| colours | ||
| colours.shift('Red') |
There was a problem hiding this comment.
shift() can be called without an argument (value) and that will remove the first item, see the documentation here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
|
|
||
| // Use an array method to remove the last item from keys | ||
| keys | ||
| keys.pop('y') |
There was a problem hiding this comment.
the pop() function of an array does not need an argument, it will simply remove the last item
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
src/data-types/numbers.js
Outdated
|
|
||
| // Set this variable to numOne added to numTwo | ||
| const numOnePlusNumTwo = NaN | ||
| const numOnePlusNumTwo = 8 + 16 |
There was a problem hiding this comment.
can you re-write the solutions below to use the variables at the start of the file?
for example: const numOnePlusNumTwo = numOne + numTwo
| } | ||
| const computer = { | ||
| form: 'laptop', | ||
| specs: ( |
There was a problem hiding this comment.
there should not be an ( and ) brackets here. To define an object i just need { ... }, so specs should be:
|
|
||
| basket.items[0].price = 2 | ||
|
|
||
| basket.items[2] = ({ |
There was a problem hiding this comment.
there's no need for ( and ); to add an object you need to:
- define the object with the { } syntax and
- call push on the array:
baseket.items.push({...})
src/loops/for-loop-basic.js
Outdated
| // TODO: Write a for loop that adds all the even numbers between 0 and 6 (0, 2, 4, 6) to evenNums | ||
| const numbers = [0, 2, 4, 6]; | ||
| for (let i = 0; i < numbers.length; i++) { | ||
| if (numbers[i]) 2 === 0; |
There was a problem hiding this comment.
this if statement won't work: you will need to place all the comparison instruction inside the ():
if(numbers[i] % 2 === 0) {
No description provided.