This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Animate Your Name Forum

View Course » View Exercise

455 points
554cf7c951b88777180008a6_744481352
Submitted by
Adrian Pardo
about 2 years ago

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");
    }

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.

3691 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
about 2 years ago


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.

3691 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
about 2 years ago

1 Comment

55df2afa95e3787b9200005e_359368177 Judy about 2 years ago

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


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);
}

455 points
554cf7c951b88777180008a6_744481352
Submitted by
Adrian Pardo
about 2 years ago


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);
}

455 points
554cf7c951b88777180008a6_744481352
Submitted by
Adrian Pardo
about 2 years ago

1 Comment

55df2afa95e3787b9200005e_359368177 Judy about 2 years ago

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