Number to word
Convert currency into words
by bvotcode
JavaScript
function capitalize(words)
{
return words.charAt(0).toUpperCase() + words.substr(1) +" đồng"
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
var test1 = capitalizeFirstLetter('mot ngan dong')
var test2 = capitalize('hai ngan dong')
console.log("test1 " +test1)
console.log("test2 " +test2)
function titleCase(str) {
str = str.toLowerCase().split(' '); //take str, lowercase all letters, create array
for (var i = 0; i < str.length; i++){ //iterate over the array
str[i] = str[i].split(''); //take each index of the array and turn it into a new index
str[i][0] = str[i][0].toUpperCase();//now we have a multi-d array. find the first letter make it uppercase
str[i] = str[i].join(''); //take the multi-d array join it into an array
}
document.write(str.join(' ')); //take the new array from above, turn it back into a string
}
titleCase("đồng");