Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.
<script>
console.log(stringContainString(["Alien", "line"])); // true
console.log(stringContainString(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])); // true
console.log(stringContainString(["Hello", "hey"])); // false
function stringContainString(arr) {
return arr[1].toLowerCase()
.split('')
.every(function(letter) {
return arr[0].toLowerCase()
.indexOf(letter) != -1;
});
}
</script>
Most Helpful This Week
jQuery get the coordinates of div clicked
Highlight and get the details of table row on click using JavaScript
Get largest number from each sub-arrays
jQuery move multi select values from one to another multi select list
Generate random password for form field on click using JavaScript
JavaScript example to change image on click