Divide the number by 10
, round the result and multiply it with 10
again, for example:
33 / 10 = 3.3
3.3 rounded = 3
3 × 10 = 30
console.log(Math.round(prompt('Enter a number', 33) / 10) * 10);
More Related Contents:
- Is it possible in javascript to invoke "Object" [closed]
- fixing slider on my website [closed]
- Transform numbers to words in lakh / crore system
- Difference in Months between two dates in JavaScript
- form serialize javascript (no framework)
- Make Axios send cookies in its requests automatically
- What does ~~ (“double tilde”) do in Javascript?
- Difference between textContent vs innerText
- Check if an element is present in an array [duplicate]
- Why is “this” in an anonymous function undefined when using strict?
- jQuery function to get all unique elements from an array?
- Sort an array based on another array of integers
- node and Error: EMFILE, too many open files
- html5 display audio currentTime
- What is meant by “public function can’t be overridden if a patch is necessary.” in Addy’s description of the Revealing Module Pattern?
- WebView methods on same thread error
- How do you float elements without a vertical gap?
- Find property by name in a deep object
- What is the need for caret (^) and dollar symbol ($) in regular expression?
- How do I keep the current tab active with twitter bootstrap after a page reload?
- Confusion between isNaN and Number.isNaN in javascript
- Does chrome supports document.selection?
- How can I delete a window.history state?
- “Permission denied” with Internet Explorer and jQuery
- Detecting HTML5 Drag And Drop support in javascript
- Can you create functions with custom prototypes in JavaScript?
- Find if variable is divisible by 2
- using css modules how do I define more than one style name
- Change and transition dataset in chord diagram with D3
- How to get and set the current web page scroll position?