Really nooby Java help...

Started by Dreaming Sun, September 11, 2013, 01:32:46 am

Previous topic - Next topic

Dreaming Sun

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.

Wizered67

September 11, 2013, 01:45:39 am #1 Last Edit: September 11, 2013, 01:46:51 am by Wizered67
I don't know offhand, but shouldn't the first line be something like
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.

Blizzard

This looks like Javascript, not Java.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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

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

Dreaming Sun

Quote from: Blizzard on September 11, 2013, 01:50:32 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

Blizzard

Yeah, Javascript is weird like that.

Quote from: Dreaming Sun on September 11, 2013, 02:08:23 am
Quote from: Blizzard on September 11, 2013, 01:50:32 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 ;~;


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 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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

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