Write a function that takes in one argument. The function should return true if the passed in argument is a valid X Number. A valid X number is 9 characters in length, begins with a X and ends with 8 digits. The function should return false if it is not valid X Number.
Call the function 4 times, 2 times with valid X Numbers and 2 times with invalid X Numbers and display the results.
1
Expert's answer
2016-11-10T13:42:09-0500
function checkNumber(n) { return n.match(/^X\d{8}/)?true:false; }
Comments
Leave a comment