I am trying to write a Java Script program that should have two variables. You should add and display the sum only if they are numbers. If they are of any other type you should show a message "Sorry.... Only Nos will be added" Please have look in the below snippet. Thanks in advance
<script>
var x = Number(prompt("Enter First Choice"));
var y = Number(prompt("Enter Second Choice"));
var x1 = typeof x;
var y1 = typeof y;
if(x1==='number' && y1==='number'){
document.write(x+y);
}
else{
document.write("Sorry.... Only Nos will be added");
}
</script>