Comments

Ball2 months ago

const solve = (strArg) => { return strArg.split('').reduce((rev,c)=>(c!=='(' && c!==')') ? rev+c :rev,'') };

plum invoice4 months ago

return strArg.replace(/[^a-z]/g, "");

Matheus Felipe Trinca5 months ago

const solve = (strArg) => { return strArg.replace(/[^\w]/g, '') };

Boris7075 months ago

const solve = (strArg) => { return strArg.split('').filter(val => val !== '(' && val !== ')').join(''); };

Neil Gebhard5 months ago

Why can't I use .replaceAll() on strArg?

Fatih KAYA6 months ago

return strArg.replace(/[()]/g,"");

PriyankaC6 months ago

strArg.split(/[/(/)]/g).join('');

Richard O'Brien6 months ago

strArg.match(/[a-z]/gi)

Boris7075 months ago

return strArg.match(/[a-z]/gi).join('')

Perry Hunchak8 months ago

const solve = (strArg) => {
  mystring = strArg.split("(").join("").split(")").join(""); 
  return mystring;
};

Ameliorated Tugrik8 months ago

I see there is someone who used a RegExp! Excellent! However, the solution is simplier than you thought. It looks like this one. You don't need to go over each element.

const solve = (str) => str.match(/\w/g).join('')

Bob's your Uncle!

\w - any character g - a global flag, meaning that it'll look for all occurances, not just one.

Ade Putra9 months ago

Why this code not work? const solve = (strArg) => { let str strArg.replaceAll(/[()]/g,""); return str; };

Mohamed El Ghannaya year ago

a simple and a straight forward solution

const solve = (strArg) => {
  let str = "";
  for(char of strArg){
    if(char === '(' || char === ')')
      continue;
    else str+=char;
  }
  return str;
};

deposit8 months ago

thanks for the word 'char' 👏😄

Ketan Ramteke2 years ago

const solve = (strArg) => { return strArg.split("(").join("").split(")").join(""); };

Mohamed El Ghannaya year ago

const solve = (strArg) => {
  return strArg.split('(').join('').split(')').join('')
};

Justin Kim2 years ago

const solve = (strArg) => strArg.split('').filter(c => c !== '(' && c !== ')').join('');

generating cross-platform2 years ago

const solve = (strArg) => { return strArg.split('').filter((leter, i) => { if (leter == '(' || leter == ')') return; return leter; }).join(''); };

benchmark Turkmenistan Granite2 years ago

i used this line:

const solve = strArg => strArg.split``.filter(el=>el.match(/\w/i))

Michael Morgan2 years ago

return strArg.replace(/(|)/gi, '');

Tobias Fried2 years ago

Forgot to escape the parens!

const solve = (strArg) => {
  return strArg.replace(/\(|\)/g, "");
};

DennisLoska2 years ago

const solve = (strArg) => strArg.split('').filter(str => !str.includes('(') && !str.includes(')')).join('')

Haven't learned RegExp yet they look ugly.