# Comments

2 days ago

const solve = (s1, s2) => s1.startsWith(s2);

19 days ago

const solve = (strOne, strTwo) => { return strOne.includes(strTwo); };

a month ago

const solve = (strOne, strTwo) => { return strOne.split(strTwo)[0] === ' ' ? true : false ; };

6 months ago

`const solve = (strOne, strTwo) => { const prefix = strOne.slice(0,strTwo.length) return prefix === strTwo; };`

7 months ago

``````const solve = (strOne, strTwo) => {
return strOne.substring(0,strTwo.length) === strTwo;
};

``````

8 months ago

One liner using RegExp

``````const solve = (strOne, strTwo) => !!strOne.match(new RegExp(`^\${strTwo}`, 'g'))
``````

8 months ago

`const solve = (strOne, strTwo) => { return strOne.includes(strTwo); }; `

10 months ago

``````const solve = (strOne, strTwo) => {
return strOne.indexOf(strTwo) === 0;
};
``````

10 months ago

const solve = (strOne, strTwo) => { return (strOne.indexOf(strTwo)==0 ? true : false); };

a year ago

``````const solve = (strOne, strTwo) => {
return strTwo === strOne.slice(0,strTwo.length)
};
``````

2 years ago

this is my solution , but i realised there is better soloutions here (startsWith) and (includes) are much simpler

const solve = (strOne, strTwo) => { return strOne.split('').slice(0,strTwo.length).join('') === strTwo };

2 years ago

const solve = (strOne, strTwo) => { const strTwoLength = strTwo.length;

return strOne.substring(0, strTwoLength) === strTwo; };

2 years ago

const solve = (strOne, strTwo) => { return strOne.startsWith(strTwo); };

2 years ago

const solve = (strOne, strTwo) => { return strOne.includes(strTwo) }; ``

2 years ago

startsWith determines whether a string begins with the characters of a specified string.

``````const solve = (strOne, strTwo) => {
return strOne.startsWith(strTwo)
};

``````

2 years ago

your solution is better although this one works also

``````const solve = (strOne, strTwo) => {
return strOne.includes(strTwo);
};

``````

2 years ago

I like this solution as it is very specific to the question, becasue a prefix will always start at the beginning of the string where includes will find it anywhere within the string.