April 28, 2019
Javascript Challenge #8: Filter by Starting & Ending of String
const myArray = [
'Blue Sky',
'light green',
'dark Green',
'Blue Van'
];
function getStartswith(wordsArray, word) {
return wordsArray.filter(myword => myword.toLowerCase().startsWith(word));
}
function getEndswith(wordsArray, word) {
return wordsArray.filter(myword => myword.toLowerCase().endsWith(word));
}
const result = getStartswith(myArray, 'blue');
console.log(result);