Estoy tratando de incrementar el último decimal de un número de 1,234 a 1,235
var numb = 1.234; numb.replace(/\d$/, numb + 1);o digamos que el problema es como seguir
var oNumber = 1.34567 var oDecimalCount = 5 increaseNumber(oNumber, oDecimalCount){ oNumber += //increase the 5th(oDecimalCount) decimal place }Podrías hacer esto:
* 10^n/ 10^n //I found this function here : https://www.tutorialspoint.com/decimal-count-of-a-number-in-javascript const decimalCount = num => { // Convert to String const numStr = String(num); // String Contains Decimal if (numStr.includes('.')) { return numStr.split('.')[1].length; }; // String Does Not Contain Decimal return 0; } let numb = 1.234; let count = decimalCount(numb); console.log(((numb * 10 ** count) + 1) / 10 ** count);No estoy seguro de entender la pregunta por completo, pero ¿no puedes hacerlo así?
let numb = 1.234; numb += 0.001;