Generation

generate functionSat, 12 Nov 2022

generate a function named "converter", it has two string parameters. If each parameter contains only numbers, convert it to int type, and the return value is this the converted value. else the return value is "Ezeket nem lehet összeadni." write all return value to the console with "console.log" expression.

function converter(a, b) { if (a.match(/^\d+$/) && b.match(/^\d+$/)) { return parseInt(a) + parseInt(b); } return "Ezeket nem lehet összeadni."; }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant