contains-number

Checks if a string or an array contains a number

Usage no npm install needed!

<script type="module">
  import containsNumber from 'https://cdn.skypack.dev/contains-number';
</script>

README

Contains Number

Checks if a string or an array contains a number.

Installation

npm install contains-number

Usage

Create a global variable.

const check = require('contains-number');


Check if a string contains a number

To check if a string contains a number call the following function with the string as parameter.

let txt = 'This is the 1st test!';
let contains = check.stringContainsNumber(txt);
console.log(contains);

Output:
The output is true if the string contains a number or false if the string does not contain a number.

true


Check if an array contains a number

To check if an array contains a number call the following function with the string as parameter.

let arr = [1, 'asfddf'];
let contains = check.arrayContainsNumber(arr);
console.log(contains);

Output:
The output is true if the array contains a number or false if the array does not contain a number.

true