How to extract last(end) digit of the Number value using jquery. because i have to check the last digit of number is 0 or 5. so how to get last digit after decimal point
<
This worked for us:
var sampleNumber = 123456789,
lastDigit = sampleNumber % 10;
console.log('The last digit of ', sampleNumber, ' is ', lastDigit);
Works for decimals:
var sampleNumber = 12345678.89,
lastDigit = Number.isInteger(sampleNumber) ? sampleNumber % 10
: sampleNumber.toString().slice(-1);
console.log('The last digit of ', sampleNumber, ' is ', lastDigit);
Click on Run code snippet to verify.