The main issue you're facing is that the variables array
and array1
are of type 'string' and are not arrays. The reason why you're not getting an error is that within strings, you can also use the index to access a character. So with the code string const text = 'hello'
, then accessing the elements as if it's an array, such as text[1] //'e'
will produce the character in that spot.
As to your code, I cannot see where the variables array
and array1
are redefined to be a string, but there are a number of ways those variables may become a string between the time you defined them (or when a
is called) to when the function moriodotisi
is called. I suspect you have somewhere some code that looks like this array = document.getElementById("Fname").value
.
To advice on where specifically your bug is, I'd need to see more code, but from what I've said above, it should be enough to track down the issue.
I'd recommend placing some console.log('')
calls to follow array
as you run the script.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…