Skip to main content Accessibility Feedback

isTenBased.js

Check if a number ten-based (10, 100, 1000, etc.).

Works in all modern browsers, and at least back to IE9.

/*!
 * Check if a number ten-based (10, 100, 1000, etc.)
 * (c) 2019 Chris Ferdinandi, MIT License, https://gomakethings.com
 * @param  {Integer}  num The number
 * @return {Boolean}      If true, the number is ten-based
 */
var isTenBased = function (num) {
	var str = num.toString();
	var first = str.slice(0, 1);
	var rest = str.slice(1, str.length);
	return first === '1' & parseFloat(rest) === 0;
};