what i dont understand is the () part, and why it wasn't necessary to use. i read just a second ago that variables being passed from one function to another are placed inside the () part of the function.
i didnt include these variables inside the (), so why is my code working?
if it has something to do with them being global, then how do i go about providing information to a function from another function?
function cardvalue(){
cardval=Math.floor(Math.random()*13+1);
if(cardval>=11 || cardval==1){
if(cardval==1){cardval="ace"}
if(cardval==14){cardval="ace"}
if(cardval==13){cardval="king"}
if(cardval==12){cardval="queen"}
if(cardval==11){cardval="jack"}
}
else{cardval=cardval};
return cardval;
}
function cardtype() {
cardt=Math.floor(Math.random()*4+1);
if(cardt==1){cardt="hearts"}
if(cardt==2){cardt="diamonds"}
if(cardt==3){cardt="spades"}
if(cardt==4){cardt="clubs"};
return cardt;
}
function cardtotal() {
cardvalue();
cardtype();
alert("your card is a "+cardval+" of "+cardt);
}


Sign In
Create Account


Back to top









