Loops and arrays II
Instructions:
var name = ["a","b","c","d","e"];
for(var i=0; i<5; i++)
{
console.log ("I know someone called "+name[i]);
}
Output:
I know someone called a
I know someone called b
I know someone called c
I know someone called d
I know someone called e
Instructions:
- Create an array called
names
filled with 5 names. - Write a
for
loop that prints"I know someone called "
followed bynames[i]
. Make sure there's a space between"called"
and the name! - Run your code and the five sentences should print out.
var name = ["a","b","c","d","e"];
for(var i=0; i<5; i++)
{
console.log ("I know someone called "+name[i]);
}
Output:
I know someone called a
I know someone called b
I know someone called c
I know someone called d
I know someone called e
No comments:
Post a Comment