Basic Data Structures - Copy Array Items Using slice()

Tell us what’s happening:

Describe your issue in detail here.
Here, we have given an array.
In the forecast function, I simply try to return an array that contains two strings, “warm” and “sunny,” but when I run the code, It gives the result that you have to untilize the splice() function.
I don’t know where I’m wrong, and the solution in form is also wrong.

Your code so far

function forecast(arr) {
  // Only change code below this line
  arr=arr.splice(2,2)
  return arr;
}

// Only change code above this line
console.log(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']));

Your browser information:

The user agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Challenge Information:

Basic Data Structures: Copy Array Items Using slice()

Hey sing,

I think you need to read the instructions carefully. It says you need to utilize the slice() method not splice()

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.