I want to replace some of the words from the user's input using customized characters. The string will be like this
var userInput = "five plus five equal to ten multiply 5";
This is what I tried to do
const punctLists = {
name: 'star',
tag: '*'
},
{
name: 'bracket',
tag: ')'
}, {
name: 'multiply',
tag: '*'
}, {
name: 'plus',
tag: '+'
}, {
name: 'double equals',
tag: '=='
}, {
name: 'equal',
tag: '='
}]
var matchPunction = punctLists.find(tag => tag.name == userInput);
if (matchPunction) {
userInput = matchPunction.tag;
}
But it is not working. I want something like this :
var userInput = "5+5 = 10*5";
Any idea?
texthere intext = matchPunction.tag;?five and tenas well