Code passing, but not logging to the console correctly


Hello everyone, here is the code I am using:

var text = "let's try this again and again and again until I get it";
var foundT=[];
for (var i=0;i<=text.length;text++) {
    if (i==="t") {

var looper = function() {
    while (3*text.length<1000) {
        console.log("not there yet");
do {
    console.log("this cannot be correct");
} while (5<4)

I cannot seem to figure out why it is accepting this code and why I am only logging an empty array to the console.


What do you see and what do you don't see? There are a few things that might be a problem:

for (var i=0;i<=text.length;text++) {

Why text++? Text is a string so this doesn't make much sense and might cause an infinite loop as i remains 0 this way.Then the looper function isn't called and therefore not executed anywhere. Also this statement:


just computes a value but does not change the value of text.length so your condition will stay true and therefore you'll have another infinite loop. The last loop is ok.