Get the App
SLTechnology News&Howtos  ›  Development  › 

How to find the Sum of Odd numbers within 100 by javascript

Shulou Source: shulou.com Published: 2022-06-03 16:32:45 11月17日 Update

This article introduces you how to find the odd sum of javascript within 100, the content is very detailed, interested friends can refer to, hope to be helpful to you.

1. Use the for loop to control the range, traversing the number 1x 100.

2. Use the if statement to determine whether the number I is odd (whether I can be divisible by 2).

If it is odd, add sum+=i

So at the end of the for loop, you get an odd number and sum.

3. Output odd number and sum at last.

Example

Var sum = 0 for (var I = 1; I)

Tags: Odd numbers content numbers more help loops good interests examples guys buddies articles knowledge articles scope statements references controls output Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Tech Info Redmi vpn Linux