Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com I need assistance on how exactly to get started with this problem

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 02-24-2013, 09:29 PM PM User | #1 traptack New to the CF scene   Join Date: Feb 2013 Posts: 5 Thanks: 2 Thanked 0 Times in 0 Posts I need assistance on how exactly to get started with this problem ** sorry for the weird title I'm taking a coding class and we have a variety of different assignments. Recently we've been told to use code academy, and the ones I've recently done were learning Loops and functions. For this one particular assignment I'm tasked with finishing a incomplete web page function as seen below. Dot Racer

Online Dot Racer

Two dots race to the finish! Enter the race length. Each time the user clicks the button, each dot advances a random amount (1, 2, or 3 steps). When a dot crosses the finish line, display the winner.

Race Length:

Red Dot: 0

Blue Dot: 0

now I'm not asking someone to completely solve this for me, I just want direction on what/how to get started. I know i'm supposed to address the part that I highlighted in orange. I'm supposed to make it so that whatever value the user puts in the "total distance" every time they press (take a step) red and blue take different steps untill they reach the finish, where a pop up/alert will announce the winner. in short: Two dots race to the finish! Enter the race length. Each time the user clicks the button, each dot advances a random amount (1, 2, or 3 steps). When a dot crosses the finish line, display the winner. so yeah i'm lost on what I should do. I have difficulties combining concepts together, you could say. I know I should be using the Looping function with some mathRdm thrown in there? I just ask for direction, if someone could simply or "dumb it down" For me by feeding me step by step instructions. I'm not asking for specific copy and paste instructions, more like "you should adress this issue, before doing this, and etc" or if you think there's some good resources for me or if I should do a particular exercise on code academy which would help... any input at all is most appreciated, thanks
 02-24-2013, 09:43 PM PM User | #2 felgall Master Coder     Join Date: Sep 2005 Location: Sydney, Australia Posts: 6,093 Thanks: 0 Thanked 579 Times in 569 Posts 1. Your HTML is invalid - for example the should be inside a form - or you should use a
 Users who have thanked felgall for this post: traptack (02-24-2013)
02-24-2013, 09:51 PM   PM User | #3
traptack
New to the CF scene

Join Date: Feb 2013
Posts: 5
Thanks: 2
Thanked 0 Times in 0 Posts
Quote:
 Originally Posted by felgall 1. Your HTML is invalid - for example the should be inside a form - or you should use a
probably poorly written because it's easier for beginners? unless that just makes it harder :P

do you know of a website where I can test try my codes if you know what i'm talking about.

and for the coding part, back to my main question
I was thinking if this could work?

for( var i = 0 ; i >= (user input) ; i +=(math random?) ) {
console.log(i);
}

sorry if my response isn't exactly clear, i'm just trying to process things right now

02-25-2013, 08:34 AM   PM User | #4
Philip M
Supreme Master coder!

Join Date: Jun 2002
Location: London, England
Posts: 17,477
Thanks: 200
Thanked 2,470 Times in 2,448 Posts
traptrack - please post your code using code tags as described in the posting guidelines - not using assorted colours.

Likewise - do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose. You can (and should) edit it to make it more meaningful.

Quote:
 I was thinking if this could work? for( var i = 0 ; i >= (user input) ; i +=(math random?) ) { console.log(i); }
No, it will not work like that. You must specify the loop counter in the proper way.

Code:
```var u = Number(document.getElementById("userinput")) || 0;  // trap NaN entries
// check that u is a sensible value, say at least 10
var num = 10;
var randy = Math.floor(Math.random() * num +1);  // generates 1- 10
for (var i =0; i<=u; i+=randy) {
}```
Quote:
 do you know of a website where I can test try my codes if you know what i'm talking about.
You test your codes in your own browser. If you get Notepad++ you are offered the choice of 4 browsers to test in (assuming you have those browsers on your computer, of course).

He's in a goldfish bowl, swimming against the tide. - Commentator Radio 5 Live
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

02-25-2013, 09:28 PM   PM User | #5
Old Pedant
Supreme Master coder!

Join Date: Feb 2009
Posts: 24,949
Thanks: 75
Thanked 4,307 Times in 4,274 Posts
Quote:
 Originally Posted by Philip M He's in a goldfish bowl, swimming against the tide. - Commentator Radio 5 Live
LOL! If that was meant as sarcasm by the commentator, then it was brilliant!

Man, I *WILL* remember that one!
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 08:26 PM.