I am trying to remove n amount of characters from a given index. Here are the instructions:
"Write a function called removeFromString, which accepts a string, a starting index (number) and a number of characters to remove.
The function should return a new string with the characters removed."
Here is what I have so far:
function removeFromString(str, index, number) {
var sliced = str.slice(index, -number);
return sliced;
}
console.log(
removeFromString('This is a string', 5, 5)
);
It is sort of working, BUT for some reason in addition to removing characters from the given index, it also removes characters from the end of the string. What am I doing wrong?