[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Can someone give me a hand with this javascript?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 13
Thread images: 1
File: spacecat.jpg (3 KB, 106x106) Image search: [Google]
spacecat.jpg
3 KB, 106x106
This is my first real javascript assignment and I'm having kind of a hard time with it. I talked to my instructor about it, and he said I could go to a forum and ask for help since it isn't due for a while. This being said, I don't want you guys to necessarily spoon feed me information, nor do I want to plagiarize anything - I want to learn this shit because I'm going to be required to do it at a job someday. However I'm kind of at an impasse with this program.

The goal of the program is to illustrate how stupid it is to play Lucky Sevens. The program does the following:

1. The user inputs how much cash they want to spend.

2. When they roll the dice, the computer automatically rolls the dice at random.

3. When they land on 7, the user wins $4.

5. When they land on anything else, they lose $1.

There's more to it, but that's the only part I'm having trouble with right now. Could somebody look at this for me?

This is the code :
http:// pastebin.com/aUL4L8jc

I know this isn't my personal tech support forum, but you guys are the only ones that I think are going to give good answers to it. I felt like it was too sophisticated for wsr.

I appreciate any help
>>
Defining a function requires the keyword function followed by the function name e.g.
function checkDie

Calling a function only requires the function name plus any variables if required. So on line 45 should be
} else { 
CheckDie();
}


You also have problems with the cash ++/-- area. Your creating a local variable which has nothing to do with your storage of cash.
>>
>>55587542

Thanks for this! I'm going to try to go through my code and see if I can fix any errors with this new information.
>>
>>55587542

Okay, so now I'm definitely on the right track. No need to use the function keyword unless I'm declaring a function.


When I try to run this through Chrome's debugger, it keeps coming up with strange errors. For example, it keeps identifying </center> as an "unexpected token" but it's outside of the <script> elements.
>>
>>55587409
Here dude, i'm left over drunk and high from the night before, but I did yer assignment for you.

You really need to take a step back and learn the basics, you weren't even declaring element ids correctly. But that's okay cuz yer learning!

not the best but it werks:
http://paste.ofcode.org/3QQzaZ7Kefw4tbzt5mSSsi
>>
>>55587674

I appreciate that, but I didn't really want someone to just come in and do the assignment for me. I kind of want to figure out how things work and what I was doing wrong so that I can show up and perform well on a job.

Still, I'm grateful for your example and i'll use it to guide my work (I won't plagiarize it though).

Thank you.
>>
>>55587692
It's okay man *wink* *wink* i know you didn't want anyone to do it for you ;^) ;^)
>>
>>55587706


I'm actually really serious. I'm enrolled in a pretty prestigious bootcamp and the goal is to get a job as a developer. I don't want to show up to my first job making noob mistakes with javascript.

I do appreciate your example though. I'll use it as a model to create my own assignment.
>>
>>55587692
You're hopeless with your current vocational staff. I hope you're not paying them. Pick up a book like Eloquent Javascript
>>
>>55587764

They have a pretty high job placement rate, which is the main reason I'm paying for the program. Anyone (smart) can teach themselves how to program, but having the recommendations and network to jump into that first job is the problem. Hence the reason for the bootcamp and their extensive employer network.


>>55587775

> The center tag isn't supported in html5 you'll have to use css to align

Thank you! I was wondering why it was doing that.
>>
I don't know what you're creating this in but get a syntax linter with whatever editor you're using.

Or get an editor that does, like Sublime, PHPstorm or something similiar. It will make your life infinitely easier.

Also inlining JS isn't a great practice, place it in a seperate file and load it in using a <link> in the <header>
>>
I wound up finishing the assignment. Delete this.

thanks for everyone's help.
>>
STOP RUINING THE INTERNET WITH YOUR SHITTY JAVASCRIPT
Thread replies: 13
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.