Skip to content
Advertisement

Tag: str-replace

What is the appropriate use for the .replace method within this context/ within a .map method?

I’m trying to loop through an array of strings and for each element(string) in that array, change the character after the “_” underscore character to a “*” character. Strings are immutable so, pushing this all to a new array. The chain performs as expected when directly targeting the underscore for replacement: But the moment the actual intended function is pursued,

How to use “for” along with string replace?

I want to make several replacements in the same string. I have this: after the replacements it should look like this: So I tried: but it doesnt seem to do anything. What is wrong? Answer The way you wrote it now, it will only replace on the last id and assign it to the mylist variable, because .replace does not

How do I convert a string to spinal case in JavasScript?

I am stuck on this coding challenge Spinal Tap Case from freeCodeCamp. Essentially I don’t know how to get the last check to execute. This is the last check: spinalCase(“AllThe-small Things”) should return “all-the-small-things” And this is my code: I do realize the last else ifcondition should go first however I didn’t get the syntax right. Thanks in advance! Answer

Advertisement