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
ES6 method of declaration multiple variables in one line
How to get selected text from a select box using jQuery?
JavaScript convert string variable in boolean using Regex
JavaScript HTML5 Validation for name and email field
Image Rollover Using onMouseOver and onMouseOut
jQuery example of scroll to top
Using jQuery delete table row on click
Example to take user input and display on screen using JavaScript
jQuery show input text inside div after on click event
JavaScript calculate Fahrenheit from Celsius