简体   繁体   中英

How to seperate a number into smaller components? [JavaScript]

I am making a JavaScript app that calculates the result of two numbers multiplied. How do I show the components of a number? For example, number = 123. hundreds = 1, tens = 2, ones = 3.

You can use a while loop in which it checks until the number becomes zero. You can take the mod with 10 of the number and divide it by 10.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM