I want to sum 2 input values but in one form with JavaScript, like this image:
then the output will be 350. is this possible?
I want to sum 2 input values but in one form with JavaScript, like this image:
then the output will be 350. is this possible?
const sum = value
.split('+')
.map(value => Number(value))
.reduce((agg, val) => agg + val, 0);
Where value
is the value from your form. This will also work for longer chains and with or without spaces, like 1 + 2+3
.