Sunday November 22, 2009
The fourth tutorial on "Regular Expressions" shows you how to split a string into several parts by matching it with a regular expression.
Splitting Matches
Saturday November 21, 2009
JavaScript can display the answer in roman numerals
Sometimes displaying a number on your web page as a normal number just doesn't look right. Sometimes it may be more appropriate to display the number on your web page using Roman Numerals instead. This simple Javascript function can handle the conversion of any number between 1 and 3999 into the roman numeral equivalent for you.
Convert to Roman Numerals
Friday November 20, 2009
Convert numbers to Words with JavaScript.
JavaScript does an excellent job of being able to manipulate numbers and even provides some quite advanced mathematical functions. What happens though when you want to print out the result of that manipulation in words rather than numbers? You use a
simple function that will do the conversion for you.
Numbers to Words
Thursday November 19, 2009
The format JavaScript wants to work with isn't always the same as the format you want to display the result in.
To be able to process numbers in JavaScript they must contain nothing except digits and perhaps a period as the decimal point and a dash for a minus sign. If you include anything else then Javascript treats it as a text string instead of a number and so will not allow you to use it in calculations. What would be useful though is a way to take those numbers and apply some formatting to them (comma separators, currency etc.) before displaying the result in our web page. Since this may need to be done for several numbers it is best done using a function and to save you the trouble of working out the JavaScript to do this I have written this function for you.
Now updated to correctly handle numbers between 1 and -1.
Formatting Numbers