Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just saw the exercise of code academy. There is nothing wrong with your code except, you are pushing <code>text[i]</code> instead of <code>text[i+j]</code> into hits array.</p> <p>Actually code academy wanted you will write the code according to their hints.</p> <p>In their hint you will be able to see <code>Your loop should stop when it hits the value of the first iterator (say, i) plus the length of your myName variable.</code></p> <p>your code</p> <pre><code>var text = "Lorem ipsum dolor nayr sit amet, consectetur adipisicing elit, sed do eiusmod tempor yan ut Ryan labore et dolore magna aliqua. Ut enim ad ry minim veniam, quis nostrud ryan exercitation ullamco ryan laboris nisi ut aliquip ex ea ry commodo rya consequat. END"; var myName = "Ryan"; var hits = []; // empty array to 'push()' my name into for(var i = 0; i &lt; text.length; i++ ){ if(text[i] == myName[0]){ for(var j = 0; j &lt; myName.length; j++){ hits.push(text[j+i]); } } } </code></pre> <p>If you replace you code with the below code, they will say okay</p> <pre><code>var text = "Lorem ipsum dolor nayr sit amet, consectetur adipisicing elit, sed do eiusmod tempor yan ut Ryan labore et dolore magna aliqua. Ut enim ad ry minim veniam, quis nostrud ryan exercitation ullamco ryan laboris nisi ut aliquip ex ea ry commodo rya consequat. END"; var myName = "Ryan"; var hits = []; // empty array to 'push()' my name into for(var i = 0; i &lt; text.length; i++ ){ if(text[i] == myName[0]){ for(var j = -1; j &lt; myName.length+1; j++){ hits.push(text[j+i+1]); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload