JSFiddle - React, Tailwind, and code Playground
JavaScript
var str = '678'.split('');
var input = '679'.split('');
var result = '';
input.map((w,e) => {
if (w === str[e]) {
function one() {
result+=1
} return one()
} else {
function two(){
result +=2
}
return two()
}
})