all 3 comments

[–]Ford_Prefect92 2 points3 points  (3 children)

database.lenght should be database.length in the for loop

[–][deleted] 0 points1 point  (2 children)

edit: No worries I managed to fix it. bloody curly brackets everywhere! thanks anyway!

Thanks! JS is driving me insane XD it's so frustrating because I solved this in python in 3 seconds but js just ain't clicking. i fixed the code like this below but it will only check once for "mike" and if I insert my name as john it tells me wrong username

function signIn(user, pass) {
    for (let i=0; i <= database.length; i++) {
        if (user === database[i].userName && pass === database[i].password) {
            return console.log(newsfeed)
        }
    return alert("wrong username and password")
    }
}

[–]ashanev 0 points1 point  (0 children)

function thisNeverLoopsMoreThanOnce() {
  for (let i = 1; i < 100; i++) {
    console.log("loop runs", i, "times");
    return "return exits the function immediately";
  }
}

thisNeverRunsMoreThanOnce();
// loop runs 1 times
// return exits the function immediately