Trying something new but I think my technique may be off


#1

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#

I think I may have gone a bit far with this, but VERY curious to know if I was close. Great learning experience for me. Thanks for any and all insight!

Line 24, 29, and 34 have issues but I’m not sure if I’m just going in the wrong direction.



var user = prompt ("Do you compost your kitchen scraps?").toLowerCase();

switch (user) {
    case 'yes':
        console.log("You're a legend!");
        break;
    
    case 'no':
        
            var willToLearn = prompt("Would you like to              learn how?").toLowerCase();
            
            if (willToLearn === "yes") {
               
                console.log("1'st step is to build a container approximately 4 foot cubed, with an open yet but protected top");
            }
          
                var green = prompt ("Can you get 'green' materials such as vegetable waste, grass clippings, or fresh cut non-invasive weeds?");
           
                var brown = prompt ("Can you get 'brown', or carbon rich materials such as mulched leaves, soaked woodchips, hay, or dried non-invasive weeds?");
            
                if (green && brown) {
                    console.log ("Then mix them in somewhat equal parts, get them thorougly wet but not soaking, and put them into your frame with cardboard on all sides to insulate. Congratulations, you're making medicine from waste!");    
                }
                else (green || brown) {
                    console.log("Then get some of the materials your missing, brown or green, and mix them in somewhat equal parts, get them thorougly wet but not soaking, then put them into your frame with cardboard on all sides to insulate. Congratulations, you're making medicine from waste!");    
                }
            }
            
            else {
            console.log("Well that's just sad");
                }
        
    
    }
    break;    
    
    case 'sometimes' :
        console.log("Pick up the pace");
        break;
    
    default:
        console.log("Please answer Yes, No, or Sometimes.");
}   


#2

else (green || brown) {

else doesn’t allow to have a condtion.if you need more condition then use else if.

and opening and closing brackets should be equal.right now you’ve 4 opening brackets but 6 closing brackets.


#3

Thank you for taking the time, I’ll tinker around and see how it goes.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.