I have the function myFunction that calculates the product of two numbers and displays them on the screen. I would like to divert this function to the listen function when the value of p1 = 10. As it stands, it only displays the value of myFunction, and ignores the equality p1 = 10 to make the deviation. Can you 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>