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
How to declare and print value of variable in JavaScript?
How to join string with number in JavaScript?
Get largest number from each sub-arrays
How to set checkbox and radio option checked on load with jQuery?
jQuery simple form validations between start date and end date
JavaScript HTML5 Validation for name and email field