Comments

Pomelo_Bank2 days ago

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

Anurag Arwalkar19 days ago

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

Cambridgeshire Computers Leka month ago

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

Ali Sequeira6 months ago

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

Bhargav7 months ago

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

Matías Duhalde8 months ago

One liner using RegExp

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

Mac Villegas8 months ago

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

Wagner CS Filho10 months ago

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

action-items10 months ago

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

Samuel Egwurubea year ago

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

Abdelhamid Ismail2 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 };

Meghna Srivastava2 years ago

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

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

Daniel Ferreira2 years ago

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

Kara Diaby2 years ago

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

Juan Luis Rojas León2 years ago

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

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

Mohamed El Ghannay2 years ago

your solution is better although this one works also

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

SAS2 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.