Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
function play(quiz){
            //main game loop
            for(var i=0, question, answer, max=quiz.length; i<max; i++){
                question = quiz[i][0];
                answer = prompt(question);
                if (answer === quiz[i][1]) { // quiz[i][1] is the ith answer
                alert("That is correct!");
                score++//increase score by 1
            //end of main game loop

        function gameOver(){
            //infom the player that the game has finished and tell them how many points they have scored
            alert("Game over, you scored " + score + " points");

        // QUIZ
        var quiz = [
            ["What is Superman's real name ?", "Clarke Kent"],
            ["What os Wonderwoman's real name ?", "Dianna Prince"],
            ["What is Batman's real name ?", "Bruce wayne"]

        var score = 0; // initialize score

that's one way to solve it
thats what i did :)
put the functions inside of the play function
that makes sense
there's other ways
such as passing the values of i into the function
you could do something like check (answer, i)
and then you define function check (answer, i) {blah blah}
it depends on how you want to do it and if you are truly making the functions reusuable
yes, but that is the hard way :)
don't think of it as hard
just different
you'll eventually be doing that stuff
because let's say another function needs to call check (answer)
you don't want to rewrite the code over and over again
and then, maintaining is hard
i see
thank you @sparklie3
rnwebdk sends brownie points to @sparklie3 :sparkles: :thumbsup: :sparkles:
:warning: rnwebdk already gave sparklie3 points
Manish Giri
anyone knows how to draw text with animation on screen?
@teachtyler I have tried the code in your code pen and my dividers are rendering as short dividers and not full length as they are in the code?
@TylerMoeller I have tried the code in your code pen and my dividers are rendering as short dividers and not full length as they are in the code?
hey guys, how would i appropriately target an id element using jquery?
$("'#" + streamers[i] + "'").removeClass("active");
Michael Karpinski
@vinarius that's the correct way to target an id element
if streamers[i] is a string, the last set of quotes SHOULDN'T be necessary, but may be with jQuery
Malala Yousafzai Tribute Page: https://codepen.io/Shizuma/details/gLQwdO
general question
i'm writing a ajax call inside a function
but ajax calls are suppose async
so when i make the call to the function in another function, i have to wait for the response
before I can do anything
for example, my code
function ajax(){
$.ajax ({
//does a ajax call


function  second(){
  //does something more, but want to wait for ajax call

i don't think i'm doing this right because now, my second function has to wait for the ajax call to complete before I can do anything
how should i approach this problem?
Michael Karpinski
@sparklie3 use Ajax's built in method success
it will run whatever code is in the success function after you get the response from the server
$.ajax ({
//does a ajax call
    url: 'www.example/com',
    success: function(data){
        //will execute code in here after data is received
Tyler Moeller
@miriam-z Not sure how to help without seeing your code :/
@karpimpski @sparklie3 The new way of doing it though is with jQuery's newer deferred callbacks rather than using success. http://stackoverflow.com/a/14754681/5253639
var jqxhr = $.ajax( "example.php" )
  .done(function() {
    alert( "success" );
  .fail(function() {
    alert( "error" );
  .always(function() {
    alert( "complete" );

// Perform other work here ...

// Set another completion function for the request above
jqxhr.always(function() {
  alert( "second complete" );
Michael Karpinski
@TylerMoeller yep, should've mentioned that. sorry, I tend to shy away from jQuery and prefer vanilla JS. thanks for the correction!
karpimpski sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
:star2: 1156 | @tylermoeller |http://www.freecodecamp.com/tylermoeller
Tyler Moeller
The success callback still works great for that purpose - still a good suggestion!
William Cross

I'm attempting to make a collapsible navbar for the portfolio project. Not sure what I'm doing wrong, my navbar won't collapse: <!-- nav bar -->

<nav style="background-color:#ffaa00" class="navbar navbar-light navbar-static-top">
<div class="container">
<div class="navbar-header">
<a href="#" class="navbar-brand">Portfolio Site</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navigation"><span class="glyphicon glyphicon-menu-hamburger"></span></button>

<div class="collapse navbar-collapse navigation">
<ul class="nav navbar-nav navbar-right" >
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>

@TylerMoeller this is a code pen http://codepen.io/miriam-z/pen/WoYojX