-2
Guys, I’m starting in JS and would like to know how I do to display the results of the product() function in html, because in console.log it works correctly (console.log(product(1, 2, 3))) Can anyone help? Thank you
function product(x, y, z) {
var arg1 = document.getElementById('arg-1').value
var arg2 = document.getElementById('arg-2').value
var arg3 = document.getElementById('arg-3').value
if (x !== undefined && y === undefined && z === undefined) {
return x;
} else if (x !== undefined && y !== undefined && z === undefined) {
return x + y;
} else if (x !== undefined && y !== undefined && z !== undefined) {
return (x + y) / z;
} else if (x === undefined && y === undefined && z === undefined) {
return false;
} else {
return null;
}
}
console.log(product(1, 2, 3))
<input type="number" id="arg-1">
<input type="number" id="arg-2">
<input type="number" id="arg-2">
<button onclick="product()">Submit</button>
<p id="saida"></p>
Oops, dude really helped was that, thanks!
– Thiago