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 null

function converter(a, b) { if (checkNumber(a) && checkNumber(b)) { return parseInt(a) + parseInt(b) } return null } function checkNumber(s) { return /^\d+$/.test(s) }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant