Hi all,
I wrote a tiny function to get the number of characters in a string (and console logged it in the code to check if it works, which it doesn’t).
I have played around with the position of variables (in/outside the function) due to some of the error messages , but I am not sure what I am doing wrong.
Current error message says ‘x is not defined’, I guess because the string has not been passed to the function yet, but I cannot do that until I call the function, which would be outside the function?
Could someone help please?
function accum(str) {
let x = str.length;
return x;
}
accum("one");
console.log(x);