0
Pushing entry to an array
I wrote a code to spawn pythagoras numbers i,j,k like 3,4,5 or 6,8,10 and so on. I set the 3 numbers as an entry to an array. How do I avoid adding entry when i is the same as j? For instance I want just 3,4,5 to be added to the array without adding 4,3,5. Or adding 6,8,10 without adding 8,6,10 and so on. https://code.sololearn.com/WBfVE8RroS1I/?ref=app
3 Antworten
+ 1
if(i*i+j*j==k*k && i<j && j<k){
r=i+" "+j+" "+k;
a.push(r);
b=a.join("<br>");
pytaoutput.innerHTML=b;
}
would be the easiest way I think.
+ 1
Thanks brooo 😀
0
seemingly works