console.log(str1), I just used to see how the code is looking but does not the str1.replace(/\s/g, “”); should do the trick to replace (,) hence joining the string.
Actually i am confused with {str1.replace(/\s/g, “”);} if i remove this part of code i am getting o,l,l,e,h as a output
Look up the replace method and what it returns. The code str1.replace(/,/g, "") is doing what you want, but you are not saving the results anywhere and it is getting tossed out.