awsum yo
awsum yo

Reputation: 1

Having issues with my function not working on javascript. Says my function is not a function

I am making a text based rpg and I decided to use functions instead of repeating everything for the sake of convenience. I have have made 3 so far, one for the intro, one for the ending, and one for picking what shoes you will wear (which contains the ending). The opening and ending work, and by itself the shoes work as well, but as soon as I put it with the rest of my game, the shoes function does not work. It says "TypeError: shoes is not a function". I made sure it is formatted the same as my other functions, but it still does not work. Here I include a link to what I have so far on google docs. The shoes function is the third function listed. Also this only works using code academy because I am using their console. Do run it go to the second link and hit save and submit. When asked a question only type the first option listed in // as I have not yet finished the others. https://docs.google.com/document/d/1pGQNFNCxsNGxKP43mUloZH3w2xeDLD8nq-knluHsQ_8/edit?pli=1

http://www.codecademy.com/courses/javascript-beginner-en-6LzGd/0/5?curriculum_id=506324b3a7dffd00020bf661

var opening = function (opening) {

    console.log ("You are looking up at your ceiling.");
    console.log ("You feel the sun shining on you through your bedroom window.");
    console.log ("You look over at your clock.  It is 10:37am.");
    console.log ("You contemplate getting out of bed.");
    var wakeUp = prompt ("Get out of bed? /yes/ or /no/?");

if (wakeUp == "yes") {
//1 
    alert ("You decide to get out of bed.");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("You get up and look at yourself in the mirror.");
    var userSex = prompt ("Are you male or female?");
    var userHairColor = prompt ("What color is your hair?");
    var userHairLength = prompt ("How long is your hair?");
    var userEyeColor = prompt ("What color are your eyes?");
    var userSkinTone = prompt ("What is your skin tone?");
    var userGlasses = prompt ("Do you wear glasses?");
    console.log ("Before you head out you want to check your computer and freshen up."); } }

    ////////////////////////////////////////////

    var ending = function (ending) {
    var endingAction = prompt ("Are you ready to go outside? /yes/ or /no/?");

if (endingAction == "yes") {
//15    
    alert ("You open the door and walk outside and go about your day.");

} else if (endingAction == "no") {

    alert ("You remember you are a lazy couch potato and go back inside and watch T.V.."); } }

   ////////////////////////////////////////////////

   var shoes = function (shoes) {
    var shoeChoice = prompt ("What shoes will you wear?  /sneakers/ or /sandals/?")

if (shoeChoice == "sneakers") {
//14    
    console.log ("You grab some socks and your pair of Nike sneakers and put them on.");
    console.log ("You get up, make sure you are all ready, and put your hand on the door handle.");

    ending("ending")

} else if (shoeChoice == "sandals") {
    console.log ("You slip on your pair of blue sandals and walk up to the door.");  

    ending("ending") } }

    //////////////////////////////////////////////////
   /  /////////////////////////////////////////////////

    alert ("Begin?");
    opening("opening")
    var beforeHeadingOutAction = prompt ("Do you want to /check your computer/ or /freshen up/ first?")

if (beforeHeadingOutAction == "check your computer") {
//2
    alert ("You decide to check your computer.");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("You head over to your desk.");
    var userComputer = prompt ("Do you have a /desktop/ or a /laptop/?");

if (userComputer == "desktop") {
//3 
    alert ("You sit down at your desk and boot up your computer.");
    console.log ("The computer logo pops up and after a few seconds and the login screen appears.");
    console.log ("You enter your password and login.");
    console.log ("You notice that you have two facebook notifications");
    var checkFacebook = prompt ("Do you want to check Facebook? /yes/ or /no/?");

if (checkFacebook == "yes"); {
//4  
    alert ("You click on the tab with Facebook open.");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("……………………………………………………………………………………………………");
    console.log ("You see that you have one message and that you were tagged in one photo.");
    var firstFacebookAction = prompt ("Do you want to /check your message/ or /check the photo/ first?");

if (firstFacebookAction == "check your message") {
//5    
    alert ("You open up your messages.");
    console.log ("You see the message is from your friend who you met with the other day.");
    console.log ("He asked you if you wanted to get lunch with him on monday.");
    console.log ("'Hey I had fun hanging out the other day and I wanted to know what your favorite food was?'");
    var favFood = prompt ("What is your favorite food? (Plural)");
    console.log ("'My favorite food are " + favFood +".'");
    var favFoodPlace = prompt ("Where do you like to get " + favFood + "?");
    var lunchPlans = prompt ("Do you want to go get " + favFood + " at" + " " + favFoodPlace + " sometime next week?  /yes/ or /no/?");

if (lunchPlans == "yes") {
//6   
    console.log ("'Cool, I'll call you later when I find a time that works.'");
    alert ("You respond yes with a smiley emoji.");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("You say bye and you close out of the chat.");
    var afterMessageAction = prompt ("Do you want to /check your other notification/, or /log off/ your computer?");

if (afterMessageAction == "check your other notification"); {
//7
    alert ("You check your other notifications.");
    console.log ("You click on 'notifications' and see that you were tagged in a photo with your friends at the local pizza place you all hangout at.");
    console.log ("You chuckle to yourself remembering when your friend tried to eat a whole pizza in under five minutes.");
    alert ("You like the photo and close out of Facebook.");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("You glance down at the time and you see it is now 10:59.");
    alert ("You decide to log off your computer and head to the bathroom to get ready for the day.");
    console.log ("You get into the bathroom and you immediately feel the difference in temperature from your warm sunbathed room to the cold bathroom");
    console.log ("You quickly shuffle over to the corner where the bath and shower are located.");
    var bathOrShower = prompt ("Do you want to take a /shower/ or a /bath/?");

if (bathOrShower == "shower") {
//8
    alert ("You opt for a shower instead of a bath.");
    console.log ("You hop into the shower and turn on the water.");
    console.log ("You immediately feel refreshed and glad that you started taking two showers a day.");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    console.log ("…………………………………………………………………………………………………");
    alert ("After about fifteen minutes you get out of the shower");
    console.log ("You step out and wrap up in a towel after drying yourself off.");
    console.log ("You relax for a minute or two before getting dressed.");
    console.log ("Today is August 23 and the weather is temprate with a cool breeze you see after you check your weather app.");
    console.log ("You decide to wear a T-shirt because you just bought a bunch of new ones online.");
    var TshirtStyle = prompt ("Do you want to wear a /graphic/ or a /plain/ shirt?");

if (TshirtStyle == "graphic") {
//9    
    var graphicTshirtDesign = prompt ("What is on your shirt?");
    console.log ("You put on your shirt with the " + graphicTshirtDesign + " design.");
    console.log ("It is not yet cold outside, but it is not too warm that you cannot wear something over your shirt.");
    var overShirt = prompt ("Do you want to wear a something over your shirt? /yes/ or /no/?");

if (overShirt == "yes") {
//10    
    var overShirtChoice = prompt ("Do you want to wear your grey /sweater/, your blue /hoodie/, or your black /jacket/?  Or did you /change your mind/?");

if (overShirtChoice == "sweater") {
//11
    console.log ("You take your sweater off the hanger and put it on.");
    console.log ("You open the part of your wardrobe with shorts and pants.");
    var bottomWear = prompt ("Do you want to wear /pants/ or /shorts/?");

if (bottomWear == "pants") {
    //12   
    var pantsType = prompt ("What type of pants do you want to wear?  /sweatpants/ or /jeans/?");

if (pantsType == "sweatpants") {
//13
    console.log ("You grab your pair of white sweatpants and put then on as you decide you should buy another pair or two.");
    console.log ("You don't feel like wearing anything else so you head over to your front door.");
    console.log ("You open the shoe closet and ponder your footwear options.");
    shoes("shoes")
     } } } } } } } } } } } }

Upvotes: 0

Views: 82

Answers (1)

Maurício Araldi
Maurício Araldi

Reputation: 389

I am not getting errors with your code.

Also, you should format you code better to get a clear view and find probable errors.

I would advise trying to run the code outside code academy (JSFiddle maybe?) to avoid interference. Try it and update us with what happened (and a link to your fiddle).


Anyway, two things you can fix in your code:

This line:

//////////////////////////////////////////////////
/  /////////////////////////////////////////////////

if you really want to have this, adjust it to be:

//////////////////////////////////////////////////
//////////////////////////////////////////////////

And some ; that are missing (probably not the reason for the error, but it would be good to adjust the code)

Upvotes: 1

Related Questions