//js function n( num, plus, num2 ){ if( num < 1 && num2 < 1 ){ num = num * 10; num2 = num2 * 10; } var num_out = ''+num+plus+num2; num_out = eval(num_out); return num_out/10; } var sum = n(0.1, '+', 0.2); console.log( sum );