These are chat archives for FreeCodeCamp/Help

10th
Jan 2015
Evan Davis
@davisec52
Jan 10 2015 16:56
@Maximization Yes, though I'm not sure how much I could contribute at this point. I'm afraid I would mostly be on the receiving end. I assume from the page on arrays that arrays have something to do with the best solution to problem I was trying to solve. Anyway, I will pick this up again. I have many family obligations today so not sure if I will be able to work on JS, today. Maybe this evening. Really appreciate your help, by the way. I feel that a granular understanding of JS is important and the key to "getting it."
Ryan Malm
@Rybar
Jan 10 2015 18:24
anyone here set up mongodb at cloud9? I'm having trouble
James McShane
@jmcshane
Jan 10 2015 18:34
ryan, i was just starting to work on cloud9.
ill work through the steps and see what i can find
@Rybar when you run the echo > mongo command does it just open a command '>' prompt?
Ryan Malm
@Rybar
Jan 10 2015 18:38
that line is creating a bash script that initializes the database. if you look at your workspace after you run it, you can see the mongod file it creates.
The problem I'm having is it's still trying to allocate too much space to the journals, despite setting --nojournal and --smallfiles
got it going
James McShane
@jmcshane
Jan 10 2015 18:40
ok, im just getting started, so i would need to do some serious work
what did you do to get it working?
Ryan Malm
@Rybar
Jan 10 2015 18:40
I think was incorrectly calling the actual shell program instead of the little bash script I just created
./mongod
James McShane
@jmcshane
Jan 10 2015 18:41
ah, so the mongod command wasn't getting the options
Ryan Malm
@Rybar
Jan 10 2015 18:41
right.
Dominic Jones
@towwiow
Jan 10 2015 18:43
@rybar - FCC teaches bash in the challenges?
Or is that something you know from previous experience?
Ryan Malm
@Rybar
Jan 10 2015 18:44
no just previous experience. It's something you'll run into eventually, especially once you start setting up back-end things from the command-line
Mark Howard
@iheartkode
Jan 10 2015 18:45
Hi Rybar
Nathan
@terakilobyte
Jan 10 2015 18:46
long live the terminal
Mark Howard
@iheartkode
Jan 10 2015 18:46
^
I'm in terminal as we speak lol
Dominic Jones
@towwiow
Jan 10 2015 18:47
Yeah. I'm amped. Whoever sent the link to edX Linux foundation course helped a lot haha. It has bash sections in there which I'm banking on learning a lot from.
Bash is what I was told I need to know to get promoted to a position in my current company. May have said this to you already.
Mark Howard
@iheartkode
Jan 10 2015 18:47
Now that you know bash. Install zsh & oh my zsh and your life will be changed for ever!!
Ryan Malm
@Rybar
Jan 10 2015 18:49
nope, but that's awesome you found a good learning resource. I only know enough to make a mess and install things from the command line.
Mark Howard
@iheartkode
Jan 10 2015 18:49
Btw help was made for help not general discussion :P
Nathan
@terakilobyte
Jan 10 2015 18:49
I’m in the same boat as rybar
but also taking that linux class
being really good in bash can make you much, much more productive
Mark Howard
@iheartkode
Jan 10 2015 18:50
whereis bash
Nathan
@terakilobyte
Jan 10 2015 18:50
which bash
though I prefer which zsh
;)
Mark Howard
@iheartkode
Jan 10 2015 18:50
I love zsh
Dominic Jones
@towwiow
Jan 10 2015 18:52
Haven't gotten to the bash section yet so I still no little lol. Just know it's used to automate processes.
I did have a question @iheartkode lol.
Mark Howard
@iheartkode
Jan 10 2015 18:53
lol
Dominic Jones
@towwiow
Jan 10 2015 18:54
oooo.k
oh snap.. i have 5 followers. help @iheartkode - why would someone wanna follow me? i'm a n00b level -100
Mark Howard
@iheartkode
Jan 10 2015 18:55
What is your twitter?
Dominic Jones
@towwiow
Jan 10 2015 18:55
same username here
@towwiow
Mark Howard
@iheartkode
Jan 10 2015 18:56
Maybe they like your content
Dominic Jones
@towwiow
Jan 10 2015 18:56
well, i work hard on that, so that's a good hunch.
Mark Howard
@iheartkode
Jan 10 2015 18:56
I just followed lol
Dominic Jones
@towwiow
Jan 10 2015 18:56
lol thanks
@iheartkode just got the verification text
Mark Howard
@iheartkode
Jan 10 2015 18:57
lol
Dominic Jones
@towwiow
Jan 10 2015 19:06
Okay... I'm playing around with this little guessing game I made from Rob Percival's course and I added a section to the Javascript to alert "I gave up after 15 wrong guesses" but after that alert is done, the regular alert saying, how many tries it took for the computer to get the right number, still comes up.. how do I stop the second alert from running if the first one ran?
    <script type="text/javascript">

    document.getElementById("guess").onclick=function() {

        var gotit=false; var guesses=1; var x;

        while (gotit==false) {

            x=Math.random();

            x=6*x;

            x=Math.floor(x);

            if (document.getElementById("myNumber").value==x) {

                gotit=true;

            } else {

                guesses++;

                guesses==15;

            }

            if (guesses==15) { 

            alert("I gave up after 15 wrong guesses!");

            }
        }

        alert("Got it! It was a "+x+". It only took me "+guesses+" guesses!");

    }


    </script>
Russ Eby
@RussEby
Jan 10 2015 19:12
Either change the gotit to true or add a break statement if you want it to break out of the While loop
Never mind, i missed the bracket
Nathan
@terakilobyte
Jan 10 2015 19:13
so much whitespace...
Russ Eby
@RussEby
Jan 10 2015 19:13
Add an if statement to the final alert, to only display if gotit it truee
Dominic Jones
@towwiow
Jan 10 2015 19:14
@terakilobyte -- sorry dude, it helps me understand the logic of it. this is my first time with javascript.
Nathan
@terakilobyte
Jan 10 2015 19:14
what’s the value of x?
Russ Eby
@RussEby
Jan 10 2015 19:14
@terakilobyte x is random
Dominic Jones
@towwiow
Jan 10 2015 19:14
whatever the CPU guesses.
Nathan
@terakilobyte
Jan 10 2015 19:15
I know...
Dominic Jones
@towwiow
Jan 10 2015 19:15
x is random and stops at 6 - so it should go from 0 - 5
Nathan
@terakilobyte
Jan 10 2015 19:15
but what is the value of x as far as guesses are concern?
always random?
Dominic Jones
@towwiow
Jan 10 2015 19:15
the input
Nathan
@terakilobyte
Jan 10 2015 19:15
you’re defining it in the while block
Dominic Jones
@towwiow
Jan 10 2015 19:16
the top half of the code..
<div>
    <p>How many fingers are you holding up?</p>

    <input id="myNumber">

    <button id="guess">Guess!</button>

</div>
Nathan
@terakilobyte
Jan 10 2015 19:16
this
while (gotit==false) {

            x=Math.random();
is not good practice
Dominic Jones
@towwiow
Jan 10 2015 19:17
that may be true, but that's how Rob is teaching it to new, no prior javascript experience, students... what would you do?
Nathan
@terakilobyte
Jan 10 2015 19:17
define it outside the while loop
Russ Eby
@RussEby
Jan 10 2015 19:18
Unless you want it to have a new random number with every loop run.
Nathan
@terakilobyte
Jan 10 2015 19:19
right
sorry, I may just be missing the point of the guessing game
P1xt
@P1xt
Jan 10 2015 19:20
@towwiow define x right above the while loop. Otherwise, it changes every loop through the while loop (it's a moving target). Also, if you only want the "Got it" alert to run if they did, in fact, get it, put it inside an if block
if (gotit === true) {
    alert("Got it")
}
Nathan
@terakilobyte
Jan 10 2015 19:20
^
P1xt
@P1xt
Jan 10 2015 19:23
Also, while we're picking at everything, using "===" to check the value AND type of a variable instead of just using "==" to check the value is a good habit to pick up. It'll save you a ton of headaches in the long run.
Dominic Jones
@towwiow
Jan 10 2015 19:23
point is - for the user to input a number between 0 - 5 and for the cpu to guess between 0 - 5 randomly. when it has it then it should alert, i got it in x amount of guesses.
I'm adding, if it doesn't get it in 15 guesses, just say that you give up.
Nathan
@terakilobyte
Jan 10 2015 19:25
ah, then just the if check and leave the assignment to x where it is
should work
Dominic Jones
@towwiow
Jan 10 2015 19:26
and the number is coming from the user input.. so I don't think it's randomly chasing down a random number each time either
Nathan
@terakilobyte
Jan 10 2015 19:28
what challenge is this from?
Dominic Jones
@towwiow
Jan 10 2015 19:28
it's not an FCC challenge...
it's from the Udemy course
Give me a moment and I'll load it to my site so you can see everything better
P1xt
@P1xt
Jan 10 2015 19:31
It seems like a pretty cruel game if you say "How many fingers am I holding up (while holding up the random number, say 2)" and tell the player "Nope, you're wrong" when they guess 3. Then, pick a new random number (say 4), and tell them "Nope, you're wrong" when they guess 2 (which was the original random number, but not the current "new" random)
Nathan
@terakilobyte
Jan 10 2015 19:32
@P1xt the user enters the number, the computer is the one guessing
from what I understand
P1xt
@P1xt
Jan 10 2015 19:32
Ah, that makes more sense
In that case: Interesting thought experiment for the next challenge to implement ... if there's only 5 possible answers, why should the program need to guess 15 times? Why not keep track of prior guesses and not make the same guess twice ;)
Dominic Jones
@towwiow
Jan 10 2015 19:35
@P1xt yes, the computer is the one guessing lol. I said it twice :( but yeah, I think it's a good experiment too.
just trying to figure this simple game out with my additional layer of an if statement
P1xt
@P1xt
Jan 10 2015 19:37
For that bit, you just need to add an if statement around the final alert because you only want it to print IF gotit === true
Dominic Jones
@towwiow
Jan 10 2015 19:53
@P1xt should I take out the first gotit=true ?
I think that's the only thing stopping it from working now
if not then Idk what's going wrong now.
Nathan
@terakilobyte
Jan 10 2015 19:55
@towwiow I haven’t tested this, but try somethign like
<script type="text/javascript">

  document.getElementById("guess").onclick(function() {

    var gotit = false, guesses = 0, x;

    while (guesses < 15) {

      guesses++;

      x = Math.floor(Math.random() * 6);

      if (+document.getElementById("myNumber").value === x) {

        gotit = true;
        break;

      }
    }

    if (gotit) {

      alert("Got it! It was a "+x+". It only took me "+guesses+" guesses!");

    } else {

      alert("I gave up after 15 wrong guesses!");
    }

  });
  </script>
Dominic Jones
@towwiow
Jan 10 2015 19:55
it's not running at all now. I only added this line: if (gotit==true) { alert("Got it! It was a "+x+". It only took me "+guesses+" guesses!");
@terakilobyte - yours isn't running as is, either.
Ryan Malm
@Rybar
Jan 10 2015 20:35
lint your code, you have unmatched {
and check your console. The "unexpected end of input" error is a good clue you left out a () or {} somewhere.
Ryan Malm
@Rybar
Jan 10 2015 20:47
This message was deleted
Dominic Jones
@towwiow
Jan 10 2015 21:04
@Rybar I see that. Thanks. I'll look over it again and match up the curlies and parens
later though. I just want to get home and get out of this office.
Maxim Orlov
@Maximization
Jan 10 2015 21:47
I just tested your code with the missed bracket replaced and it works, find the missing bracket
Dominic Jones
@towwiow
Jan 10 2015 22:13
thanks @Maximization
@iheartkode - I downloaded appgrid and brackets and now I'm trying to figure out how to get them running now
Mark Howard
@iheartkode
Jan 10 2015 22:14
press the super key and type appgrid
or brackets
Did you install them?
Dominic Jones
@towwiow
Jan 10 2015 22:16
and the appgrid downloaded into a temp folder?
Mark Howard
@iheartkode
Jan 10 2015 22:16
double click it
should be a .deb file
Dominic Jones
@towwiow
Jan 10 2015 22:17
yeah it is.
There is a .deb file - but should I extract them?
This message was deleted
Dominic Jones
@towwiow
Jan 10 2015 22:38
@iheartkode - think I got it with a youtube video lol. waiting for terminal to finish before I can tell for sure
nvm
Mark Howard
@iheartkode
Jan 10 2015 22:47
lol
Dominic Jones
@towwiow
Jan 10 2015 22:48
lol.. was I supposed to extract it or not?
Mark Howard
@iheartkode
Jan 10 2015 22:48
not if its a .deb
Dominic Jones
@towwiow
Jan 10 2015 22:48
I don't think I was supposed to. I ran the three commands they had on the video, but when it went to install (the last command) it just stopped working
okay.
towwiow @towwiow goes to delete the extraction
Mark Howard
@iheartkode
Jan 10 2015 22:48
lol
.deb is a package
Dominic Jones
@towwiow
Jan 10 2015 22:49
is ithere supposed to be a file in the .deb with the terminal install commands? I can't seem to find it
Mark Howard
@iheartkode
Jan 10 2015 22:49
no you should just double click it
Dominic Jones
@towwiow
Jan 10 2015 22:49
okay... now app grid just opens up magically lol wth?
Dominic Desimini
@trisell
Jan 10 2015 23:01
think of .deb as .exe on windows
Dominic Jones
@towwiow
Jan 10 2015 23:01
thanks @trisell that makes a lot more sense
Dominic Desimini
@trisell
Jan 10 2015 23:02
and .rpm is .exe on fedora/centos/red hat
Dominic Jones
@towwiow
Jan 10 2015 23:24
double click on the brackets.deb and it launches app grid, it says it's installing but hasn't done anything for 20 minutes.
Dominic Desimini
@trisell
Jan 10 2015 23:29
sudo add-apt-repository ppa:webupd8team/brackets
sudo apt-get update
sudo apt-get install brackets
Run this in the terminal
This should get it installed for you.
Dominic Jones
@towwiow
Jan 10 2015 23:44
@trisell - let me see
Dominic Jones
@towwiow
Jan 10 2015 23:55
@trisell - ran the commands, it look like it installed but it doesn't seem to open up from the launcher
Mark Howard
@iheartkode
Jan 10 2015 23:58
All i did was download the deb from brackets it installed I ran it lol
Dominic Jones
@towwiow
Jan 10 2015 23:59
Hmm...
I'm just going to delete it and try again haha
making things way too hard right now