+ 1

Why is this fuction not working well[solved]

var as = prompt("escribe la poscición en el array a");     var bs = prompt("escribe la poscición en el array b"); function comp (a, b) {   comp (as,bs);    var arr1 = [10-6,7*4, 3+2];   var arr2 = [1,3,5,7];     if (arr1[a] > arr2[b]) {     document.write("El primer elemento de arr1 es mayor que el primero de arr2"+"<br>");   }else if(arr1[a] < arr2[b]){     document.write("El primer elemento de arr1 es menor que el primero de arr2"+"<br>");   }else{      document.write("El primer elemento de arr1 es igual que el primero de arr2"+"<br>");   } } ////maybe this code is so werid but it was an experiment. The user should put the number of the place of the array 1 and 2 and it will compare it but it don't shows nothing. I repeat maybe is a very werid code...

23rd Oct 2020, 5:39 PM
Carmen Lucía
Carmen Lucía - avatar
2 ответов
+ 3
Shudn't call to comp function (comp(as,bs)) be outside of that function?
23rd Oct 2020, 5:53 PM
Abhay
Abhay - avatar
+ 2
Oh yes now it works ¡thanks!
23rd Oct 2020, 5:56 PM
Carmen Lucía
Carmen Lucía - avatar