+ 1
Can map be used in strings? Do I have to split a string in order to search and replace elements from it?
const htmlEntities = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }; For example I want to use this object in order to replace these symbols with their code from the word the user enters
3 Réponses
+ 2
No you don't have to use split to find and replace you can use the String method .replace()
https://www.w3schools.com/jsref/jsref_replace.asp
+ 1
map method can only be used on arrays. But split returns you an array.
0
Answer to second question?