js add numbers code example
Example 1: javascript add nd st th to number
function ordinal(number) {
const english_ordinal_rules = new Intl.PluralRules("en", {
type: "ordinal"
});
const suffixes = {
one: "st",
two: "nd",
few: "rd",
other: "th"
}
const suffix = suffixes[english_ordinal_rules.select(number)];
return (number + suffix);
}
ordinal(3);
ordinal(111);
ordinal(-1);
Example 2: how to add two numbers in javascript
let a = 4;
let b = 5;
document.write(a + b);
Example 3: adding numbers in Javscript
return a+b;