Exercise 6 · Chapter: ArraysRequired+50 XP
Fix the Push
This code is trying to add "grape" to the array of fruits, but it's doing it the wrong way — + turns the array into one glued-together string.
Fix the code so it correctly adds "grape" to the end of the array and prints the result.
Expected output:
apple,banana,grape
Hint: You can't add an item to an array with +. Use the right array method instead!
Need a hint?
3 available · costs 5 XP each
javascript
let fruits = ["apple", "banana"];
fruits = fruits + "grape";
console.log(fruits);
Output
Run your code to see the output here.