+ 2
Help! Reduce code
How i do it right? var num0 = document.getElementById("num0").value*1; var num2 = document.getElementById("num2").value*1; var num1 = document.getElementById("num1").value*1; var num3 = document.getElementById("num3").value*1; var i = 0; while (i<4) { var [`num${i}`] = document.getElementById(`num${i++}`).value*1;] }
2 Antworten
+ 7
// look at this
var num0 = document.getElementById("num0").value*1;
var num2 = document.getElementById("num2").value*1;
var num1 = document.getElementById("num1").value*1;
var num3 = document.getElementById("num3").value*1;
let nums = [num0, num1, num2, num3];
var i = 0;
while (i<4) {
nums[i] = document.getElementById(`num${i++}`).value*1;
//cannot understand what do you want here
}
+ 2
Thanks, i was thought it too, but i wanted not use arrays.
I want to optimize my code:
https://www.sololearn.com/post/114558/?ref=app