Ask coding questions

← Back to all posts
JavaScript Function Question
Comb

Hello, I have a bit of a problem. I have been making a casino test game for fun and I came across a roadblock. I put a randomized slot machine in and put it in a function, but when I try to print the function, it just comes up as [Function: yes]. I am very new to coding in JavaScript and I was wondering if there was anyway to actually print the function instead of that message? Here's the code I am using.

function slot (slots) {if (slots > 50) {
console.log('You won, now you have ' + money * 2 + ' Moneys!')
} else {
console.log('You lost, and now you have ' + money / 2 + ' Moneys!')
}
}

Answered by Zavexeon [earned 5 cycles]
View Answer
Voters
Comb
Comments
hotnewtop
Zavexeon

I'm not seeing an issue. Though please note that functionName() calls the function (executes it on runtime), while functionName is a reference to the function. A reference is sort of like "hey, store this function but don't execute it when the code is ran".

Comb

@Zavexeon Thank you so much! This should really clear everything up!

EgorKrutilin

Good afternoon. Maybe you should pay attention to the casino https://jackpottown.nz/ and see how everything works out for them. They have been around for quite a long time and people believe them, so they have a good game system and everything is qualitatively worked out.