Javascript

Given a string remove all + present together in the string. Javascript Program

Input string =’a+++b++c+’;

Output String=a+b+c+

Source Code

let str='a+++b++c+';
let outStr='';
let len=str.length;
for(let i=0;i<len;i++)
{
    if(str[i]=='+'&&str[i+1]=='+')
    {
        outStr=outStr+'';

    }
    else
    {
        outStr=outStr+str[i];
    }
}
console.log(outStr);