Home  >  Article  >  Web Front-end  >  The difference between break and continue and rounding

The difference between break and continue and rounding

巴扎黑
巴扎黑Original
2016-11-25 09:44:321998browse

①The difference and function of break and continue

Both break and continue are used to control the loop structure, mainly to stop the loop.
1.break
Sometimes we want to terminate the loop when a certain condition occurs instead of waiting until the loop condition is false.
This is what we can do using break. break is used to completely end a loop and jump out of the loop body to execute the statements following the loop.
2.continue
continue is somewhat similar to break. The difference is that continue only terminates this loop and then executes the following loops, while break terminates the loop completely.
It can be understood that continue means skipping the remaining statements in the current loop and executing the next loop.


②toFixed() method can round Number to a number with specified decimal places. toFixed (fixed)
Note: [The numeric parameter of tofixed() must be between 0 and 20, and a in a.tofixed() must be of type number]
Syntax NumberObject.toFixed(num)
(items[i].count *items[i].price).toFixed(2) Output the total price ##.00 yuan

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn