Javascript help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Javascript help

I saw on the internet that with the function calcula it is determined which number is greater in an arrangement, but I don't know what the logic of the cycle is for exactly I do not understand it, can someone help me and teach better? Sorry for my english, thanks function capturado() { coleccion.push(parseInt(entrada.value)); console.log(coleccion); } coleccion=[]; function calcula() { max=0; for (var i = 0; i <coleccion.length; i++) { if (max<coleccion[i]) { max = coleccion[i]; } } console.log(max); }

14th Sep 2019, 11:57 PM
Jesus Hernandez
Jesus Hernandez - avatar
3 Answers
+ 2
What are u trying to do with the code ? I don't really understand. I speak Spanish btw if that's what u prefer
15th Sep 2019, 12:53 AM
Minerals2016
Minerals2016 - avatar
+ 2
Entiendo q coleccion es el array. i < coleccion.length significa q i es menos q el array de coleccion para q pare el loop. A lo q yo entiendo. Responde su pregunta o no ? 🤔
15th Sep 2019, 1:35 AM
Minerals2016
Minerals2016 - avatar
0
Ahh esta bien, lo que no entiendo del codigo es por que el If que esta dentro del ciclo For tiene esa condicion max< coleccion[i] , siendon coleccion el array donde tengo los numeros que comparara para saber cual es mayor
15th Sep 2019, 12:56 AM
Jesus Hernandez
Jesus Hernandez - avatar