Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use for Loop to realize Sum in js

Shulou Source: shulou.com Published: 2022-06-01 02:09:11 09月21日 Update

This article mainly introduces how js uses the for cycle to achieve summation, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

Using for loops, summation

Function sum (arr) {var s = 0; for (var ionomarr.lichmer1; I > = 0; iMel -) {s + = arr [I];} return s } Thank you for reading this article carefully. I hope the article "how js uses the for cycle to achieve peace" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles cycles values interests at the same time more friends knowledge editing industry information information channels channels references learning help support Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux Microsoft Redmi Shulou Technology