Because for…in loop is designed to go through the properties of an object. The variable x will be a string type. For array, it is better to use for instead. For your reference.
Came from https://www.w3schools.com/jsref/jsref_forin.asp
JavaScript supports different kinds of loops:
for - loops through a block of code a number of times
for/in - loops through the properties of an object
for/of - loops through the values of an iterable object
while - loops through a block of code while a specified condition is true
do/while - loops through a block of code once, and then repeats the loop while a specified condition is true Note Do not use the for/in statement to loop through arrays where index order is important. Use the for statement instead.