== Search Text for Your Name ==
We'll want to place the
var myArray = ['a', 'b', 'c'];
myArray[0]; // equals a.
Instructions:
Add your
There's no need to put anything between the
Solutions:
var text = "Hello world Keya how you doing Keya";
var myName ="Keya";
var hits = [];
for(var i=0; i<text.length; i++ )
{
if (text[i]=== 'K')
{
}
}
We'll want to place the
if
statement inside our for
loop to make sure the program checks the if
statement each time it moves forward through the loop. Essentially, the for
loop is saying: "Hey program! Go through every letter in 'text'." The if
statement will say: if
you see something interesting, push that text into an array!"var myArray = ['a', 'b', 'c'];
myArray[0]; // equals a.
Instructions:
Add your
if
statement in the body of your for
loop. It should check to see whether the current letter is equal to the first letter of your name. (Capitalization counts!)There's no need to put anything between the
{}
s of your if
just yet.Solutions:
var text = "Hello world Keya how you doing Keya";
var myName ="Keya";
var hits = [];
for(var i=0; i<text.length; i++ )
{
if (text[i]=== 'K')
{
}
}
No comments:
Post a Comment