I need to check if my array has the word
This is my code please help
var name = ['heine', 'hans'];
var password = ['12343', '1234'];
function login() {
var pos;
if(name.includes('hans')) {
console.log("enthält");
pos = name.indexOf('hans');
console.log(pos)
if(password[pos] === '1234') {
console.log("angemeldet")
}
}
}
consoleout = 6, but why, it must be a 1
If the word hans is in the array, than i need the position from the word in the array
indexOf()password[i] === 1234will however always be false, due to the passwords being strings and the usage of===nameis a string. Which is very odd.