63 815
Assignments Done
99,5%
Successfully Done
In August 2018

Answer to Question #63155 in AJAX | JavaScript | HTML | PHP for Miguel Rivera

Question #63155
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.
Expert's answer
function checkNumber(n) {
return n.match(/^X\d{8}/)?true:false;
}

console.log(checkNumber('X00878765'));
console.log(checkNumber('X28878765'));
console.log(checkNumber('X2887876'));
console.log(checkNumber('32887876'));

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions