Author Topic: Really nooby Java help...  (Read 2686 times)

Offline Dreaming Sun

  • Trained Member
  • *
  • Posts: 16
  • LV: 1
    • View Profile
Really nooby Java help...
« on: September 11, 2013, 07:32:46 AM »
So I have been actually trying to learn to code at this CodeAcademy website a friend redirected me to and I just did something stupid and so something's wrong and I don't know what I did wrong...

var creditCheck = function(income) {
    if (income>=100) {
        console.log("You earn a lot of money! You qualify for a credit card.");
    } else {
        console.log("Alas you do not qualify for a credit card. Capitalism is cruel like that.");
    }
};

creditCheck(75)
creditCheck(125)
creditCheck(100)

Basically the goal is to create a code where if the income is greater than 100, it prints one thing, and if it doesn't, it prints the other. And then to shove in some example parameters. But for some reason it's also printing the result for what I suppose would be "income" itself and I don't know how to stop that.

So yeah, sorry if it seems really stupid... but I'd really appreciate help.

Offline Wizered67

  • Astral Trancist
  • *****
  • Posts: 512
  • LV: 16
    • View Profile
Re: Really nooby Java help...
« Reply #1 on: September 11, 2013, 07:45:39 AM »
I don't know offhand, but shouldn't the first line be something like
Code: [Select]
function creditCheck(income){ if its defining a function?

edit: also no semicolon on the last line with the }, but add semicolons on all of the subsequent function calls.
« Last Edit: September 11, 2013, 07:46:51 AM by Wizered67 »

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19982
  • LV: 648
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Really nooby Java help...
« Reply #2 on: September 11, 2013, 07:50:32 AM »
This looks like Javascript, not Java.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.

Offline Dreaming Sun

  • Trained Member
  • *
  • Posts: 16
  • LV: 1
    • View Profile
Re: Really nooby Java help...
« Reply #3 on: September 11, 2013, 08:08:23 AM »
This looks like Javascript, not Java.

I was just screamed at by several people before I managed to reply to this post so that is now hammered in my head I am sorry ;~;

... also for some reason I just did it again and it's suddenly working... weird

Offline Blizzard

  • This sexy
  • Administrator
  • has over 9000 posts
  • *****
  • Posts: 19982
  • LV: 648
  • Gender: Male
  • Magic midgets.
    • View Profile
    • You're already on it. (-_-')
Re: Really nooby Java help...
« Reply #4 on: September 11, 2013, 08:27:34 AM »
Yeah, Javascript is weird like that.

This looks like Javascript, not Java.

I was just screamed at by several people before I managed to reply to this post so that is now hammered in my head I am sorry ;~;

Don't worry, I made the same mistake back then and I have been a programmer for over 8 years.
Check out Daygames and our games:

King of Booze      King of Booze: Never Ever      Pet Bots
Drinking Game for Android      Never have I ever for Android      Pet Bots for Android
Drinking Game for iOS      Never have I ever for iOS      Pet Bots for iOS
Drinking Game on Steam


Quote from: winkio
I do not speak to bricks, either as individuals or in wall form.

Quote from: Barney Stinson
When I get sad, I stop being sad and be awesome instead. True story.