programming-examples/js/String/Test whether a string starts with a specified string.js

4 lines
140 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function startsWith(input, string) {
return input.indexOf(string) === 0;
}
console.log(startsWith('js string exercises', 'js'));