I came up by my own with an alternative solution for Convert HTML Entities Challenge.
It might be basic but I’m happy that it looks good and that I didn’t find a similar solution it in the comments of the challenge.
Also I think it’s a good excuse to start participating in the forum
If you think there is something that I could change to do a better practice, please let me know
Thanks!
I am a bit confused as to how what you have written works. map((char) => char === “&” ? “&” this line will simply return what char already is with no conversion. The whole function as far as I can tell simply returns an unaltered string. Did you perhaps leave out some of your code?
That aside I personally do not like a bunch of chained ternaries as I find them difficult to read, and in this case you have essentially written a switch statement so you might as well use it unless you do not like switch statements, and I personally do not, but they have there place.
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.