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.
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.
This looks like Javascript, not Java.
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
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.