when i want to get the array value its becomes undefined. what i am doing worng and how to fix it?
var cars = [4, 8];
for (i = 0; i < cars.length; i++) {
fetch("http://example.com?id=" + cars[i], {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Upgrade-Insecure-Requests": "1",
"Cache-Control": "max-age=0"
},
"method": "GET",
"mode": "cors",
})
.then(response => response.text())
.then(str => {
var text = str.split('yesyes')[1];
var abc = text.split('nono')[0];
document.write(abc + " = " + cars[i]);
})
}