1/**
2 * Function to check if a string contains any numbers
3 * @author Sebastian Keable
4 * @param {String} str - String to be checked.
5 * @returns {Boolean} str - Result of the check.
6 */
7function containsNumbers(str){
8 var regexp = /\d/g;
9 return regexp.test(str);
10};
11
12// use function below
13containsNumbers("Here are some Numbers 2123"); // => true
14containsNumbers("Here are no Numbers"); // => false
1/**
2 * Function to check if a string contains numbers
3 * @author Okoro Redemption
4 * @param {String} str - The string to be checked.
5 * @returns {Boolean} str - The result of the check.
6 */
7function hasNumbers(str){
8 var regexp = /d/g;
9 return regexp.test(str);
10};
11
12// use function below
13hasNumbers("I am 20years old"); // => true
14hasNumbers("I am a boy"); // => false