Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report