This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Adrian Pardo
almost 9 years

Need some help with this bit i added

trying to troll my girlfriend. I’ve got 2 problems. prompt asks twice, and my “else” doesn’t console.log”Sorry wrong answer”. please help, I’m sure its an easy fix.

var userChoice = prompt("Does Adrian love Mileini more?");

    if (userChoice === "yes") {
        var red = [0, 100, 63];
        var orange = [40, 100, 60];
        var green = [75, 100, 40];
        var blue = [196, 77, 55];
        var purple = [280, 50, 60];
    
        var myName = "Mileini";
        var letterColors = [red, orange, green, blue, purple]
        if(10 > 3) {
            bubbleShape = "circle";
        } else {
            bubbleShape = "square";
        }
    
        drawName(myName, letterColors);
        bounceBubbles();
    
    } else {
        console.log("sorry wrong answer");
    }

Answer 554cebfe9376766b1f0005e9

1 vote

Permalink

Hi Adrian,

You aren’t seeing any output from the console.log() because there is no console in this exercise. The white box off to the right is a web page, not a console.

You could change your console.log() to:

document.write("sorry wrong answer");

but you still won’t see it in the little Preview window because the canvas is taking up space - you will see it in the Full Screen view, but that is not very satisfactory.

You could rethink your if/else and have it only decide what var myName should be. That way myName will either be “Mileini” or “Wrong Answer”.

Once you get that working, you could also change the colours for the wrong answer, sad colours – what ever they maybe for you.

points
Submitted by Judy
almost 9 years

Answer 554cf21351b887420d00063c

1 vote

Permalink

You can’t just magically change the name of the colour array, this; [0, 100, 63], and have it be a different colour. You will need to look up the values for the colours that you are interested in. This will help you with that: http://www.codecademy.com/forum_questions/53385d4e8c1ccca3de00a9a6

You don’t need this if/else to decide bubbleShape, do you? Just assign which ever shape you want. If you want them both to be the same, put the assignment outside of the big if/else.

if(10 > 3) {
    bubbleShape = "circle";
} else {
    bubbleShape = "square";
}

Put everything else outside of the big if/else that doesn’t depend on the outcome of that decision.

points
Submitted by Judy
almost 9 years

1 comments

Judy almost 9 years

I would put all my color arrays at the top, outside of the if/else.

Answer 554cf05de39efe6d24000701

0 votes

Permalink

awesome! good idea. Prompt still asks twice though, and else isn’t showng the correct colors. any idea?

var userChoice = prompt("Does Adrian love Mileini more?");

if (userChoice === "yes") {
var red = [0, 100, 63];
var orange = [40, 100, 60];
var green = [75, 100, 40];
var blue = [196, 77, 55];
var purple = [280, 50, 60];

var myName = "Mileini <3";
var letterColors = [red, orange, green, blue, purple]
if(10 > 3) {
    bubbleShape = "circle";
} else {
    bubbleShape = "square";
}

drawName(myName, letterColors);
bounceBubbles();

} else {
var black = [0, 100, 63];
var yellow = [40, 100, 60];
var green = [75, 100, 40];
var blue = [196, 77, 55];
var gray = [280, 50, 60];

var myName = "Wrong Answer!";
var letterColors = [black, yellow, green, blue, gray]
if(10 < 3) {
    bubbleShape = "circle";
} else {
    bubbleShape = "square";
}

drawName(myName, letterColors);
}
points
Submitted by Adrian Pardo
almost 9 years

Answer 554cf5acd3292ff7f700077d

0 votes

Permalink

Thanks for all your help Albions.

So i cleaned it up a lot more, but still a double prompt.

var userChoice = prompt("Does Adrian love Mileini more?");

var red = [0, 100, 63];
var orange = [40, 100, 60];
var green = [75, 100, 40];
var blue = [196, 77, 55];
var purple = [280, 50, 60];
var black = [0, 0, 0];
var yellow = [62, 60, 50];
var gray = [0, 5, 50];

if (userChoice === "yes") {
    var myName = "Mileini <3";
    var letterColors = [red, orange, green, blue, purple]
    bubbleShape = "circle";
    drawName(myName, letterColors);
    bounceBubbles();

} else {
    var myName = "Wrong Answer!";
    var letterColors = [black, yellow, green, blue, gray]
    bubbleShape = "square";
    drawName(myName, letterColors);
}
points
Submitted by Adrian Pardo
almost 9 years

1 comments

Judy almost 9 years

That works nicely now Adrian! Good job. I don’t know what is going on with the double prompting. You might want to have a look at making heart shapes. http://www.codecademy.com/forum_questions/533d5690548c3545a4002563