Reputation: 15
function bj(numa,numb){
if(numa>numb){
alert(numa);
}
else if(numa==numb){
alert(numa,numb);
}
else{
alert(numb);
}
}
I mean, in the above function when the two numbers are equal, the pop-up window appears two values. Can I do that?
Upvotes: 1
Views: 44
Reputation: 16673
You can concatenate them:
alert('number1: ' + numa + ' number2: ' + numb);
Upvotes: 1
Reputation: 207517
You need to concatenate them
alert(numa + "," + numb);
alert(numa + "\n" + numb);
Upvotes: 1
Reputation: 1211
Depending on what you want to display you can do something like the below
function bj(numa,numb){
if(numa>numb){
alert(numa);
}
else if(numa==numb){
alert(numa + " = " + numb);
}
else{
alert(numb);
}
}
This would display the below if numa and numb were 12
12 = 12
Upvotes: 1