The inner loop does not have to start from the very beginning every time.
First set would be 99x99, 99x98, 99x97... 99x1
Second set would be 98x98, 98x97, 98x96... 98x1
Third set: 97x97, 97x96, 97x95... 97x1
In second set you don't test 98x99 because you already tested 99x98 in first set.
L.A. based web developer slowly parsing through Stack Overflow. If you like hot web dev tips or stories about being a freelancer, check out my newsletter: https://codenutt.substack.com/p/coming-soon
for (let j = largestNum; j > 0; j--)
can become:
for (let j = i; j > 0; j--)
The inner loop does not have to start from the very beginning every time.
First set would be 99x99, 99x98, 99x97... 99x1
Second set would be 98x98, 98x97, 98x96... 98x1
Third set: 97x97, 97x96, 97x95... 97x1
In second set you don't test 98x99 because you already tested 99x98 in first set.
Ohhh, I see. That's genius. Thank you!