0
I have the myFunction function that calculates the product of two numbers and displays them on the screen. I would like to shift this function to the Listen function when the value of P1=10. The way it is, it only displays the value of myFunction, and ignores the equality P1=10 to make the detour. Can help me?
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Functions</h2>
<p id="demo"></p>
<script>
function myFunction(p1, p2) {
if (p1=10)  {listen(a)}
    return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(10, 3);
var a ="jj";
function listen(k){
 var s1 = k;
 alert(s1);
 return k
 }
</script>
</body>
</html>
I gave an answer to the main problem of your code, but I’m intrigued by the function
listen. What’s your role? Just make onealert? why thereturn? will be integrated into the result ofmyFunction?– Sergio