Weird Issue When Writing JS

So, initially I was struggling to use Arrow Functions, and now I find that it’s difficult to write a solution to the challenges without writing the whole code block to solve the challenges. For instance:

/*function sliceArray(anim, beginSlice, endSlice) {
    // Add your code below this line
    return anim.slice(beginSlice, endSlice);
    // Add your code above this line
let sliceArray = (anim, beginSlice, endSlice) => anim.slice(beginSlice, endSlice);

var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
sliceArray(inputAnim, 1, 3);

console.log(sliceArray(inputAnim, 1, 3));

I find the arrow function syntax much easier to comprehend and work with, so much so that the regular syntax is throwing me off, although it may be an issue with not writing the whole block. Is this normal? Did/does anyone else experience this? If it’s a negative, does anyone have any suggestion on how to fix it?

Thanks in advance.

sliceArray is a reference to your arrow function, declare it with const can protect them from being accidentally reassigned.
The goal of the exercise is to explain one single notion, add your code in the reserved area is a good practice.

1 Like

Right. I appreciate your suggestion

So, do you normally have issues with finding the solution unless you write the entire block?

Yes I focus just on the snippet of code that can be added in the reserved area to let all tests pass.

1 Like

don’t fossilise on arrow functions, there are situations in which it is totally not appropriated (example, defining methods)

1 Like