After the split() operator, the result you get should be an array right?

function a(string) {
  string = string.toLowerCase().split(" ");
  return string;
}
a("i lOve jS");
console.log(typeof (string));

why does it give me undefined?

string doesn’t exist outside the function (a) scope.

1 Like

Like ghukahr said, the “string” doesn’t exist outside of function’s scope.
You can put your console.log inside the function, or store the function’s return value inside a variable, like this:

Change
a("i lOve jS");
console.log(typeof (string));

to
const variable = a("i lOve jS");
console.log(typeof variable) // you don't need to put brackets around variable
1 Like