Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • friendlyhelper: Meet up with old and new friends and explore what Runescape Classic could have been had development continued [link]
      January 21, 2020, 05:28:31 PM
    • friendlyhelper: After well over 6 years of continuous runtime, RSCR still most actively developed RSC server  [link]
      January 21, 2020, 05:25:33 PM
    • milomakes: holy crap the spam is real! I just came back after idk how many years to this haahah
      January 20, 2020, 07:32:33 AM
    • bansil: wow the absolute state of this forum
      January 19, 2020, 10:08:34 AM
    • hardcore22:[link]
      January 15, 2020, 02:20:59 PM
    • hardcore22:[link]
      January 15, 2020, 02:20:53 PM
    • hardcore22: come play and enjoy the good old feeling of back in the day! [link]
      January 15, 2020, 02:20:48 PM
    • hardcore22: join scaperune!!!! [link]
      January 15, 2020, 02:20:16 PM
    • hardcore22:[link] join the ultimate oldskool feeling
      January 15, 2020, 02:20:05 PM
    • Zukodens: Brand new rsps in this site Adv's : [link]
      January 15, 2020, 11:20:55 AM
    • Zukodens:[link]
      January 15, 2020, 11:20:38 AM
    • ragnoroker: Brand New RSPS - Unique with Friendly laid back community - Join today - [link]
      January 14, 2020, 05:23:32 PM
    • ragnoroker: Brand New RSPS - Unique with Friendly laid back community - Join today - [link]
      January 14, 2020, 05:23:29 PM
    • ragnoroker: Brand New RSPS - Unique with Friendly laid back community - Join today - [link]
      January 14, 2020, 05:23:25 PM
    • hardcore22: become a member of scaperune! [link]
      January 14, 2020, 11:56:21 AM
    • hardcore22:[link] good old days
      January 14, 2020, 11:55:59 AM
    • hardcore22:[link] join now!
      January 14, 2020, 11:55:47 AM
    • hardcore22: scaperune [link]
      January 14, 2020, 11:54:03 AM
    • hardcore22: join [link] and enjoy the good old days! its awsome!
      January 14, 2020, 11:52:54 AM
    • Zukodens: Infinity-Pk Brand new 317 server just released ! ! Join here : [link]
      January 14, 2020, 11:51:05 AM

    Author Topic: JavaScript Functions  (Read 2597 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineAdobe

    • Member
    • ****
    • Posts: 302
    • Thanks: +0/-0
      • View Profile
    JavaScript Functions
    « on: October 13, 2016, 12:21:38 PM »
    I am currently working on developing a wider skill-set in the JavaScript language, and have tasks in order to help me learn along the way.
    I'm stuck on using global variables correctly, and how to get the correct output from them.

    The instructions are commented into the code, and my attempt at getting the correct output is in-between the comments.



    What my current result is when running the program vs the reference sheet it's intended to match:



    Any guidance or help would be appreciated.

    « Last Edit: October 13, 2016, 12:30:20 PM by Adobe »
    rep means nothing on this forum, so don't let it get to your head.
    Runescape Gambling

    Offlinejustaguy

    • Member
    • ****
    • *
    • Posts: 706
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #1 on: October 13, 2016, 08:11:53 PM »
    First thing I noticed is this line:
    Code: Text
    1. seed = rand(seed % 100);
    What you're trying to do is pass an argument to rand even though it's not supposed to take any. Also, you're reassigning your seed outside of rand which shouldn't happen.

    The question is asking you to call rand and modulo it by 100. Do that and print the result 5 times in total.

    As an aside: I hope whatever tutorial you're learning from teaches you more modern JavaScript because the use of var and not specifying a base for parseInt is bad.
    RIP

    OfflineAdobe

    • Member
    • ****
    • Posts: 302
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #2 on: October 14, 2016, 10:02:01 AM »
    Thank you for your reply justaguy, I have gotten closer to the results I need.

    my results vs what they're supposed to be:



    and my current code:





    Resolved:

    « Last Edit: October 14, 2016, 04:25:01 PM by Adobe »
    rep means nothing on this forum, so don't let it get to your head.

    OfflineWhackatre

    • u wan buy dvd?
    • Member
    • ****
    • *
    • Posts: 1,780
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #3 on: October 15, 2016, 09:48:13 AM »
    why aren't you using syntax highlighting

    p.s. you can totally paste code as text instead of as an image...
    [20:14:10] <dicklord> your to smart :'( You make botserv bots say something you enjoy and want to go to the boards.

    If you're looking for a supreme text editor for everything look no further than Emacs.

    OfflineAdobe

    • Member
    • ****
    • Posts: 302
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #4 on: October 16, 2016, 04:14:07 PM »
    Required to use a SSH client as I am doing college work. Therefore, I'm currently using PuTTy and normally use the Jove editor within it.
    I also haven't looked up the keys to copy and paste using Jove, and that is why I used the image.

    I use sublime-text 3 as my laptop editor when working on projects that aren't being requested by my professor.
    rep means nothing on this forum, so don't let it get to your head.

    Offlinejustaguy

    • Member
    • ****
    • *
    • Posts: 706
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #5 on: October 16, 2016, 04:19:27 PM »
    I don't use ST but being a pretty popular editor I'm sure it has plugins for SFTP, kinda like Atom's remote-sync package.
    RIP

    OfflinePowerr

    • First Time Poster
    • *
    • Posts: 1
    • Thanks: +10/-10
      • View Profile
    Re: JavaScript Functions
    « Reply #6 on: October 16, 2016, 04:54:45 PM »
    I can't log in game now whats wrong?

    Offlinejustaguy

    • Member
    • ****
    • *
    • Posts: 706
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #7 on: October 16, 2016, 04:57:46 PM »
    I can't log in game now whats wrong?

    go away
    RIP

    OfflineThongmas

    • Member
    • **
    • Posts: 8
    • Thanks: +10/-10
      • View Profile
    Re: JavaScript Functions
    « Reply #8 on: October 16, 2016, 05:12:24 PM »
    You could've just pointed him towards Appeals/General Board.  :palm:

    So helpful.

    Offlinejustaguy

    • Member
    • ****
    • *
    • Posts: 706
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #9 on: October 16, 2016, 05:28:51 PM »
    You could've just pointed him towards Appeals/General Board.  :palm:

    So helpful.

    go away
    RIP

    OfflineThongmas

    • Member
    • **
    • Posts: 8
    • Thanks: +10/-10
      • View Profile
    Re: JavaScript Functions
    « Reply #10 on: October 16, 2016, 05:33:38 PM »
    Hahaha. Mr. Witty.

    OfflineWhackatre

    • u wan buy dvd?
    • Member
    • ****
    • *
    • Posts: 1,780
    • Thanks: +0/-0
      • View Profile
    Re: JavaScript Functions
    « Reply #11 on: October 17, 2016, 01:55:30 AM »
    Required to use a SSH client as I am doing college work. Therefore, I'm currently using PuTTy and normally use the Jove editor within it.
    I also haven't looked up the keys to copy and paste using Jove, and that is why I used the image.

    I use sublime-text 3 as my laptop editor when working on projects that aren't being requested by my professor.

    surely you aren't specifically required to code remotely though? btw, i've not heard of jove but if it doesn't even have syntax highlighting it's pretty lacking. try emacs (or vim); they are the best editors if you're absolutely forced to code in a terminal environment.

    you can also use emacs' remote editing to code locally and have it automatically sync with the remote file. :)
    [20:14:10] <dicklord> your to smart :'( You make botserv bots say something you enjoy and want to go to the boards.

    If you're looking for a supreme text editor for everything look no further than Emacs.

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal