4/7 If statement


#1

var text = "OJ afsJ.";
var myName = "Jevin";
var hits = [];

for(var i = 0; i < text.length; i++){
if(text[i] === 'J'){
console.log(myName);
}

}

The output is myName variable twice, what is this code doing?


#2

first in the for loop its going through all of the strings in text since it is set toi<text.length (.length finds the length of the string), and in your text there are two J's so it console.log your name twice! Hope this helped and take a look at this
..


#3

/*jshint multistr:true */
var text = "Mornings are often \ a tough time, right Ron?";
var myName = "Ron";
var hits = [];
//end of global variables
for(var i = 0; i < text.length; i++) {
if (text[i]=== "R") {}}