Implement a function startsWith(start)
.
It should accept a single parameter start
and return a function that takes a string s
and checks if s
starts with start
.
start
is a string that consists of one or more characters
If s
passes the check, the closure should return true
, otherwise - false
This task is part of the Full-Stack JavaScript Course
If you have any issues with it, you can ask for community help below the post
Feel free to help others if you’ve already solved the task
functions.js
export const startsWith = (start) => {
return (s) => {
};
}
solution.js
/**
* Implement the function `startsWith(start)`.
* */
import { startsWith } from './functions.js';
const words = [ 'good', 'god', 'goblin', 'grand', 'giga', 'mega', 'force', 'joy', 'giggle', 'global', 'function' ];
console.log(words.filter(startsWith('g')));
console.log(words.filter(startsWith('go')));
console.log(words.filter(startsWith('f')));