meaning of console.log(id); id = id.split(" "); [closed]

console.log writes the value to the JavaScript Console.

id.split(" ") splits the string id at the space into an array.

var id = "This is a string";
var idParts = id.split(" ");

for(var i = 0; i < idParts.length; i++) {
  console.log(idParts[i]);
} 

The above will output “This”, “is”, “a”, and “string” to the javascript console.

Leave a Comment