Your second "for" loop


#1



I have no idea where to begin to start this piece of code, any tips or advice?


/*jshint multistr:true */
var text = "Hey, how are you Vaughan?\
How was your sleep Vaughan?\
My name is Vaughan?";

var myName = "Vaughan"

var hits = []

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


#2

1. Take time reading the instructions carefully and even write it in pseudocode for better comprehension.

2. If you built the first loop you can build the second, use it as a guide they are not too different. :slight_smile:

3. Here's an example of how it should start, just to give you a base line, :sweat_smile:

for (var j = i; j < i + myName.length; //More code here...


#3

/*jshint multistr:true */
var text = "Hey, how are you Vaughan?\
How was your sleep Vaughan?\
My name is Vaughan?";

var myName = "Vaughan"

var hits = []

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

The above is where i got so far, the Instructions aren't very clear to be honest on code academy. There is alot of "do this" with not much break down on some of the questions


#4

This is because, Codecademy infers that you have grasped all the concepts taught before the lesson you are on and can safely unravel how to do it. :slight_smile:

It seems to me that you have added nothing to your code even after I gave you a baseline, you just appended my base line to your code and didn't even add an increment block afterj < i + myName.length;) I think the best advice I can give you is review the previous lessons about for loops and the nesting of for loops, how they work and so on. Because I gather that you are a bit lost, and I'm a little confused on how you did the first for loop on your own.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.