
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to round the decimal number to the nearest tenth in JavaScript?
To round the decimal number to the nearest tenth, use toFixed(1) in JavaScript. The syntax is as follows −
var anyVaribleName=yourVariableName.toFixed(1)
Let’s say the following is our decimal number −
var decimalValue =200.432144444555; console.log("Actual value="+decimalValue)
Let’s now round the decimal number. Following is the code −
Example
var decimalValue =200.432144444555; console.log("Actual value="+decimalValue) var modifiedValue=decimalValue.toFixed(1) console.log("Modified value="+ modifiedValue);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo38.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo38.js Actual value=200.432144444555 Modified value=200.4
- Related Articles
- How to round up to the nearest N in JavaScript
- Round a number to the nearest even number in C#
- Round number down to nearest power of 10 JavaScript
- How to round to the nearest hundred in R?
- Round off the following number to the nearest hundred:236
- Round off the following number to the nearest tens. 7896.
- How can I round a number to 1 decimal place in JavaScript?
- How to round off the numbers nearest tens?
- How to round off to nearest thousands?
- How to round a number to n decimal places in Java
- Round off to the nearest thousand.$5914$
- Round off 4200 to the nearest thousands.
- How to round down to nearest integer in MySQL?
- How to round off numbers In nearest $100$.
- How to round up a number in JavaScript?

Advertisements