The condition is always true, because you assign this value to the variable and this is the value which is evaluated for the if clause.
But you could use a direct check without a compare value (and without assigning this value).
Beside that, you could change the else part to only an if part, becaue you exit the function with return, so no more else happen in this case.
if (usernameExists) {
console.log("returning true");
return true;
}
if (looped) {
console.log(usernameExists+" is returned");
looped = null;
return false;
}