Write your own function that multiplies by 2, rounds, then divides by 2, e.g.
function roundHalf(num) {
return Math.round(num*2)/2;
}
More Related Contents:
- Calculate text width with JavaScript
- download file using an ajax request
- Why can’t I call a function named clear from an onclick attribute?
- JavaScript Form Submit – Confirm or Cancel Submission Dialog Box
- enabling cross-origin resource sharing on IIS7
- How to detect browser’s protocol handlers?
- How to add a tooltip to an svg graphic?
- Which browsers support ?
- Convert JS Object to form data
- How to access `window` (Target page) objects when @grant values are set?
- Javascript functions like “var foo = function bar() …”?
- jquery attr(‘checked’,’checked’) works only once
- this operator in javascript
- How to clear cache of service worker?
- Modify object property in an array of objects
- Chrome extension Content Script not loaded until page is refreshed
- Retain Twitter Bootstrap Collapse state on Page refresh/Navigation
- (Embed and) Refer to an external SVG via D3 and/or javascript
- Real world examples of Ecmascript functions returning a Reference?
- Why no Array.prototype.flatMap in javascript?
- JQuery Ajax Post results in 500 Internal Server Error
- Recall Tampermonkey script when page location changes
- Finding child element of parent with JavaScript
- Jquery: mousedown effect (while left click is held down)
- how express forming the img URL
- Confused on how a JSONP request works
- Using a block’s return value in JavaScript
- JSON to string variable dump
- Is it possible to make an in-app button that triggers the PWA “Add to Home Screen” install banner?
- Configure grunt copy task to exclude files/folders