how to check if a string contains numbers in javascript
/**
* Function to check if a string contains numbers
* @author Okoro Redemption
* @param {String} str - The string to be checked.
* @returns {Boolean} str - The result of the check.
*/
function hasNumbers(str){
var regexp = /d/g;
return regexp.test(str);
};
// use function below
hasNumbers("I am 20years old"); // => true
hasNumbers("I am a boy"); // => false
Also in JavaScript:
- get select option count using jquery
- json file example
- how set defualt image for dropify
- js .length
- discord.js tempmute command
- express and node
- javascript array add end
- nodejs include json file
- captitalize js
- document write
- node close rabbitmq connection
- add select option jquery
- primitive and non primitive data types in javascript
- nodejs function example
- How to use hash in javascript
- get last date of a month javascript
- react native cover image in parent view
- how to delete everything from a folder in js
- react window navigate
- javascript get browser name
- how to set validation for email in javascript
- javascript how to pass an action back in a function
- if else condition on hide and show in jquery
- javascript codegolf round