Your task is to write a function called stringLength that accepts a string as a parameter and computes the length of that string; however, as you may have guessed, you are not allowed to use the length property of the string!
Instead, you'll need to make use of the string method called slice.
My program is not creating the right output. Please explain the error in my code.
function stringLength(string) {
let start =0;
let end= string.slice(0, "");
let result=0;
for(let i=start; i<=end; i++){
result++;
}
return result;
}
My output is 1
Whereas the output should return the length of the given string.
slice(0, "")supposed to do? Btw[...string].length