Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 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
CamperBot
@camperbot
api offline
Dan Lafferty
@DanLaff
It will make it easier to get help here when your code gets more complicated
Anders Nicolai Magnussen
@andersnicolaimagnussen
Yes, good tip. I will change that right away
Aditya
@ezioda004
@KUBIX90 This should work
if(val.stream === null){
                    $("#" + username).css("box-shadow", "5px 0px 10px red");
                    $("#" + username + ">p").text("Offline")
                                .css("color","red");
                } else {$("#" + username).css("box-shadow", "5px 0px 10px green");
                        $("#" + username + ">p").text("Online")
                                    .css("color","green");
                        }
Easier to select this way without modifying any other parts.
Mark Kubik
@KUBIX90
@ezioda004 Thanks that works perfectly, but I'm not 100% understanding why?
CamperBot
@camperbot
kubix90 sends brownie points to @ezioda004 :sparkles: :thumbsup: :sparkles:
:cookie: 415 | @ezioda004 |http://www.freecodecamp.org/ezioda004
Mark Kubik
@KUBIX90
@ezioda004 Why the ">p"?
Dan Lafferty
@DanLaff
@KUBIX90 It selects all the <p> elements in the #username div https://www.w3schools.com/cssref/css_selectors.asp
Could be troublesome if you add more <p> elements - but goes to show, there are lots of ways to select an element :)
Aditya
@ezioda004
@KUBIX90 With your previous code, you were overwriting the #status since it only selects one. The >p selects child of $("#" + username).
Mark Kubik
@KUBIX90
@DanLaff @ezioda004 Ahh I see thanks for the help both, the fact it was being used in a jQuery context threw me off, I've only ever used it in my CSS file.
CamperBot
@camperbot
kubix90 sends brownie points to @danlaff and @ezioda004 :sparkles: :thumbsup: :sparkles:
api offline
api offline
Kaleb.sh
@porowns

Hi, got a somewhat weird question.

I have a button with and onclick effect, and I'm trying to build up the url of the onclick based on previous button presses, but not really sure how.

Example

<button class=onclick="location.href='https://test.com/{{VARIABLE}}'">
</button>

I'd like to set {{VARIABLE}} using javascript (from a previous onclick()), but not exactly sure how I'd do that. I was thinking about putting like a div and then replacing the value using javascript, but I feel that the '' will negate the div.

Anders Nicolai Magnussen
@andersnicolaimagnussen

Okey, I have fixed a little bit more here now.

https://codepen.io/nicolaimagnussen/pen/aEgrrB

So how can I change all this code to click functions instead?

Daniel Feldman
@Feldbot
I'm having some troubles with this algorithm challenge. I'm getting 3/5 test cases to evaluate okay, but the ones that say, for example, addTogether(2)(3) should return 5. aren't passing. I'm guessing that they mean the 3 is the function factory argument that is passed in in the code, but I'm not sure. You can't call a function with two arguments like they are suggesting that I know of. I'm just not quite getting why these don't pass. Any thoughts?

function addTogether(num1, num2) {

  var add3 = makeAdder([3]);
  var sum;
  var number = true;

  // Function to test if arguments are numbers
  function numTest(args) {
    for (var prop in args) {
      console.log(args[prop]);
      if (typeof args[prop] !== 'number' || Array.isArray(args)) {
        number = false;
      }
    }    
  }

  // 1 argument case
  if (arguments.length === 1) {
    numTest(arguments);
    if (number === false) {
      return undefined;
    } 
    return (add3(2));
  }

  // 2 arguments case
  if (arguments.length > 1) {
    numTest(arguments);
    if (number === false) {
      return undefined;
    } 
    sum = num1 + num2;
    return sum;  
  }

  // makeAdder function
  function makeAdder(x) {
    return function(y) {
      numTest(x);
      if (number === false) {
        return undefined;
      }

      return x + y;
    };
  }
}

addTogether(2);
Kaz Baig
@kbaig
@Feldbot You just need to simplify it so that you have a case for arguments.length being either 1 or 2
if 1, return a function. Your makeAdder looks right to me without the if statement
If 2, return sum of the two args
You have all the components here already
Darren
@DarrenfJ

@kbaig hey buddy thanks for the larfs ;)

But we gotta have semantic markup :clap:

CamperBot
@camperbot
darrenfj sends brownie points to @kbaig :sparkles: :thumbsup: :sparkles:
:cookie: 557 | @kbaig |http://www.freecodecamp.org/kbaig
pragya1248
@pragya1248
hey! finally i completed my homepage .Here is my url:https://codepen.io/pragyapriya/pen/mpZZEz?editors=1100
Kaz Baig
@kbaig
@Feldbot but also add a check in the beginning to make sure your args are numbers, otherwise throw an error
pragya1248
@pragya1248
Any suggestion to make it more attractive
Kaz Baig
@kbaig
@DarrenfJ ;)
Aditya
@ezioda004
@pragya1248 Maybe have the "newsletter" div fixed to the bottom right of the page? It blocks some of the text while scrolling
pragya1248
@pragya1248
ok thanks +1:
Anders Nicolai Magnussen
@andersnicolaimagnussen

@DanLaff

Thanks Dan, Now I understood what you mean with your code example.

You mean something like this

https://codepen.io/nicolaimagnussen/pen/aEgrrB

I agree with you, this is much better and much cleaner in my opinion as well, thanks for showing me that!! ;)

CamperBot
@camperbot
api offline
nicolaimagnussen sends brownie points to @danlaff :sparkles: :thumbsup: :sparkles:
pragya1248
@pragya1248
:)
Daniel Feldman
@Feldbot
@kbaig The hints suggested to make a function to check for argument numbers. I started out more simply like what you suggested, but it got more complex due to needing to check the argument on the makeAdder function. What you suggested is pretty much what is already there in terms of checking for argument length. I just am not sure why it isn't passing and why the test cases say addTogether(2)(3)... it is choking on both those where there is a function call with multiple arguments. I don't even know why they are suggesting that syntax.
Anders Nicolai Magnussen
@andersnicolaimagnussen
@pragya1248 Cool that you have build your first website, it can need some visual approves, but great achievement.
Try checking out bootstrap or CSS grid and flex box
Aditya
@ezioda004
@pragya1248 Its giving early 2000 vibe, css can be improved.
Daniel Feldman
@Feldbot
@pragya1248 Nice work! Some design suggestions that could make it more user-friendly:
  • It is hard to scan the content since the type is virtually all the same size. Try just using the browser defaults for heading levels (h1, h2, h3, etc.) to get an idea of how those create a flow on their own. You may have to look at your content to see how to arrange it by title, subtitle, etc. This will really help things pop and make it easy to scan to see what the page is about.
    • Perhaps look at some templates to get an idea of how to arrange content. Right now everything is 100% wide, which makes it hard to read and scan. If you divide these content areas into smaller width blocks it will be easier to read, and perhaps have a more interesting design.
    • Some of the type is hard to read since the background competes with the text. Maybe use some opacity on the images, or change text colors to be more legible.
Stephen James
@sjames1958gm
@Feldbot your makeAdder function does need to have the argument check.
But you need to call makeAdder with arguments[0] or with num1 as you have that as your first parameter
@Feldbot addTogether(2)(3) should result is addTogether returning a function closed over the value 2 ( basically, makeAdder(2)) then it will call that function with (3)
Daniel Feldman
@Feldbot
@sjames1958gm The makeAdder(x) function does run the numTest function with x passed in, which is the equivalent to the 3 in the makeAdder(3) function. So it does check over that. I wonder why they didn't have their test case say addTogether(2) since the rest of the function tests for (3). It is really confusing to say addTogether(2)(3).
Stephen James
@sjames1958gm
You need to call makeAdder with num1 not [3] or 3 - and that function shouild test for the value y not x in the case of
addTogether(2)(3) x is 2 and y is 3
Bjorn van de Peut
@bjorno43
@Feldbot Also, please use Codepen or Pastebin when posting large walls of code like that. It could be considdered spamming :)
Daniel Feldman
@Feldbot
@bjorno43 Thanks for the tip.
CamperBot
@camperbot
feldbot sends brownie points to @bjorno43 :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @bjorno43 |http://www.freecodecamp.org/bjorno43
Daniel Feldman
@Feldbot
@sjames1958gm Not sure I understand your suggestion. The challenge mentioned checking all the arguments. I thought this meant not only the num1, num2 arguments, but also the argument passed in to make adder (this would be the third argument, x, equal to three 3). So the function I have set up to test checks for num1, and num2, and then lastly checks x as the third argument in the make adder function. So that one checks for what you are calling y or 3.
nsonhouse
@nsonhouse
Can any one help with filtering a background image?