Change for each by a normal for

0

I have an Object that is films and with this I am going to call an ajax function so that it shows me a title of a movie (In the api they send me 4 or more) to go through each movie I made a FOREACH but I want it to show me only one so I try with for (var j = 0; j

asked by Bella 08.02.2018 в 11:03
source

1 answer

2

instead of

films.forEach(function (url) {
   //codigo a ejecutar que usa el parámetro url...
}

usa

//codigo a ejecutar que usa el parametro url, pero sustituyendo
// url por films[0]

For example:

var request = new XMLHttpRequest();
...
request.open('GET',films[0]);
    
answered by 08.02.2018 / 13:00
source