These are chat archives for FreeCodeCamp/HelpFrontEnd

26th
Aug 2017
Rafael Monroy
@rafaelmonroy
Aug 26 2017 00:00
@sjames1958gm that worked,
Daniel Feldman
@Feldbot
Aug 26 2017 00:01
Hello all. I'm working on the Mutations challenge. I can get all cases to pass except for this one. I think I'm doing something wrong with my return statements that prevent it from comparing the whole array. Any thoughts on how to get it to run through the whole array before returning true or false?
function mutation(arr) {
  var arr1 = arr[0].toLowerCase().split("");
  var arr2 = arr[1].toLowerCase().split("");
  for (var i = 0; i < arr2.length; i++) {
    var answer = arr1.indexOf(arr2[i]);
    if (answer === -1) {
    return false;
    } else {
     return true;
    }
  }
}
mutation(["hello", "hey"]); // => false 2nd index has y
Stephen James
@sjames1958gm
Aug 26 2017 00:01
@rafaelmonroy :+1:
@Feldbot return false inside the loop - wait until after to return true
Daniel Feldman
@Feldbot
Aug 26 2017 00:05
@sjames1958gm Thanks very much Stephen! I tried so many things for hours—ugh!!!
CamperBot
@camperbot
Aug 26 2017 00:05
feldbot sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8389 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 26 2017 00:05
@Feldbot :+1: there is even a array function .every that handles that pattern
Daniel Feldman
@Feldbot
Aug 26 2017 00:07
@sjames1958gm That is good to know, I'll bookmark that. I wonder how many functions wind up taking care of these things later on, like with jQuery and such. This is good though, failing for hours will definitely make me way more attentive to how those returns are structured!
Stephen James
@sjames1958gm
Aug 26 2017 00:08
@Feldbot Yep more is learned, IMO, in failing that in quick success.
fefo360
@fefo360
Aug 26 2017 00:08
@daniel will never forget
Daniel Feldman
@Feldbot
Aug 26 2017 00:09
@fefo360 forget what? lol
fefo360
@fefo360
Aug 26 2017 00:11
@Daniel how to do that piece of code, didnt you find the answer?:p
Daniel Feldman
@Feldbot
Aug 26 2017 00:12
@fefo360 I was just kidding... like I already forgot :-)
fefo360
@fefo360
Aug 26 2017 00:12
lol
what does mutation do :p
Daniel Feldman
@Feldbot
Aug 26 2017 00:16
@fefo360 Besides turning a happy person into a crazy monster, it compares the letters in array[0] to array[1] and looks to see if all the letters are the same.
fefo360
@fefo360
Aug 26 2017 00:17
my God
why do you have strings there if it compares arrays?
Daniel Feldman
@Feldbot
Aug 26 2017 00:20
@fefo360 You need to split the array into letters so you can compare.
fefo360
@fefo360
Aug 26 2017 00:21
hmmm ok
Rafael Monroy
@rafaelmonroy
Aug 26 2017 00:22
@sjames1958gm hey I'm having some trouble understanding how i = (i + 1) % quotes.length; cycles back to zero
fefo360
@fefo360
Aug 26 2017 00:22
and it just returns true or false im assuming
is quotes.lenght 1??
Long Nguyen
@longnt80
Aug 26 2017 00:25
@rafaelmonroy do you know how the % work?
fefo360
@fefo360
Aug 26 2017 00:25
modulus?
Stephen James
@sjames1958gm
Aug 26 2017 00:25
@rafaelmonroy When i + 1 is quotes.length then (i + 1) % quotes.length results in a remainder of zero
Long Nguyen
@longnt80
Aug 26 2017 00:26
@rafaelmonroy ex: quotes.length = 5
1%5 -> i = 1
2%5 -> i = 2
3%5 -> i = 3
4%5 -> i = 4
5%5 -> i = 0
6%5 -> i = 1
7%5 -> i = 2
.....
Stephen James
@sjames1958gm
Aug 26 2017 00:27
@sjames1958gm if quotes.length is 4 then when i is 3 then i + 1 is 4 then 4 % 4 is 0
andry91959
@andry91959
Aug 26 2017 01:43
hello, can someone tell me why my bullet point is overlaping
Capture.PNG
Spacetime
@justinemar
Aug 26 2017 01:58
@andry91959 what's the width of the parent?
post the code it'll be great help for helpers
andry91959
@andry91959
Aug 26 2017 02:01
so I am working on this shopify website
when you minimize the window it messed up the bullet points
Ken Haduch
@khaduch
Aug 26 2017 04:42
@andry91959 - I cannot see the same effect that you showed with your image up above? I might not be looking at the right product that has that same amount of information? Or perhaps you made a change in the code?
Caleb Brenner
@cwborion
Aug 26 2017 04:43

hey folks, can anyone explain to me why i have to apply negative margin and padding to everything between my navbar and footer to get it where i need to? basically i want that middle dark backgroung to go the entire width of the page, as well as the grid items i’m putting in it. i feel like it’s some sort of default setting.

https://codepen.io/Calebwill91/pen/MvryOE

Ken Haduch
@khaduch
Aug 26 2017 04:59
@cwborion - the container class is a fixed-width container. Did you try container-fluid? I think that might be what you want?
Caleb Brenner
@cwborion
Aug 26 2017 05:00
yeah that was it. In my class I was under the impression that that’s how I needed it to be. Thank you, it’s been irritating me for a while now @khaduch
CamperBot
@camperbot
Aug 26 2017 05:00
cwborion sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 3241 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Aug 26 2017 05:01
@cwborion - okay - that's great and you're welcome!
Bigyan Karki
@bigyankarki
Aug 26 2017 05:42
<div class="panel panel-primary">
    <span class="panel-heading">Billing Address</span>
        <div class="panel-body">
            <form action="#" class="form-horizontal" id="billingInfo">

            <div class="form-group">

                <div class="col-sm-2"></div>

                <div class="checkbox col-sm-4">
                    <label><input type="checkbox" name="sameAdd" onclick="sameAddress(this.checked);">Same as Shipping Address</label>
                </div>

                <div class="checkbox col-sm-4">
                    <label><input type="checkbox" name="chargeCredit">Charge My Credit Card</label>
                </div>

              </div>

                <div class="form-group">
                    <span class="control-label col-sm-2 text-muted small-font">Name</span>
                    <div class="col-sm-8" id="billing_name">
                      <input type="text" class="form-control" placeholder="Enter Billing Address" />
                    </div>
                  </div>

                  <div class="form-group">
                    <span class="control-label col-sm-2 text-muted small-font">Street: </span>
                    <div class="col-sm-8" id="billing_street"> 
                      <textarea class="form-control" rows="5" id="street"></textarea>
                    </div>
                    <div class="col-sm-2"></div>
                  </div>

                  <div class="form-group">
                    <span class="control-label col-sm-1 text-muted small-font">City:</span>
                    <div class="col-sm-3" id="billing_city">
                      <input type="text" class="form-control"/>
                    </div>
                    <span class="control-label col-sm-1 text-muted small-font">State:</span>
                    <div class="col-sm-3" id="billing_state">
                      <input type="text" class="form-control"/>
                    </div>
                    <span class="control-label col-sm-1 text-muted small-font">Zip:</span>
                    <div class="col-sm-3" id="billing_zip">
                      <input type="text" class="form-control"/>
                    </div>
                  </div>

            </form>
        </div>
</div>
function sameAddress(checked) {
    if (checked) {
        document.getElementById('billing_name').value = document.getElementById('shipping_name').value;
        document.getElementById('billing_street').value = document.getElementById('shipping_street').value;
        document.getElementById('billing_city').value = document.getElementById('shipping_city').value;
        document.getElementById('billing_state').value = document.getElementById('shipping_state').value;
        document.getElementById('billing_zip').value = document.getElementById('shipping_zip').value;
        }

    else {
        document.getElementById('billing_name').value = "";
        document.getElementById('billing_street').value = "";
        document.getElementById('billing_city').value = "";
        document.getElementById('billing_state').value = "";
        document.getElementById('billing_zip').value = "";
    }
}
can anyone let me know why my form is not working?
Minoy
@minoy
Aug 26 2017 06:26

Hello, I am trying to write a function that takes an array as an argument and checks if all the elements in the array are same, in which case the output should be 'true', else 'false'. Following is the current code:

function isUniform (arr1) {
    var first = arr1[0];
    for (var i = 1; i <= arr1.length - 1; i++) {
        if (arr1[i] === first) {
            if (i === arr1.length - 1) {
                console.log(true);
            } 
        }
        else {
            console.log (false);
        } 
    } 
}

isUniform ([1,1,1,4,1,1,1]);

This gives an output of:
false
true

I am trying to make the loop stop on hitting the first 'false' value. Any ideas?

iso
@iso1048
Aug 26 2017 06:29
@minoy maybe try using break; in the condition which returns false?
Gulsvi
@gulsvi
Aug 26 2017 06:30
Return false first - when the loop finishes, return true
function isUniform(arr1) {
  var first = arr1[0];
  for (var i = 1; i <= arr1.length - 1; i++) {
    if (arr1[i] !== first) console.log(false);
  }
  console.log(true);
}

isUniform([1, 1, 1, 4, 1, 1, 1]);
(replace console.log() with returns)
iso
@iso1048
Aug 26 2017 06:30
@SkyC0derr haven't left yet?
Gulsvi
@gulsvi
Aug 26 2017 06:30
Not until Sunday. Still Friday
iso
@iso1048
Aug 26 2017 06:31
oh I thought you were leaving today. my bad
Gulsvi
@gulsvi
Aug 26 2017 06:32
No worries - a little more time left to code :p
iso
@iso1048
Aug 26 2017 06:33
did you finish that last challenge?
Gulsvi
@gulsvi
Aug 26 2017 06:33
Yes, earlier today
iso
@iso1048
Aug 26 2017 06:33
nice
Gulsvi
@gulsvi
Aug 26 2017 06:33
Exact Change took me a few hours... very challenging
iso
@iso1048
Aug 26 2017 06:34
@SkyC0derr i want to put info for 20 amino acids with their structure a a few other details. Should I just hard code it or put the information in an object/array then loop through it?
Gulsvi
@gulsvi
Aug 26 2017 06:35
Probably better to put it in an object if you have some template HTML you can display it in
@minoy You could also use .every():
function isUniform(arr1) {
  return arr1.every(v => v == arr1[0]);
}

isUniform([1, 1, 1, 4, 1, 1, 1]);
Minoy
@minoy
Aug 26 2017 06:42
@gothamknight thanks it worked!
CamperBot
@camperbot
Aug 26 2017 06:42
minoy sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 399 | @gothamknight |http://www.freecodecamp.com/gothamknight
Minoy
@minoy
Aug 26 2017 07:08
@SkyC0derr thanks! .every() method makes it very concise.
CamperBot
@camperbot
Aug 26 2017 07:08
minoy sends brownie points to @skyc0derr :sparkles: :thumbsup: :sparkles:
:warning: @skyc0derr's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
Rafael Monroy
@rafaelmonroy
Aug 26 2017 08:44
this code works fine when I run it on my local server with sublime, but it wont print out to the console on codepen, can anyone tell me why?
$(document).ready(function(){
    $.ajax({
      type: 'GET',
      url: 'http://rest.learncode.academy/api/johnbob/friends',
      success: function(data) {
        console.log("I have friends!", data); 
      }
    });

});
iso
@iso1048
Aug 26 2017 08:47
@rafaelmonroy your url is http. codepen is served over https so anything that requests http will not work
Rafael Monroy
@rafaelmonroy
Aug 26 2017 08:55

in this code


$(document).ready(function(){

  var quotes = [
    {
     quote: "bla bla bla -me"
    },
    {
     quote: "cha cha cha -you"
    },
    {
     quote: "sa sa sa - him"
    },
    {
    quote: "fa fa fa -her"
    }
  ];


  var i = Math.floor(Math.random() * 2);
  $("#btn").click(function(){
    $("#people").html("<p>"+quotes[i].quote+"</p>");
    i = (i + 1) % quotes.length;
  });

});

i see how everything works and how “i" is reset to 0 by the %, but the only part i dont see is how (i+1) = quotes.length, i never set it to that, or did i and not know? how does javascript know. I see how quotes.length % quotes.length is equal to 0, but i dont see where (i+1) = quotes.length, can anyone shine some light on me? thanks

@gothamknight thanks man
Long Nguyen
@longnt80
Aug 26 2017 09:17
@rafaelmonroy if you're loading random i, there's no point for i = (i + 1) % quotes.length
just make i randomly from 0 to quotes.length - 1
This message was deleted
buiphuking
@buiphuking
Aug 26 2017 10:19
anyone vietnamese here?
BuntyBru
@BuntyBru
Aug 26 2017 13:31

hi everyone Tell me one thing
For bootstrap

DO we have to download it or it can work through putting a <link> tag on html HEAD?

Tom
@moT01
Aug 26 2017 13:34
you can link it
@BuntyBru
BuntyBru
@BuntyBru
Aug 26 2017 13:35
@moT01
thanks TOm
CamperBot
@camperbot
Aug 26 2017 13:35
buntybru sends brownie points to @mot01 :sparkles: :thumbsup: :sparkles:
:cookie: 814 | @mot01 |http://www.freecodecamp.com/mot01
Tom
@moT01
Aug 26 2017 13:36
https://cdnjs.com/ - search bootstrap copy the link
just1witness
@just1witness
Aug 26 2017 14:04
answer = [["ONE HUNDRED", 0],
["TWENTY", 60],
["TEN", 20],
["FIVE", 15],
["ONE", 1],
["QUARTER", 0.5],
["DIME", 0.2],
["NICKEL", 0],
["PENNY", 0.04]];
oops, hold on a sec, lol
My for loop only removes the first true test, then stops
answer = [["ONE HUNDRED", 0],
                  ["TWENTY", 60],
                  ["TEN", 20],
                  ["FIVE", 15],
                  ["ONE", 1],
                  ["QUARTER", 0.5],
                  ["DIME", 0.2],
                  ["NICKEL", 0],
                  ["PENNY", 0.04]];

   for(var i = 0; i < answer.length; i++){
    if(answer[i][1] === 0){
     answer.splice([i],1);
      }
    return answer;
      }
       }

checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);

//THIS RETURNS

[
                  ["TWENTY", 60],
                  ["TEN", 20],
                  ["FIVE", 15],
                  ["ONE", 1],
                  ["QUARTER", 0.5],
                  ["DIME", 0.2],
                  ["NICKEL", 0],
                  ["PENNY", 0.04]];
It doesn't remove the nickel
only the one hundred
just1witness
@just1witness
Aug 26 2017 14:17
If I make another loop it removes the nickel
But aren't loops supposed to go through the entire array and return all true tests?
Markus Kiili
@Masd925
Aug 26 2017 14:20
@just1witness A return statement exist the whole function (and thus also the loop).
just1witness
@just1witness
Aug 26 2017 14:22
How do I get the output of the loop without a return statement? I've tried moving it all the way down until it says it's out of scope and it doesn't work
I can get all the tests but 4 to pass with this, it removes all the zero values except, twenty, five and nickel... would you like to see the whole code?
@Masd925
Markus Kiili
@Masd925
Aug 26 2017 14:26
@just1witness Usually you do things inside the loop and return after the loop (but inside the function).
just1witness
@just1witness
Aug 26 2017 14:26
@Masd925 yeah, that's what I have
here's the whole thing
function checkCashRegister(price, cash, cid) {
     var answer = [["ONE HUNDRED", 0],
                  ["TWENTY", 0],
                  ["TEN", 0],
                  ["FIVE", 0],
                  ["ONE", 0],
                  ["QUARTER", 0],
                  ["DIME", 0],
                  ["NICKEL", 0],
                  ["PENNY", 0]];
  var cidArr = cid.reverse();
  var changeDue = (cash - price) * 100;
  var cidTot = (cid.reduce(function(acc,val){
    return acc+val[1] * 100;
   },0));

 if (changeDue === cidTot) {
    return 'Closed';
  } 
 if (changeDue > cidTot){
    return 'Insufficient Funds';
 }

   while (changeDue > 0){


   if(changeDue >= 10000 && cidArr[0][1] * 100 >= 10000){
    changeDue = changeDue - 10000;
     answer[0][1] = answer[0][1] + 10000 / 100;
      cidArr[0][1] = ((cidArr[0][1] * 100) - 10000) /100;
   }
    else if(changeDue >= 2000 && cidArr[1][1] * 100 >= 2000){
     changeDue = changeDue - 2000;
      answer[1][1] = answer[1][1] + 2000 / 100;
       cidArr[1][1] = ((cidArr[1][1] * 100) - 2000) / 100;
   } 
     else if(changeDue >= 1000 && cidArr[2][1] * 100 >= 1000){
     changeDue = changeDue - 1000;
      answer[2][1] = answer[2][1] + 1000 / 100;
       cidArr[2][1] = ((cidArr[2][1] * 100) - 1000) / 100;
   } 
      else if(changeDue >= 500 && cidArr[3][1] * 100 >= 500){
     changeDue = changeDue - 500;
      answer[3][1] = answer[3][1] + 500 / 100;
       cidArr[3][1] = ((cidArr[3][1] * 100) - 500) / 100;
   } 
      else if(changeDue >= 100 && cidArr[4][1] * 100 >= 100){
     changeDue = changeDue - 100;
      answer[4][1] = answer[4][1] + 100 / 100;
       cidArr[4][1] = ((cidArr[4][1] * 100) - 100) / 100;
   } 
      else if(changeDue >= 25 && cidArr[5][1] * 100 >= 25){
     changeDue = changeDue - 25;
      answer[5][1] = answer[5][1] + 25 / 100;
       cidArr[5][1] = ((cidArr[5][1] * 100) - 25) / 100;
   } 
      else if(changeDue >= 10 && cidArr[6][1] * 100 >= 10){
     changeDue = changeDue - 10;
      answer[6][1] = answer[6][1] + 10 / 100;
       cidArr[6][1] = ((cidArr[6][1] * 100) - 10) / 100;
   } 
      else if(changeDue >= 5 && cidArr[7][1] * 100 >= 5){
     changeDue = changeDue - 5;
      answer[7][1] = answer[7][1] + 5 / 100;
       cidArr[7][1] = ((cidArr[7][1] * 100) - 5) / 100;
   } 
         else if(changeDue >= 1 && cidArr[8][1] * 100 >= 1){
     changeDue = changeDue - 1;
      answer[8][1] = answer[8][1] + 1 / 100;
       cidArr[8][1] = ((cidArr[8][1] * 100) - 1) / 100;
         }
       else { 
         return "Insufficient Funds";           
            } 
   }
   for(var i = 0; i < answer.length; i++){
    if(answer[i][1] === 0){
     answer.splice([i],1);
      }
   }


      return answer;


}
checkCashRegister(19.50, 20.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);
Markus Kiili
@Masd925
Aug 26 2017 14:33
@just1witness There is no need to hardcode all those tests. What I did was to use an object var NOTES = {"ONE HUNDRED":100,"TWENTY":20,"TEN":10,"FIVE":5,"ONE":1,"QUARTER":0.25,"DIME":0.10,"NICKEL":0.05,"PENNY":0.01}; and then solved it by iterating cid. That way avoids repeating code that you have there.
just1witness
@just1witness
Aug 26 2017 14:35
@Masd925 I know it's inefficient. It's what I'm going with for now, because with my current knowledge I don't know how to do it better and I don't want to look at an answer yet. Once I pass all the tests to a challenge, I look at the solutions on the hint page and watch a couple tutorials on it, to learn how to do it better. This is the second time I've written this one from the ground up. Once I get it to pass, I'll move on to doing it more efficiently.
Markus Kiili
@Masd925
Aug 26 2017 14:36
@just1witness Yeah. You can always refactor them later.
just1witness
@just1witness
Aug 26 2017 14:37
:)
just1witness
@just1witness
Aug 26 2017 14:46
Welp, adding the second loop makes it pass all the tests... I guess that means I can move on to the solutions, even though the answer is very unsatisfying, lol. :/
Markus Kiili
@Masd925
Aug 26 2017 14:47
@just1witness Yes. Do it again later when you know more.
Jorge
@OrangeKulture
Aug 26 2017 14:53
ahh the good 'ol cashier algorithm .. what a pain :joy:
anyone here? would appreciate someone could help me test drive a small project..
please someone help me with my problem
in the jquery
just1witness
@just1witness
Aug 26 2017 15:00
@Masd925 Thank you
CamperBot
@camperbot
Aug 26 2017 15:00
just1witness sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4439 | @masd925 |http://www.freecodecamp.com/masd925
just1witness
@just1witness
Aug 26 2017 15:01
I'll loo at it
look*
@OrangeKulture
Jorge
@OrangeKulture
Aug 26 2017 15:01
@just1witness awesome thanks ... one sec
CamperBot
@camperbot
Aug 26 2017 15:01
orangekulture sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 294 | @just1witness |http://www.freecodecamp.com/just1witness
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
Aug 26 2017 15:03
@mahi929 What is the problem?
Jorge
@OrangeKulture
Aug 26 2017 15:13
lost internet .. sry
@just1witness App
the info doesnt have to be real, just try and make a user but remember the user and password and test if you can login ..
just1witness
@just1witness
Aug 26 2017 15:15
k
worked like a charm. I would personally suggest having the user submit the password twice, or giving the option to see it, to avoid typo mistakes that make it so they can't sign in. @OrangeKulture
Mahesh
@mahis929
Aug 26 2017 15:20
@Otto-AA
the jquery is not working on my local machine
try it on yours by copying the code
just1witness
@just1witness
Aug 26 2017 15:26
move the return statement out of the for loop @lestairon
Fernando
@lestairon
Aug 26 2017 15:27
@just1witness Thanks, now i noticed something still wrong
CamperBot
@camperbot
Aug 26 2017 15:27
lestairon sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @just1witness |http://www.freecodecamp.com/just1witness
Mahesh
@mahis929
Aug 26 2017 15:28
hiii
just1witness
@just1witness
Aug 26 2017 15:28
:)
hiiiii back
@lestairon what is it?
Fernando
@lestairon
Aug 26 2017 15:29
It's returning every value at the array + the one who is next
just1witness
@just1witness
Aug 26 2017 15:30
can you paste the code again? I can't remember what it was. @lestairon
Fernando
@lestairon
Aug 26 2017 15:30

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var newArr = [];
  for (i = 0; i < arr.length; i++) {
    newArr.push(arr[i] + arr[i+(size-1)]);

  }
  return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Returns ["ab"], ["bc"], ["cd"], ["dundefined"]
just1witness
@just1witness
Aug 26 2017 15:33
change i++ to i+=2 @lestairon
your pairing every iteration, I think you want to pair every other
you're*
Fernando
@lestairon
Aug 26 2017 15:33
Oh, right, thanks
just1witness
@just1witness
Aug 26 2017 15:33
no prob
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
Aug 26 2017 15:34
@mahi929 Have you tried loading the jquery script in your html file before your own script?
aRtoo
@artoodeeto
Aug 26 2017 16:18

alright guys. so im back. this is getting crazier. so on algorithm challenge entitled. arguments optional. the instruction says:

// Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.
// For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function.
// Calling this returned function with a single argument will then return the sum:
// var sumTwoAnd = addTogether(2);
// sumTwoAnd(3) returns 5.
// If either argument isn't a valid number, return undefined

now how can i return the a sum with only one argument?
this is my code:

function addTogether(a,b) {

  var len = arguments.length;

  if(len === 1){
    return function(x){
      return x;
    };
  } 
  return a+b;
}
addTogether(2,3);
Jorge
@OrangeKulture
Aug 26 2017 16:28
@just1witness awesome stuff! thanks a lot for checking
CamperBot
@camperbot
Aug 26 2017 16:28
orangekulture sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 296 | @just1witness |http://www.freecodecamp.com/just1witness
Jorge
@OrangeKulture
Aug 26 2017 16:29
@just1witness yeah its not really meant to be for production, it's just to showcase the techs behind the code, thanks again, appreciated
CamperBot
@camperbot
Aug 26 2017 16:29
orangekulture sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:warning: orangekulture already gave just1witness points
just1witness
@just1witness
Aug 26 2017 16:29
No prob Bob @OrangeKulture
@artoodeeto read about the .reduce() function. You'll want to add +in front of a, and b to treat them like numbers.
oops, ingnore the last part
I tried to delete it, but hit enter
Jorge
@OrangeKulture
Aug 26 2017 16:31
@artoodeeto u also need to return undefined for certain tests
just1witness
@just1witness
Aug 26 2017 16:31
look at reduce though
oh, arguments optional... I hated that one
Jorge
@OrangeKulture
Aug 26 2017 16:33
yeah that one was a lil bit tricky for sure
just1witness
@just1witness
Aug 26 2017 16:37
@artoodeeto forget what I said about reduce with this one. One tool that will be useful for you here is the conditional ternary operator, read a little on that. And you might want to use a helper function to use what you get for the first argument to check the second argument.
aRtoo
@artoodeeto
Aug 26 2017 16:38
@just1witness thanks. ill understand this
CamperBot
@camperbot
Aug 26 2017 16:38
artoodeeto sends brownie points to @just1witness :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @just1witness |http://www.freecodecamp.com/just1witness
Mauricio Scioville
@invasorMou
Aug 26 2017 17:26
Hi, Im bulding my random quote machine, but I don't know how to make the tweet button, any advice?
Ghost
@ghost~57b1df1e40f3a6eec05f92a8
Aug 26 2017 17:28
@invasorMou Did you already check the tutorial on twitter? (https://dev.twitter.com/web/tweet-button - How to add a Tweet button to your website)
korzo
@korzo
Aug 26 2017 17:28
@invasorMou You can't use twitter button, but link like
https://twitter.com/intent/tweet?text=' + encodeURIComponent('"' + currentQuote + '" ' + currentAuthor)
5millerk
@5millerk
Aug 26 2017 17:33
does anyone actually use the FCC weather api? I'm getting very frustrated trying to pull data from it. When I've looked at other people's projects it seems everyone uses the darksky api :-/
Gulsvi
@gulsvi
Aug 26 2017 17:36
@5millerk It has only been around for a month or two. Everyone used Dark Sky before that. The FCC Weather API is a pass through for Open Weather Map, if you need more documentation for it: https://openweathermap.org/current
just1witness
@just1witness
Aug 26 2017 17:36
I used this
 //call to darksky for weather results based on 'coords' variable called with ajax previously//
    var darkSkyAPI = "https://api.darksky.net/forecast/c1c79c93374cb0e0b5e2439d84fd12f5/" + coords + "?exclude=minutely,hourly,daily";
 //function and ajax call to get weather condtions for specified coordinates//  
    getWeather(darkSkyAPI);
@5millerk
Mauricio Scioville
@invasorMou
Aug 26 2017 17:37
@Otto-AA I'll check thanks
CamperBot
@camperbot
Aug 26 2017 17:37
invasormou sends brownie points to @otto-aa :sparkles: :thumbsup: :sparkles:
:cookie: 385 | @otto-aa |http://www.freecodecamp.com/otto-aa
Mauricio Scioville
@invasorMou
Aug 26 2017 17:37
@korzo thanks man
Gulsvi
@gulsvi
Aug 26 2017 17:37
@just1witness That is not your API key for Dark Sky
just1witness
@just1witness
Aug 26 2017 17:38
oops, I was just showing that I used darksky, the lazy way, since I'm on phone
lol
Gulsvi
@gulsvi
Aug 26 2017 17:39
Your pen is using that key though: https://s.codepen.io/Just1witness/pen/BZRozr
just1witness
@just1witness
Aug 26 2017 17:41
@SkyC0derr Thanks :)
CamperBot
@camperbot
Aug 26 2017 17:41
just1witness sends brownie points to @skyc0derr :sparkles: :thumbsup: :sparkles:
:warning: @skyc0derr's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
5millerk
@5millerk
Aug 26 2017 17:44
ok so maybe someone can help explain this because i've been staring at it for a long time now and i just confused myself more
my api address is right (if I take the console.log and paste it to my browser i pull up good data)
but i can't get either of the console.log() inside the getJSON function to return data
Gulsvi
@gulsvi
Aug 26 2017 17:45
@5millerk
      $.getJSON("https://fcc-weather-api.glitch.me/api/current?lon=" + lon + "&lat=" + lat, function(json) {
        console.log(json);
        console.log(lon);
      });
you have some syntax issues in the URL
5millerk
@5millerk
Aug 26 2017 17:46
sigh
thanks buddy
actually wait
Gulsvi
@gulsvi
Aug 26 2017 17:46
Can't have the : in the URL - that's just standard way of referring to an endpoint I guess
5millerk
@5millerk
Aug 26 2017 17:46
it still doesn't kick anything back to me
even when i fix those
the last 2 console.log() don't log anything
Gulsvi
@gulsvi
Aug 26 2017 17:46
Did you fix json[0][0] too?
start with looking at json and then drive down into the object from there
5millerk
@5millerk
Aug 26 2017 17:47
i actually just added that line too haha
and still get no data for console.log(json)
nothing goes to the console at al
all
and i don't get an error or anything
5millerk
@5millerk
Aug 26 2017 17:53
@SkyC0der thanks buddy, helpful as always
CamperBot
@camperbot
Aug 26 2017 17:53
5millerk sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2570 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Aug 26 2017 17:53
No problem
5millerk
@5millerk
Aug 26 2017 17:53
the old "you put an extra parenthesis" bug...
lol
Gulsvi
@gulsvi
Aug 26 2017 17:53
:)
Zachary Orona-Calvert
@TheTRUEHoohah
Aug 26 2017 18:25
hey guys how could a make a stopwatch that uses system time in JS
Jan Shah
@JanShah
Aug 26 2017 18:29
get a new Date() @TheTRUEHoohah and use those values
Zachary Orona-Calvert
@TheTRUEHoohah
Aug 26 2017 18:31
thanks @JanShah
CamperBot
@camperbot
Aug 26 2017 18:31
thetruehoohah sends brownie points to @janshah :sparkles: :thumbsup: :sparkles:
:cookie: 493 | @janshah |http://www.freecodecamp.com/janshah
Rajat Khare
@rajatkhare619
Aug 26 2017 18:41

Hey guys,

I’m looking for a way to change the opacity of a particular area of an image. The images would be fetched dynamically.
Something like this:

The circular area has higher opacity than the rest of the image.

One way of selecting area is image map but I don’t think I can style that.

I would appreciate any ideas.

@rajatkhare619
Amit Joshi
@amitjoshi956
Aug 26 2017 18:52
Hey guys! I have some problem figuring out the "Get Streams by User" endpoint of the Twitch.tv api! Can anyone help?
Andrei
@DrDrei
Aug 26 2017 19:05
what's the problem?
Moisés Man
@moigithub
Aug 26 2017 19:08
...../streams/username
Rajat Khare
@rajatkhare619
Aug 26 2017 19:12
@JanShah Thank! Will look into it.
CamperBot
@camperbot
Aug 26 2017 19:12
rajatkhare619 sends brownie points to @janshah :sparkles: :thumbsup: :sparkles:
:cookie: 494 | @janshah |http://www.freecodecamp.com/janshah
Caleb Brenner
@cwborion
Aug 26 2017 19:32

can anyone explaine why when I resize my screen the part with the dark background’s text and image don’t overlap but the two light background areas do? they have virtually the same code written.

https://codepen.io/Calebwill91/pen/MvryOE

korzo
@korzo
Aug 26 2017 19:37
@cwborion You have to add to css img { max-width: 100%;}
@cwborion Difference is that image is overflowing to the right.
In white it goes over text, in dark not
Caleb Brenner
@cwborion
Aug 26 2017 19:40
ah that worked, thank you! my only issue now is that I can’t change the right margins or padding of the font in the dark section to align it with the right side of the images on the left side of the grid.
thank you @korzo
CamperBot
@camperbot
Aug 26 2017 19:40
cwborion sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 412 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
Aug 26 2017 19:44
@cwborion you can use negative margin on image or text
Caleb Brenner
@cwborion
Aug 26 2017 19:45
@korzo I will try messing with that. Thank you for your help! sometimes another set of eyes picks it out so fast
CamperBot
@camperbot
Aug 26 2017 19:45
cwborion sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:warning: cwborion already gave korzo points
Denise Pilgrim
@godluvu22
Aug 26 2017 19:54
I am still struggling with the issue of centering my code and page. I have a project called Mimi Camp on Code Pen and if anyone could check it and tell me what I can do to center my design. I am not even sure how to put my code where someone can view it!
korzo
@korzo
Aug 26 2017 19:57
@godluvu22 Post link to your pen
Denise Pilgrim
@godluvu22
Aug 26 2017 20:30
I think I got it woked out! thanks so much Korzo.
Sam Moradi
@sammymm
Aug 26 2017 21:50
Hi everyone, I'm doing the wikipedia search challenge and for some reason my ajax function is not returning anything
not sure what i'm missing
Moisés Man
@moigithub
Aug 26 2017 21:51
@sammymm open ur BROWSER console (NOT codepen console)
F12 on most browsers
u will see an error
Sam Moradi
@sammymm
Aug 26 2017 21:55
@moigithub I did, and I don't understand what it means
iso
@iso1048
Aug 26 2017 21:59
@sammymm it means that the domain you are trying to request the information from will not send the information due to security reasons or something (is that correct @moigithub ?) Add dataType: 'jsonp', to your ajax call then check the console.
Moisés Man
@moigithub
Aug 26 2017 22:00
thats a CORS restriction u can google for more info :)
wiki API allows cors request by passing origin=* parameter
another way to bypass that is usign JSONP requests
Sam Moradi
@sammymm
Aug 26 2017 22:01
ok, I changed it to jsonp
Jorge
@OrangeKulture
Aug 26 2017 22:01
@moigithub do u work with backend at all ?
Moisés Man
@moigithub
Aug 26 2017 22:01
yep cross domain request not allowed by default.. unless server explicitly allows it
Sam Moradi
@sammymm
Aug 26 2017 22:02
but how do you figure out what the error is from the console?
which part do i look at?
iso
@iso1048
Aug 26 2017 22:03
@sammymm google "Access-Control-Allow-Origin"
Moisés Man
@moigithub
Aug 26 2017 22:03
work... whats that ? @OrangeKulture
Gulsvi
@gulsvi
Aug 26 2017 22:03
@sammymm Wikipedia allows you to make cross origin requests with the origin parameter. Add origin=* to your URL to allow any origin:
https://en.wikipedia.org/w/api.php?action=opensearch&limit=10&origin=*&namespace=0&search=
No need for JSONP with the Wikipedia API
Jorge
@OrangeKulture
Aug 26 2017 22:03
lol well do you play with backend?
Gulsvi
@gulsvi
Aug 26 2017 22:04
wrong room, guys :p
Jorge
@OrangeKulture
Aug 26 2017 22:04
lol yeah ..
Moisés Man
@moigithub
Aug 26 2017 22:04
:P .. been/im doing job hunting this year no luck yet
yep.. i did backend FCC projects long time ago
@OrangeKulture
Jorge
@OrangeKulture
Aug 26 2017 22:05
thats cool ... i should do the advanced on backend too, would be fun
Sam Moradi
@sammymm
Aug 26 2017 22:05
ok it did work when I added origin=* but not by changing json to jsonp
thanks @SkyC0der
CamperBot
@camperbot
Aug 26 2017 22:06
sammymm sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2573 | @skyc0der |http://www.freecodecamp.com/skyc0der
Pagnito
@Pagnito
Aug 26 2017 22:07
@SkyC0der
Gulsvi
@gulsvi
Aug 26 2017 22:07
Hey @Pagnito
@sammymm Glad I could help - try to simplify your ajax a bit, in case other errors come up. This is all you need to get your URL working:
  var url = "https://en.wikipedia.org/w/api.php?action=opensearch&origin=*&limit=10&namespace=0&search=" + searchCriteria;
  $.ajax({
    url: url,
    success: function(data) {
      console.log(data);
    }
  });
Sam Moradi
@sammymm
Aug 26 2017 22:08
okay I will, I tried adding .done to the end but it didn't work
how can I add a line that let's me know if the call was successful or not
because I don't really get what I'm looking at in the console
Gulsvi
@gulsvi
Aug 26 2017 22:10
That would look like this:
  $.ajax(url).done(function(data) {
    console.log(data);
  });
.done() is only called on success
.fail() is called on errors
  $.ajax(url)
    .done(function(data) {
      console.log(data);
    })
    .fail(function(err) {
      console.error(err);
    })
Pagnito
@Pagnito
Aug 26 2017 22:11
@SkyC0der sweet thanks
CamperBot
@camperbot
Aug 26 2017 22:11
pagnito sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:star2: 2574 | @skyc0der |http://www.freecodecamp.com/skyc0der
Gulsvi
@gulsvi
Aug 26 2017 22:11
@Pagnito What did I help with ? :)
Pagnito
@Pagnito
Aug 26 2017 22:11
@Pagnito ill just use that in future projects
Hey @Pagnito
oh nvm
it was for sammymm
but right after u shouted me out
Gulsvi
@gulsvi
Aug 26 2017 22:12
You didn't ask a question, I was just saying Hi
Pagnito
@Pagnito
Aug 26 2017 22:12
but anyways do u know how to override materialize table height?
Gulsvi
@gulsvi
Aug 26 2017 22:12
not off the top of my head
do you have an example? I could try to figure it out
Sam Moradi
@sammymm
Aug 26 2017 22:13
thanks @SkyC0der so I can just add those lines under my regular ajax function or do i have to create a new one with $.ajax(url)
CamperBot
@camperbot
Aug 26 2017 22:13
sammymm sends brownie points to @skyc0der :sparkles: :thumbsup: :sparkles:
:warning: sammymm already gave skyc0der points
iso
@iso1048
Aug 26 2017 22:13
@SkyC0der this time - safe travels for tomorrow
@SkyC0der finish any more projects?
Gulsvi
@gulsvi
Aug 26 2017 22:13
@sammymm you would have to choose to use either sucess: or the .done() .fail() pattern
Sam Moradi
@sammymm
Aug 26 2017 22:14
right
Pagnito
@Pagnito
Aug 26 2017 22:14
@SkyC0der not ,its in my jsx :/
Gulsvi
@gulsvi
Aug 26 2017 22:14
@gothamknight No more projects, but all the advanced algorithms are done :)
Pagnito
@Pagnito
Aug 26 2017 22:14
@SkyC0der u finally did no repeats please?
Gulsvi
@gulsvi
Aug 26 2017 22:14
@Pagnito I could figure out the CSS, not the jsx :/
Yeah, I did that one earlier this week - no repeats please
Sam Moradi
@sammymm
Aug 26 2017 22:15
this whole experience would be much shittier without your help. thanks bud
Gulsvi
@gulsvi
Aug 26 2017 22:15
lol, happy to make things less shitty :p
Pagnito
@Pagnito
Aug 26 2017 22:15
@SkyC0der did u make ur own heaps algorithm?
Gulsvi
@gulsvi
Aug 26 2017 22:15
Got the heap's algorithm working @Pagnito yeah
iso
@iso1048
Aug 26 2017 22:16
@SkyC0der do you know how to set the dimensions of a screenshot?
Gulsvi
@gulsvi
Aug 26 2017 22:16
In MS Paint, sure @gothamknight
iso
@iso1048
Aug 26 2017 22:17
i want to take same same width, height image in one step. yeah guess i could use paint
Pagnito
@Pagnito
Aug 26 2017 22:17
@SkyC0der nice
Gulsvi
@gulsvi
Aug 26 2017 22:17
took me practically an entire day to do that challenge - exact change was a serious pain too
Gulsvi
@gulsvi
Aug 26 2017 22:28
Adios FCC! :)
iso
@iso1048
Aug 26 2017 22:28
@SkyC0der goodbye.
Jorge
@OrangeKulture
Aug 26 2017 22:32
cya later Sky
iso
@iso1048
Aug 26 2017 22:33
@OrangeKulture would you be able to give some feedback on my steamroller code?
Jorge
@OrangeKulture
Aug 26 2017 22:49
@gothamknight sry dude was away .. yeah sure thing
just1witness
@just1witness
Aug 26 2017 23:03
@SkyC0der I did it! I did it! I'm done and it's beautiul, lalala!
function checkCashRegister(price, cash, cid) {
     var value = [[10000],
                  [2000],
                  [1000],
                  [500],
                  [100],
                  [25],
                  [10],
                  [5],
                  [1]];
     var answer = [["ONE HUNDRED", 0],
                  ["TWENTY", 0],
                  ["TEN", 0],
                  ["FIVE", 0],
                  ["ONE", 0],
                  ["QUARTER", 0],
                  ["DIME", 0],
                  ["NICKEL", 0],
                  ["PENNY", 0]];
  var cidArr = cid.reverse();
  var changeDue = (cash - price) * 100;
  var cidTot = (cid.reduce(function(acc,val){
    return acc+val[1] * 100;
   },0));  
 if (changeDue === cidTot) {
    return 'Closed';
   } 
 if (changeDue > cidTot){
    return 'Insufficient Funds';
   }
 for(var k = 0; k < cidArr.length; k++){
  if(changeDue >= 0 && value[k] <= changeDue){
   if(value[k] <= cidArr[k][1] * 100){
    changeDue = changeDue - value[k];   
     answer[k][1] = ((answer[k][1]) + (value[k]) /100);
      cidArr[k][1] = ((cidArr[k][1] * 100) - value[k]) / 100;
       k = 0;   
        }   
         }
          }
   for(var i = 0; i < answer.length; i++){
    if(answer[i][1] === 0){
     answer.splice([i],1);
      i = -1; 
       }
   if (changeDue > 0) {
    return "Insufficient Funds";}
     }      
  return  answer;   
}
checkCashRegister(3.26, 3.30, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]) ;
iso
@iso1048
Aug 26 2017 23:13

@OrangeKulture no worries.

function steamrollArray(arr) {
 var newArr=[]; 
 for (var i =0; i<arr.length; i++){
  Array.isArray(arr[i]) ? arr.push(arr[i][0],arr[i][1]) : newArr.push(arr[i]);
 }
  return newArr.filter(item => item != null);
}

steamrollArray([1, [2], [3, [[4]]]]);

(i did pass the challenge, just wanted some feedback). thanks man

CamperBot
@camperbot
Aug 26 2017 23:13
:cookie: 443 | @orangekulture |http://www.freecodecamp.com/orangekulture
gothamknight sends brownie points to @orangekulture :sparkles: :thumbsup: :sparkles:
aRtoo
@artoodeeto
Aug 26 2017 23:35
should i use loop on the algorithm?
to check if all arguments are interger?

function addTogether(a,b) {

  var len = arguments.length;
  if(len === 1 ){
    return function(x){

      return a+x;
    };
  } 
  else if(arguments === isNaN) {
    return undefined;
  } 

  return a+b + 'sdf';
}
//addTogether(2);
//addTogether(2, 3);//should return 5.
//addTogether(2)(3);//should return 5.
//addTogether("http://bit.ly/IqT6zt");//should return undefined.
//addTogether(2, "3");//should return undefined.
addTogether(2)([3]);//should return undefined.
ehutchllew
@ehutchllew
Aug 26 2017 23:45
@artoodeeto try using a loop and typeof
Pagnito
@Pagnito
Aug 26 2017 23:50
i wonder if its possible to come up with a method in a programming language that rewinds an event
ehutchllew
@ehutchllew
Aug 26 2017 23:51
Not quite a rewind, but there are ways to clear local storage and destroy current scope.
aRtoo
@artoodeeto
Aug 26 2017 23:59
@ehutchllew loop wont work because it will invoke addTogether(2)([3]); i tried console(arguments) it will give me 0: 2