The Creator needs construction help


#1

Hey guys! I’m currently moving away from working on my Clash Royale game, and working on the antagonist, The Creator, because most of the feedback I’ve been receiving says to give The Creator a way to win, but I’m kinda stuck!

alert("this is just for testing code for the Creator");
let creator = confirm("Are you sure you want to proceed?");
if(creator === true) {
    alert("Haha... I choose " + cardType + "!");
} else {
    
}
function cardtype(){
    return("Prince");
    }

I know that the } else { } is empty. please ignore that as well, but how do I get the if(creator === true) {alert("Haha... I choose " + cardType + "!"); how do I put cardType in the alert to change to Prince?


#2

return("abc"); -> return "abc"; ?


#3

I forgot to remove the brackets… didn’t I


#4

Looks like it :wink:


#5

I didn’t do that on purpose… I legit just replaced the console.log with return.


#6

though the code still doesn’t work… I did remove the brackets

alert("this is just for testing code for the Creator");
let creator = confirm("Are you sure you want to proceed?");
if(creator === true) {
    alert("Haha... I choose " + cardType + "!");
} else {
    alert("Aww...");
}
function cardtype(){
    return "Prince";
    }

also how do the Parameters work? would they affect if the code runs properly?


#7

Change

creator === true

to

creator

Because checking if something is true inside the parentheses of an if statement is the same as simply using the variable name;

if (yourBool === true)

=

if (yourBool)


#8

okay I’ll do that!!!


#9

so I did that, but what I want is to have if(creator) { alert("Haha... I choose " + cardType + "!"); and function cardtype(){ return "Prince"; } so how do I get Prince into the alert?


#10

Yeah so to call a function you need to include the (), so replace cardType with cardtype()