These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Nov 2016
Joseph
@revisualize
Nov 23 2016 00:00 UTC
@domuttel No.
You're supposed to re-assign the result variable.
But, meh.
Dominic Muttel
@domuttel
Nov 23 2016 00:01 UTC
Oh I see then so I guess I gotta get more smarts together
lol
Joseph
@revisualize
Nov 23 2016 00:01 UTC
What's the point of doing this...
Dominic Muttel
@domuttel
Nov 23 2016 00:01 UTC
haha
Joseph
@revisualize
Nov 23 2016 00:01 UTC
result = thing.thinger;
return result;
Why not just do...
return thing.thinger;
Dominic Muttel
@domuttel
Nov 23 2016 00:02 UTC
As to have clear code?
Joseph
@revisualize
Nov 23 2016 00:02 UTC
The top one is not clearer than the bottom one.
Dominic Muttel
@domuttel
Nov 23 2016 00:03 UTC
Hmmmmm...
Joseph
@revisualize
Nov 23 2016 00:03 UTC
@domuttel Maybe it is clearer if the process was larger.
But, when you do returns the way the top one is done you have to go...
Dominic Muttel
@domuttel
Nov 23 2016 00:04 UTC
No I think I see what you are saying
Joseph
@revisualize
Nov 23 2016 00:04 UTC
Okay, we're returning result.. Let's look up and see what result is again.
Okay. That's result. So, that's we're returning that thing.
In a small block of code it is quite pointless.
Dominic Muttel
@domuttel
Nov 23 2016 00:05 UTC
I see
Joseph
@revisualize
Nov 23 2016 00:05 UTC
BUT! If you get into a function that calls another function .. Maybe it would be better.
Dominic Muttel
@domuttel
Nov 23 2016 00:05 UTC
Right! I totally see wat you are saying
tommy
@tommygebru
Nov 23 2016 00:06 UTC
Every challenge is a little different but we usually see/play around with the structure, variable assignment, etc. The setup isnt alway perfect and there are many ways to get a solution. With every challenge you get more insight and can probably get an answer cleaner, quicker, etc.
Joseph
@revisualize
Nov 23 2016 00:06 UTC
@tommygebru That's right.
You should see how I solved some of the challenges when I started working lessons.
I went back through and was all... Damn I did that the hard way.
I think for one challenge I took 20 lines of code down to 2.
Dominic Muttel
@domuttel
Nov 23 2016 00:07 UTC
Red light, Green light, refactor
Joseph
@revisualize
Nov 23 2016 00:07 UTC
Though... Seek and Destroy is still my original code.. I think.
Dominic Muttel
@domuttel
Nov 23 2016 00:08 UTC
hahahaha
Joseph
@revisualize
Nov 23 2016 00:08 UTC
Oh,.... I did refactor that one.
Dominic Muttel
@domuttel
Nov 23 2016 00:08 UTC
I dig
Joseph
@revisualize
Nov 23 2016 00:08 UTC
That challenge SUCKS!
Anyhow!
Dominic Muttel
@domuttel
Nov 23 2016 00:10 UTC
The one I was working on?
@revisualize
@dmcfaddengalway did you figure it out?
What problem are you working on?
SoteroX
@SoteroX
Nov 23 2016 00:12 UTC
having a problem with----Adding a default option in Switch statements
Dominic Muttel
@domuttel
Nov 23 2016 00:13 UTC
@dmcfaddengalway I work mine out on a text editor to double check stuff
Although I just got stumped
SoteroX
@SoteroX
Nov 23 2016 00:14 UTC

switch (val) {
case 1:
if (val === "a") {
answer = "apple";
}
break;
case 2:
if (val === "b") {
answer = "bird";
}
break;
case 3:
if (val === "c") {
answer = "cat";
}
break;

  default:
  answer = "stuff";

}

Yang Lu
@ylu01
Nov 23 2016 00:15 UTC
put the break in the if
SoteroX
@SoteroX
Nov 23 2016 00:15 UTC
try that already
Yang Lu
@ylu01
Nov 23 2016 00:15 UTC
actually no, you do case "a"
so the if is not necessary
SoteroX
@SoteroX
Nov 23 2016 00:17 UTC
yea that works, so the case value and the value im checking has to be the same type?
Yang Lu
@ylu01
Nov 23 2016 00:18 UTC
not in javascript no
everything is just a var, no ints, no chars, no bools etc
switch is just switch variable
saves a bunch of if statements
Caden Damiano
@cdomiano
Nov 23 2016 00:20 UTC

function slasher(arr, howMany) {
  var holderArray = [];
  var count = 0;

  for (i = count; i === 0; i++) {
     holderArray.splice(arr.slice(arr[0], howMany));

  }

  return holderArray;
}

slasher([1, 2, 3], 2);

//or for (i=count;i = arr.length, i++)
I'm doing the slasher flick bonfire in basic algorithm scripting. I think the middle paremeter to my 4 loop keeps it from running. Am
I right?
Daniel McFadden
@dmcfaddengalway
Nov 23 2016 00:21 UTC
@domuttel return lagest numbers in array
Stephen James
@sjames1958gm
Nov 23 2016 00:23 UTC
@cdomiano Yes, the test is false so the loop doesn't run. Are you sure you even need a loop?
Caden Damiano
@cdomiano
Nov 23 2016 00:24 UTC
I haven't considered it, I guess I wan't think straight after using loops for every challenge so far. What is a good direction to go? @sjames1958gm
Stephen James
@sjames1958gm
Nov 23 2016 00:26 UTC
@cdomiano If you read the docs on slice - a single slice will do the trick here
OleksandrNedobitkov
@OleksandrNedobitkov
Nov 23 2016 00:27 UTC
I have a problem with writing escape sequences
Caden Damiano
@cdomiano
Nov 23 2016 00:27 UTC
I just did, right direction? @sjames1958gm
function slasher(arr, howMany) {
  arr.slice(0, howMany);


  return arr;
}

slasher([1, 2, 3], 2);
It's not doing anything, do I need to splice it to array after slicing it?
Joseph
@revisualize
Nov 23 2016 00:28 UTC
@cdomiano Does slice modify the array in place?
Stephen James
@sjames1958gm
Nov 23 2016 00:28 UTC
@cdomiano some functions mutate the array, such as push, pop, etc. Some only return a new value.
Daria Doronina
@Skidle
Nov 23 2016 00:29 UTC
@cdomiano maybe you should return arr.slice(0, howMany); instead of just arr?
@cdomiano oh no I think I'm wrong
@cdomiano sorry
Dominic Muttel
@domuttel
Nov 23 2016 00:30 UTC
@dmcfaddengalway why dont you use a texteditor and the console?
that will def work with console.log();
Stephen James
@sjames1958gm
Nov 23 2016 00:32 UTC
@OleksandrNedobitkov What do you have so far
Caden Damiano
@cdomiano
Nov 23 2016 00:33 UTC
I'm not sure @revisualize It looks like it modifies the end of the array
function slasher(arr, howMany) {
 // arr.slice(0);
// arr= arr.splice()

  return arr.slice(0, howMany);//returns 1,2 not 3
}

slasher([1, 2, 3], 2);
Stephen James
@sjames1958gm
Nov 23 2016 00:33 UTC
@cdomiano You can use a site like repl.it or jsbin.com to experiment - or just open devtools console
@cdomiano So the first parameter is where to start the slice
Daria Doronina
@Skidle
Nov 23 2016 00:36 UTC
@cdomiano or you cant just use splice
Matt
@airborneprayer
Nov 23 2016 00:38 UTC
Hello world!
CamperBot
@camperbot
Nov 23 2016 00:38 UTC

welcome to FreeCodeCamp @airborneprayer!

TheMightyPingu
@TheMightyPingu
Nov 23 2016 00:38 UTC
I'm working on the tic tac toe project and i cant figure out how to make the X's and O's bigger in the html table im using as a playing board without the table itself becoming bigger, help?
Caden Damiano
@cdomiano
Nov 23 2016 00:39 UTC
function slasher(arr, howMany) {
 arr.slice(0);
arr= arr.splice(howMany);

  return arr
  ;
}

slasher([1, 2, 3], 2);
Haha thanks @Skidle @revisualize @sjames1958gm I was tweaking with the code and this suprised my by working. So let me get this right. So the use of slice dictated that I would cut off the first part of the array, then I reassigned what was left to redifine arr with the howMany argument. Did I butcher that?
CamperBot
@camperbot
Nov 23 2016 00:39 UTC
cdomiano sends brownie points to @skidle and @revisualize and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @skidle |http://www.freecodecamp.com/skidle
:star2: 4479 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2406 | @revisualize |http://www.freecodecamp.com/revisualize
Stephen James
@sjames1958gm
Nov 23 2016 00:40 UTC
@cdomiano arr.slice(0) returns the whole array - it does nothing to the arr variable.
Then arr.slice(howMany) sliced off the end which you stored in arr
Matt
@airborneprayer
Nov 23 2016 00:40 UTC
I'm new to this guys I need big time help.
Stephen James
@sjames1958gm
Nov 23 2016 00:40 UTC
This is the place for big time help :)
Emily Christensen
@emmalee113
Nov 23 2016 00:40 UTC
Hi! anyone able to take a look at this and help me figure out how to put the actual generated quote into the box? http://codepen.io/emmalee113/pen/WojpVY
Matt
@airborneprayer
Nov 23 2016 00:42 UTC
I'm wanting to know how to convert celsius to fahrenheit
//Age in minutes and seconds

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Yang Lu
@ylu01
Nov 23 2016 00:43 UTC
some people use api, i hard coded a bunch in @emmalee113
Daria Doronina
@Skidle
Nov 23 2016 00:44 UTC
@airborneprayer your var fahrenheit should equal celsius parameter * something something
@airborneprayer they have instructions for conversion in the task
Emily Christensen
@emmalee113
Nov 23 2016 00:44 UTC
@ylu01 if you look under the tan colored box, i have a generator which is showing quote1, quote 2, etc randomly. that part i have figured out. but how do i move that into the box where i have the text "quote"?
Johnny
@JohnnyBizzel
Nov 23 2016 00:44 UTC
@emmalee113 This is one way:
http://codepen.io/JohnnyBizzel/pen/QGvvob
Yang Lu
@ylu01
Nov 23 2016 00:45 UTC
@emmalee113 if the box is a div you can just next them in that
Stephen James
@sjames1958gm
Nov 23 2016 00:45 UTC
@emmalee113 Your HTML has a problem - it should be class="quotebox"
Then you can
document.querySelector(".quotebox").textContent = Quotation[whichQuotation]
Emily Christensen
@emmalee113
Nov 23 2016 00:46 UTC
@ylu01 nest all my javascript in the div?
@sjames1958gm would that simply go in my <h3> ?
Stephen James
@sjames1958gm
Nov 23 2016 00:47 UTC
@airborneprayer When the function is called (e.g. convertToF(30)) the variable/parameter celsius will contain the value to be converted (e.g. 30) you should use the provided conversion formula and this variable celsius to set the fahrenheit parameter
@emmalee113 yes
Steve
@marioecg
Nov 23 2016 00:49 UTC
Seek and Destroy bonfire, can anyone guide me please?
Johnny
@JohnnyBizzel
Nov 23 2016 00:49 UTC
@marioecg Filter out the unwanted numbers
Array.filter() method
Steve
@marioecg
Nov 23 2016 00:50 UTC
@JohnnyBizzel @lbg232 same as with the Falsy bonfire?
Johnny
@JohnnyBizzel
Nov 23 2016 00:50 UTC
@emmalee113 I would put a Div around the H3 you are putting the quote into. As suggested above.
@marioecg Can't remember that one sorry. - just checked. Yes that will work.
Steve
@marioecg
Nov 23 2016 00:51 UTC
@JohnnyBizzel thanks
CamperBot
@camperbot
Nov 23 2016 00:51 UTC
marioecg sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 848 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Aaron Bell
@awb715
Nov 23 2016 00:51 UTC
i dont understand .keys() at all
can someone help me udnerstand
Emily Christensen
@emmalee113
Nov 23 2016 00:52 UTC

@JohnnyBizzel so i have this:

<div>
<h3 class = quotebox>

quote

</h3>

</div>

Johnny
@JohnnyBizzel
Nov 23 2016 00:52 UTC
@emmalee113 Using an ID on the div you can control the style more easily. And also access it with jQuery
Steve
@marioecg
Nov 23 2016 00:53 UTC
@lbg232 thnks
@marioecg if you scroll up this chat I was working on it at 20:13 and somebody explained to me.
Dominic Muttel
@domuttel
Nov 23 2016 00:53 UTC
In: Testing Objects for Properties... Do I need a for loop?
Steve
@marioecg
Nov 23 2016 00:53 UTC
@lbg232 alright, thanks
CamperBot
@camperbot
Nov 23 2016 00:53 UTC
marioecg sends brownie points to @lbg232 :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @lbg232 |http://www.freecodecamp.com/lbg232
Dominic Muttel
@domuttel
Nov 23 2016 00:54 UTC
an if else should do- I think
function checkObj(checkProp) {
  // Your Code Here
  if ( checkProp !== true ) {
    return "Not Found";
  } else {
    return myObj[checkProp][0]; 
  }
}
Yang Lu
@ylu01
Nov 23 2016 00:58 UTC
@emmalee113 was helping my dad carrying stuff, your <style> stuff should go under the css part, the <p> tag that says quote, should be in a div which would be your box
Arnaud Casamé
@arnaudcasame
Nov 23 2016 00:58 UTC
@domuttel what's your query?
Moisés Man
@moigithub
Nov 23 2016 00:59 UTC
wonder why [0] at the end @domuttel
also probably u should use hasOwnProperty
this is mine
@domuttel
myObj.hasOwnProperty(...)
Emily Christensen
@emmalee113
Nov 23 2016 00:59 UTC
@ylu01 thanks ! I'm gonna take a deeper look at how you did yours. i was able to figure it out but want to see different ways
CamperBot
@camperbot
Nov 23 2016 00:59 UTC
emmalee113 sends brownie points to @ylu01 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ylu01
Yang Lu
@ylu01
Nov 23 2016 01:00 UTC
np
Joanna
@Joanna15
Nov 23 2016 01:00 UTC
Hello, it's first time when I'm writing here.. I would love to ask you about her with target 145 escape sequences in strings
Anthony Drane
@Antiaccess
Nov 23 2016 01:00 UTC
Can anyone tell me why this code isn't working for mouseup/mousedown in jQuery? It works in part, in that it toggles, but not on the same mouse-click
$("#g").on("mousedown", function() {
    $("#g").toggleClass('fullGreen');
}).on("mouseup", function() {
    $(this).toggleClass('n-green');
});
@ylu01 "China - Donald Tromp" X,DDD
tramp*
Anthony Drane
@Antiaccess
Nov 23 2016 01:00 UTC
Here's the codepen for anyone who can help
https://codepen.io/antiaccess/pen/wogRwp
Yang Lu
@ylu01
Nov 23 2016 01:00 UTC
@lbg232 trump*
Anthony Drane
@Antiaccess
Nov 23 2016 01:01 UTC
try clicking on green
ADIL KARMOUZI
@mradil16
Nov 23 2016 01:02 UTC
Hi everyone. I just finished a javascript beginner guide. Honestly , I don't know how to use that syntax all in one piece like this guy did :
// Set the number of snowflakes (more than 30 - 40 not recommended)
var snowmax=35

// Set the colors for the snow. Add as many colors as you like
var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD")

// Set the fonts, that create the snowflakes. Add as many fonts as you like
var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS")

// Set the letter that creates your snowflake (recommended:*)
var snowletter="*"

// Set the speed of sinking (recommended values range from 0.3 to 2)
var sinkspeed=0.6

// Set the maximal-size of your snowflaxes
var snowmaxsize=22

// Set the minimal-size of your snowflaxes
var snowminsize=8

// Set the snowing-zone
// Set 1 for all-over-snowing, set 2 for left-side-snowing 
// Set 3 for center-snowing, set 4 for right-side-snowing
var snowingzone=3

///////////////////////////////////////////////////////////////////////////
// CONFIGURATION ENDS HERE
///////////////////////////////////////////////////////////////////////////


// Do not edit below this line
var snow=new Array()
var marginbottom
var marginright
var timer
var i_snow=0
var x_mv=new Array();
var crds=new Array();
var lftrght=new Array();
var browserinfos=navigator.userAgent 
var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/)
var ns6=document.getElementById&&!document.all
var opera=browserinfos.match(/Opera/)  
var browserok=ie5||ns6||opera

function randommaker(range) {        
    rand=Math.floor(range*Math.random())
    return rand
}

function initsnow() {
    if (ie5 || opera) {
        marginbottom = document.body.clientHeight
        marginright = document.body.clientWidth
    }
    else if (ns6) {
        marginbottom = window.innerHeight
        marginright = window.innerWidth
    }
    var snowsizerange=snowmaxsize-snowminsize
    for (i=0;i<=snowmax;i++) {
        crds[i] = 0;                      
        lftrght[i] = Math.random()*15;         
        x_mv[i] = 0.03 + Math.random()/10;
        snow[i]=document.getElementById("s"+i)
        snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)]
        snow[i].size=randommaker(snowsizerange)+snowminsize
        snow[i].style.fontSize=snow[i].size
        snow[i].style.color=snowcolor[randommaker(snowcolor.length)]
        snow[i].sink=sinkspeed*snow[i].size/5
        if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
        if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
        if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
        if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
        snow[i].posy=randommaker(2*marginbottom-marginbottom-2*snow[i].size)
        snow[i].style.left=snow[i].posx
        snow[i].style.top=snow[i].posy
    }
    movesnow()
}

function movesnow() {
    for (i=0;i<=snowmax;i++) {
        crds[i] += x_mv[i];
        snow[i].posy+=snow[i].sink
        snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]);
        snow[i].style.top=snow[i].posy

        if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
            if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)}
            if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)}
            if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4}
            if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2}
            snow[i].posy=0
        }
    }
    var timer=setTimeout("movesnow()",50)
}

for (i=0;i<=snowmax;i++) {
    document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
}
if (browserok) {
    window.onload=initsnow
}
JacobY
@jyelton4
Nov 23 2016 01:02 UTC
looking for some assistance on this js challenge
Dominic Muttel
@domuttel
Nov 23 2016 01:03 UTC
@lbg232 Do I need a if else?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:03 UTC
@Antiaccess Your this might be out of scope
JacobY
@jyelton4
Nov 23 2016 01:04 UTC
I can't get past the 'no global myVar variable' test
tommy
@tommygebru
Nov 23 2016 01:06 UTC
@revisualize yeah same here and my front-end html/css was horrible too :smile:
Walid Ashri
@walidashri
Nov 23 2016 01:07 UTC
@jyelton4 your code please
@Joanna15 what is the issue?
JacobY
@jyelton4
Nov 23 2016 01:08 UTC
@walidashri I just needed to refresh apparently, code was correct
Walid Ashri
@walidashri
Nov 23 2016 01:08 UTC
@jyelton4 :) :+1:
Richie
@Richie2
Nov 23 2016 01:09 UTC
Hello campers
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:10 UTC
Can anybody explain to me why this returns false?
function truthCheck(collection, pre) {
  // Is everyone being true?
  for (var element in collection) {
    if (!collection[element].hasOwnProperty(pre)) {
      return false;
    }
    if (collection[element].pre === undefined) {
      return false;
    }
  }
  return true;
}

truthCheck([{"single": "yes"}], "single");
Walid Ashri
@walidashri
Nov 23 2016 01:10 UTC
Hello Rich :)
Dominic Muttel
@domuttel
Nov 23 2016 01:10 UTC

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  myObj.hasOwnPropery(checkProp);
  if (true){
        return 
      } else {
        return "Not Found";
      }
  }


// Test your code by modifying these values
checkObj("gift");
am I meant to pass checkProp to hasOwnProperty
lowcities
@lowcities
Nov 23 2016 01:11 UTC
Hey everyone, Im working on the algorithm challenge where you push the largest number from a two dimensional array to a new array. My code seems to do that but it repeats each number 3 times. Can someone give me a hint at what I did wrong?
Much Appreciated!
                                                                                                                                                                                                                                                                 function largestOfFour(arr) {
  // You can do this!
  var array= [];

  for(i = 0; i < arr.length; i ++){
   for(j = 0; j < arr[i].length; j ++){
      array.push(Math.max.apply(Math,arr[j]));

   }


  }

  return array;

}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Richie
@Richie2
Nov 23 2016 01:11 UTC
Hi Walid :smile:
Walid Ashri
@walidashri
Nov 23 2016 01:12 UTC
@BrennanGlynn cauze all the time this is true collection[element].pre === undefined)
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:12 UTC
@walidashri mhhhhh thanks haha
CamperBot
@camperbot
Nov 23 2016 01:12 UTC
brennanglynn sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 672 | @walidashri |http://www.freecodecamp.com/walidashri
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:12 UTC
@Antiaccess It works fine for me
Joanna
@Joanna15
Nov 23 2016 01:12 UTC
Basically myStr should have encoded text and two correctly escaped backslashes characters. It looks like that now: var myStr = 'First \tLine\n\"second \tLine\"\rThird\tLine';
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:13 UTC
How do you check for all the values like null undefined NaN etc...?
Richie
@Richie2
Nov 23 2016 01:14 UTC
@BrennanGlynn try stepping through with debugger; then you can see actually happen
Moisés Man
@moigithub
Nov 23 2016 01:14 UTC
no inner quotes or tabs needed... also check correct case on ur words (Second.. with uppercase S ) @Joanna15
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:14 UTC
@Richie2 do I have to code in a seperate program to do that?
Richie
@Richie2
Nov 23 2016 01:15 UTC
@BrennanGlynn no, you don’t type in debugger; on the line before the for loop, then open up the console log
@BrennanGlynn I will cheack youtube for you
lots to go on there for you.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:18 UTC
@domuttel hasOwnProperty() is a method that returns true if the property is found in the object you're searching it. So you should put the whole statement myObj.hasOwnProperty(checkProp) inside the if statement.
Joanna
@Joanna15
Nov 23 2016 01:19 UTC
It still doesn't work..
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:19 UTC
Hi everyone. I want to get some help with an algorithms problem. How do you put code blocks in the chat to show your code? Is it 3 backticks?
lowcities
@lowcities
Nov 23 2016 01:20 UTC
@OsakaStarbux Yes 3 tick before code then 3 ticks after
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:20 UTC
thanks!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:20 UTC
@OsakaStarbux 3 backticks before the code, 3 backticks after
coffeebeanzz
@coffeebeanzz
Nov 23 2016 01:20 UTC
'''
CamperBot
@camperbot
Nov 23 2016 01:20 UTC
:bulb: to format code use backticks! ``` more info
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:21 UTC

```function palindrome(str) {
// Good luck!
// strip all non alphanumeric chars
var regex = new RegExp('/[^0-9A-Za-z]','g');
str = str.replace(regex,'');
// downcase
str = str.toLowerCase();
// split into array
var currentStringArray = str.split('');
// join into string
var oldString = currentStringArray.join('');
// reverse and join into string
var reversed = currentStringArray.reverse().join('');
// check if array and reversed array are equal
return oldString == reversed;
}

palindrome("eye"); ```

oops
coffeebeanzz
@coffeebeanzz
Nov 23 2016 01:21 UTC
The backticks have to be on their own lines
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:21 UTC
sorry
coffeebeanzz
@coffeebeanzz
Nov 23 2016 01:21 UTC
Np
lowcities
@lowcities
Nov 23 2016 01:21 UTC
@OsakaStarbux press shift +enter to do a line break after ticks
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:22 UTC
ha! my next question
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:22 UTC
No problem @OsakaStarbux . Try again
lowcities
@lowcities
Nov 23 2016 01:22 UTC
Does anyone have any advice for me? I posted some code further up the chat
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:24 UTC
function palindrome(str) {
  // Good luck!
  // strip all non alphanumeric chars
  var regex = new RegExp('/[^0-9A-Za-z]','g');
  str = str.replace(regex,'');
  // downcase
  str = str.toLowerCase();
  // split into array
  var currentStringArray = str.split('');
  // join into string
  var oldString = currentStringArray.join('');
  // reverse and join into string
  var reversed = currentStringArray.reverse().join('');
  // check if array and reversed array are equal
  return oldString == reversed;
}



palindrome("eye");
Joe Narvaez
@wordyallen
Nov 23 2016 01:25 UTC
I'm trying to create an array of objects, I feel like I'm missing somethign simple here:
[1,2,3].map(n=>{num: n})
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:25 UTC
I'm guessing my regex might be wrong but..
Walid Ashri
@walidashri
Nov 23 2016 01:25 UTC
@lowcities you need only one loop
Anthony Drane
@Antiaccess
Nov 23 2016 01:25 UTC
@djcase001 thanks for replying. I wonder why it would work for you and not me
CamperBot
@camperbot
Nov 23 2016 01:25 UTC
antiaccess sends brownie points to @djcase001 :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @djcase001 |http://www.freecodecamp.com/djcase001
Joe Narvaez
@wordyallen
Nov 23 2016 01:26 UTC
[1,2,3].map(n=>{num: n}) this returns an array of undefined
lowcities
@lowcities
Nov 23 2016 01:26 UTC
@walidashri Ahh OK, I'll try that, Thanks!
CamperBot
@camperbot
Nov 23 2016 01:26 UTC
lowcities sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 673 | @walidashri |http://www.freecodecamp.com/walidashri
Anthony Drane
@Antiaccess
Nov 23 2016 01:27 UTC
@djcase001 it also doesn't work in another browser for me
@djcase001 clicks between light green, transparent and the normal green
on the down press of the mouse it's supposed to go light green, lift-off the mouse and it goes back to green
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:27 UTC
@Antiaccess it probably worked for you but it happened so fast
I tried it on my own
Anthony Drane
@Antiaccess
Nov 23 2016 01:28 UTC
@djcase001 no, it stays solid light-green
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:28 UTC
OK I'm gonna check your codepen to see what the problem is
Aaron Bell
@awb715
Nov 23 2016 01:28 UTC
im working on where art thou and i got stuck here

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var hold = (Object.keys(source));// this is creates array of the property names from source
  console.log(hold);
  console.log(source[hold]);//this can show the values of the object propertys

  for (i=0;i<collection.length;i++) {
    console.log(collection[i][hold]);//logs value of 
if ( collection[i].hasOwnProperty(hold) && collection[i][hold]==source[hold]){
 arr.push(collection[i]);

} else {
  console.log(false);
 }
}


  // Only change code above this line
  return arr;
}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
MoNag1
@MoNag1
Nov 23 2016 01:28 UTC
@lowcities yea you can just use 1 loop to loop through all 4 sub arrays and return the largest number from each sub array as you did using Math.max.apply()
Anthony Drane
@Antiaccess
Nov 23 2016 01:29 UTC
@djcase001 thanks
CamperBot
@camperbot
Nov 23 2016 01:29 UTC
:warning: antiaccess already gave djcase001 points
antiaccess sends brownie points to @djcase001 :sparkles: :thumbsup: :sparkles:
Aaron Bell
@awb715
Nov 23 2016 01:29 UTC
ive read about a for in while loop, is that something i need to use
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:29 UTC
Send me your codepen
Adress
Aaron Bell
@awb715
Nov 23 2016 01:29 UTC
me?
lowcities
@lowcities
Nov 23 2016 01:30 UTC
@MoNag1 Yup, that does it, Thanks!
CamperBot
@camperbot
Nov 23 2016 01:30 UTC
lowcities sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @monag1 |http://www.freecodecamp.com/monag1
Walid Ashri
@walidashri
Nov 23 2016 01:31 UTC
@wordyallen [1,2,3].map(n=>{return{'num': n}})
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:33 UTC
thanks @coffeebeanzz
CamperBot
@camperbot
Nov 23 2016 01:33 UTC
osakastarbux sends brownie points to @coffeebeanzz :sparkles: :thumbsup: :sparkles:
:star2: 1303 | @coffeebeanzz |http://www.freecodecamp.com/coffeebeanzz
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:33 UTC
thanks @lowcities
CamperBot
@camperbot
Nov 23 2016 01:33 UTC
osakastarbux sends brownie points to @lowcities :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @lowcities |http://www.freecodecamp.com/lowcities
Richie
@Richie2
Nov 23 2016 01:33 UTC
@BrennanGlynn After you run the code with debugger; the program will stop and you can step trough the code. This link gives the commands you can use to step through. https://developers.google.com/web/tools/chrome-devtools/javascript/step-code
Aaron Bell
@awb715
Nov 23 2016 01:33 UTC
@walidashri did you see my code
Joanna
@Joanna15
Nov 23 2016 01:38 UTC
var myStr ="\FirstLine\n\SecondLine\rThirdLine\";
145 target... myStr looks like above but unfortunately i still don't have any idea how to encoded this text..
please help
Coy Sanders
@coymeetsworld
Nov 23 2016 01:41 UTC
whats the challenge name @Joanna15? the number is just your brownie points the challenges aren't numbered
@joehesse you have spacing issues
there should only be one space between the end of the first sentence and beginning of the second,
you have 3 spaces between the sentences, it needs to be exactly one
like a sentence would be in English
Joanna
@Joanna15
Nov 23 2016 01:45 UTC
Escape sequences in strings
Dominic Muttel
@domuttel
Nov 23 2016 01:45 UTC
@djcase001
```
jrr5230
@jrr5230
Nov 23 2016 01:46 UTC
@Joanna15 Follow the test with the escape sequences: “FirstLine newline backslash SecondLine backslash carriage-return ThirdLine”
So look at the table and correlate each code with the output
Dominic Muttel
@domuttel
Nov 23 2016 01:46 UTC
@djcase001
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp) === true){
    return myObj[checkProp][];
  } else {
    return "Not Found";
  }  
}

// Test your code by modifying these values
checkObj("guf");
Is this syntax correct?
Coy Sanders
@coymeetsworld
Nov 23 2016 01:46 UTC
@Joanna15 yeah what @jrr5230 said
CamperBot
@camperbot
Nov 23 2016 01:47 UTC
joehesse sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1561 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Nov 23 2016 01:47 UTC
@joehesse remove the space at the end of the last sentence and I think it'll be ok
Dominic Muttel
@domuttel
Nov 23 2016 01:48 UTC
Im struggling with how to show the value in an objects list of name value pairs
Walid Ashri
@walidashri
Nov 23 2016 01:48 UTC
@awb715 you need to loop through hold items it's an array
Joanna
@Joanna15
Nov 23 2016 01:48 UTC
The point is that everything is correct but text is still coded
Coy Sanders
@coymeetsworld
Nov 23 2016 01:49 UTC
@domuttel your return statement if you find the property doesn't look right
jrr5230
@jrr5230
Nov 23 2016 01:49 UTC
@domuttel if .hasOwnProperty finds the property it should already set it to true. So no need for the (=== true condition).
Coy Sanders
@coymeetsworld
Nov 23 2016 01:49 UTC
@Joanna15 no theres some problems with your string
Dominic Muttel
@domuttel
Nov 23 2016 01:49 UTC
function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty(checkProp) === true){
    return myObj[checkProp];
  } else {
    return "Not Found";
  }  
}
Coy Sanders
@coymeetsworld
Nov 23 2016 01:49 UTC
for example you don't need backslashes at the beginning or end of the sentence
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:50 UTC
Hello,
I've found bug in Chunky Monkey course.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:50 UTC
take that line and replace the words like newline with its code in the table above
Joanna
@Joanna15
Nov 23 2016 01:50 UTC
I've got it thank you..
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:50 UTC
The result is correct, but i can't pass the course.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:51 UTC
nothing more or less
Spencer Kuzara
@kodaxx
Nov 23 2016 01:51 UTC
Anyone skilled with node.js in here?
Coy Sanders
@coymeetsworld
Nov 23 2016 01:51 UTC
ok
jrr5230
@jrr5230
Nov 23 2016 01:51 UTC
@Joanna15 to encode your text use three backticks (```) (Then press Shift + Enter) (Copy and Paste your code)(Then end with three backticks again)
Chang
@chhuang
Nov 23 2016 01:51 UTC
Hello, can someone help me with this:
var hi =  ‘hello!’;
document.addEventListener(‘input’, function() { 
  debugger;   // why I don’t have access to hi here?
  console.log(hi);   // but this works fine?
});
Coy Sanders
@coymeetsworld
Nov 23 2016 01:51 UTC
@domuttel looks better but like @jrr5230 said you don't need the === operator, hasOwnProperty returns a true/false value
jrr5230
@jrr5230
Nov 23 2016 01:51 UTC
@domuttel were you able to pass that lesson with your code?
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:51 UTC

let boo = [];
function chunkArrayInGroups(arr, size) {
// Break it up.
if (arr.length === 0) {
return boo;
}
else if (arr.length < size) {
boo.push(arr.slice(0,size));
return boo;
}
boo.push(arr.slice(0,size));

return chunkArrayInGroups(arr.splice(size),size);
}

The code is as above.
and the result is ok
but i always get x signals in all instructions.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:52 UTC
@AndreiLuca99 you can't have global variables in the challenges unless they explicitly give them to you
it messes up the tests and also its generally bad practice to have them
you don't need recursion to solve this problem
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:53 UTC
Then how can i solve this problem?
I just need to use global variables
Coy Sanders
@coymeetsworld
Nov 23 2016 01:54 UTC
you dont need global variables to solve this
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:54 UTC
if not, it's complicated to finish this one.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:54 UTC
try using a for loop instead of recursion to iterate through the array
Walid Ashri
@walidashri
Nov 23 2016 01:55 UTC
@chhuang are you sure of this quotes? ‘input’ ‘hello!’;
Matt
@Matteoo7
Nov 23 2016 01:57 UTC
@kodaxx I'm not, but a lot of the folks here https://gitter.im/nodejs/node are
Chang
@chhuang
Nov 23 2016 01:57 UTC
@walidashri yep
DestroyingLight
@DestroyingLight
Nov 23 2016 02:02 UTC
How bad is this?
function findLongestWord(str) {

  var strArray = str.split(' ');
  var longest = strArray.reduce(function(accu, curr){
    if(curr.length >= accu.length){
      return curr;
    } else{
      return accu;
    }
  });

  return longest.length;

}
Coy Sanders
@coymeetsworld
Nov 23 2016 02:04 UTC
looks ok to me at first glance @DestroyingLight, is there a problem with it
DestroyingLight
@DestroyingLight
Nov 23 2016 02:05 UTC
it works, but in terms of style, can it be done better?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:05 UTC
may want to consider using the variable prev instead of accu as that is the nomenclature
also you could use a ternary operator to compact the if/else statement
another thing is you can do this without creating either variable strArray or longest
and lastly you can use ES6 arrow functions
DestroyingLight
@DestroyingLight
Nov 23 2016 02:07 UTC
curr.length >= accu.length ? curr : accu
like that?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:08 UTC
think you need the return statement still
but you can put it at the beginning once
DestroyingLight
@DestroyingLight
Nov 23 2016 02:10 UTC
I think my last message could not be sent
how can i use ES6 syntax on the FCC parser ?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:10 UTC
i think it just works
DestroyingLight
@DestroyingLight
Nov 23 2016 02:11 UTC
it shows me warnings
chazztizer
@chazztizer
Nov 23 2016 02:11 UTC

I'm having a hard time understanding the mechanics of ===-1 and what it is doing.Can anyone eli5 this for me? Sorry and thanks!

function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);
args.splice(0, 1);
return arr.filter(function(element) {
return args.indexOf(element) === -1;
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

DestroyingLight
@DestroyingLight
Nov 23 2016 02:12 UTC
blob
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12 UTC
warnings aren't a big deal
DestroyingLight
@DestroyingLight
Nov 23 2016 02:12 UTC
can you see it there?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12 UTC
im not sure how to clear that because i didn't use any es6 first time around doing the challenges
Stephen James
@sjames1958gm
Nov 23 2016 02:12 UTC
@chazztizer indexOf returns -1 when it cannot find element in args
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12 UTC
yeah im trying it now
Walid Ashri
@walidashri
Nov 23 2016 02:12 UTC
@chhuang it's not valid :)
Stephen James
@sjames1958gm
Nov 23 2016 02:13 UTC
@chazztizer Since you want to keep elements that don't match the remaining args -1 would mean that.
Chang
@chhuang
Nov 23 2016 02:13 UTC
@walidashri what is not valid?
chazztizer
@chazztizer
Nov 23 2016 02:14 UTC
@sjames1958gm So arr is being returned, but is filtering out the "element" of args?
Walid Ashri
@walidashri
Nov 23 2016 02:14 UTC
@chhuang the qoutes it's " or '
@DestroyingLight add 'jshint esversion:6' as 1st line in ur code
Chang
@chhuang
Nov 23 2016 02:15 UTC
sorry I may have put in the wrong quote, but the problem is not the quote
Stephen James
@sjames1958gm
Nov 23 2016 02:15 UTC
@chazztizer If the element is not in args indexOf returns -1 and the function returns true which keeps element, if the element is in args then indexOf returns index and the functin returns false and drops the element
chazztizer
@chazztizer
Nov 23 2016 02:17 UTC
@sjames1958gm Maybe i'm just dumb. Thanks though
CamperBot
@camperbot
Nov 23 2016 02:17 UTC
chazztizer sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4480 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Walid Ashri
@walidashri
Nov 23 2016 02:17 UTC
@chhuang did u test the input if you try to type in the debugger should be triggered
@sjames1958gm Hello My Mentor, thanks
CamperBot
@camperbot
Nov 23 2016 02:18 UTC
walidashri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 23 2016 02:18 UTC
@DestroyingLight
return str.split(' ').reduce((accu, curr) => accu > curr.length ? accu : curr.length, 0);
CamperBot
@camperbot
Nov 23 2016 02:18 UTC
:star2: 4481 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 23 2016 02:18 UTC
@walidashri Hello -
DestroyingLight
@DestroyingLight
Nov 23 2016 02:20 UTC
@walidashri I'm not getting it to work
@sjames1958gm I was doing something similar now
function findLongestWord(str) {

  const longest = str.split(' ').reduce( (accu, curr) => curr.length >= accu.length ? curr : accu);

  return longest.length;

}
it seems to pass the challenge
Moisés Man
@moigithub
Nov 23 2016 02:23 UTC
return str.split(" ").sort().shift().length;
DestroyingLight
@DestroyingLight
Nov 23 2016 02:25 UTC
@moigithub that sorts a alphabetically
I think
Moisés Man
@moigithub
Nov 23 2016 02:25 UTC
yea.. probably need a callback on sort...
.sort((a,b)=>a.length-b.length)
DestroyingLight
@DestroyingLight
Nov 23 2016 02:26 UTC
something I'm stuck between trying to make code pure, brief, with the least variables possible, AND making it readable
sometimes*
Walid Ashri
@walidashri
Nov 23 2016 02:28 UTC
@DestroyingLight /*jshint esversion: 6 */
DestroyingLight
@DestroyingLight
Nov 23 2016 02:28 UTC
thanks @walidashri ! no warnings now
CamperBot
@camperbot
Nov 23 2016 02:28 UTC
destroyinglight sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 674 | @walidashri |http://www.freecodecamp.com/walidashri
Luis Felipe López G.
@luishendrix92
Nov 23 2016 02:36 UTC
@DestroyingLight const findLongestWord = str => Math.max(...str.split(' ').map(w => w.length))
Dominic Muttel
@domuttel
Nov 23 2016 02:36 UTC
Can someone explain Record Collection to me a bit more then they have written?
I take it when given the parameters are passed I have to add information provided to the obj
Dominic Muttel
@domuttel
Nov 23 2016 02:42 UTC
Am I meant to update the object before I start?
Chang
@chhuang
Nov 23 2016 02:43 UTC
@walidashri https://jsfiddle.net/pe46d6tp/1/ you can try it in there
Terryd12345
@Terryd12345
Nov 23 2016 02:44 UTC
hey has anyone done smallest common multiple in the intermediate javascript scripting section that can help me out?
__mifflin__
@cdrainxv
Nov 23 2016 02:45 UTC
@walidashri: Overkill, no? :point_up: November 22, 2016 7:28 PM Single line comment //. Come and join us at the lazy table. :smile:
c0d0er
@c0d0er
Nov 23 2016 02:46 UTC
@walidashri thanks!
CamperBot
@camperbot
Nov 23 2016 02:46 UTC
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 675 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Nov 23 2016 02:47 UTC
@cdrainxv shut up
blob
@chhuang
yoojuu
@yoojuu
Nov 23 2016 02:48 UTC
Screen Shot 2016-11-22 at 9.46.11 PM.png
Hi! I was wondering why I couldn't do return checkProp[myObj]; in the function to get the same result
Chang
@chhuang
Nov 23 2016 02:48 UTC
@walidashri so my question is why is the animal variable not defined when you comment the console.log line out?
Terryd12345
@Terryd12345
Nov 23 2016 02:48 UTC
@domuttel It wants you to write a function that takes some inputs and checks some parameters in the JSON file which will then update the JSON file
Dominic Muttel
@domuttel
Nov 23 2016 02:49 UTC
@Terryd12345 OK so this will take a bit of work!
Terryd12345
@Terryd12345
Nov 23 2016 02:50 UTC
@domuttel Yeah the way its written is a bit confusing but basically just use some if/else statements to check the conditions and then put the correct info in if its true
Emerson
@DikoFaji
Nov 23 2016 02:51 UTC
how can i use the function inside an argument??
function findElement(arr, func) {

  var num = 4;
  return func;
}

findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });
Arnaud Casamé
@arnaudcasame
Nov 23 2016 02:52 UTC
@DikoFaji by its name
Dominic Muttel
@domuttel
Nov 23 2016 02:52 UTC
^ assign it to a variable?
:|
Moisés Man
@moigithub
Nov 23 2016 02:52 UTC
to CALL a function add a set of () at the end of its name
Emerson
@DikoFaji
Nov 23 2016 02:53 UTC
@djcase001 in challenge Finders Keepers the function is set in the var func
yes it is assigned in the variable, and i know that to call function is thru its name. i just wonder in this challenge why the function is assigned in var func?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 02:56 UTC
@DikoFaji you gotta use a built-in JS function in this exercise
Emerson
@DikoFaji
Nov 23 2016 02:57 UTC
and i thought that by returning the var func will run the function. but not
alex_wang
@wangzhenalex
Nov 23 2016 02:57 UTC
How to make a regular expression matching Symbol “:” in JavaScript
Arnaud Casamé
@arnaudcasame
Nov 23 2016 02:58 UTC
@DikoFaji go take a look back at the built-in array methods
Walid Ashri
@walidashri
Nov 23 2016 03:00 UTC
@chhuang debugger issue
Emerson
@DikoFaji
Nov 23 2016 03:01 UTC
@djcase001 my question now is why is the function is placed in argument func?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:02 UTC
@DikoFaji it is a callback function that executes once you call the main function
Alejandro Tejada
@wannabecoding
Nov 23 2016 03:04 UTC
Any guidance on counting cards?
var count = 0;

function cc(card) {
  // Only change code below this line
  count = 0;
  var answer = "" ;
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      answer = count++ + " Bet";
      break;
    case 7:
    case 8:
    case 9:
      answer = count + " Hold";
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      answer = count-- + " Hold";
      break;
  }
    return count;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
changed bottom to return answer;
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:06 UTC
@DikoFaji in this exercise, the callback function has to filter the array and get the number that matches the condition of the call
jrr5230
@jrr5230
Nov 23 2016 03:06 UTC
@wannabecoding count ++ and count -- go in separate lines. The break statement by itself should suffice for the middle three cases
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:06 UTC
@wannabecoding I'd use an if statement instead
Emerson
@DikoFaji
Nov 23 2016 03:07 UTC
@djcase001 i think im getting it. ok ill try first
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:08 UTC
@DikoFaji ok bro
Alejandro Tejada
@wannabecoding
Nov 23 2016 03:10 UTC
@jrr5230 Don't I have the count++ and count-- in separate lines?
@djcase001 I'll try the if statement, might be easier
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:11 UTC
@wannabecoding definitely much easier
@wannabecoding
```
@wannabecoding
if(card >= 2 && card <= 6){
     // your logic
}
jrr5230
@jrr5230
Nov 23 2016 03:14 UTC
@wannabecoding nah...it'll be like count ++;
count--;
KT
@Krystinet
Nov 23 2016 03:15 UTC
Hello! I cannot seem to get the "Stand in line" code correct
I have gone back to the earlier lessons and I am just completely lost on this section
jrr5230
@jrr5230
Nov 23 2016 03:15 UTC
then answer = count + string
MoNag1
@MoNag1
Nov 23 2016 03:15 UTC
@Krystinet let us see what you have so far or at least what you tried
Chang
@chhuang
Nov 23 2016 03:15 UTC
@walidashri thanks!
CamperBot
@camperbot
Nov 23 2016 03:15 UTC
chhuang sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 676 | @walidashri |http://www.freecodecamp.com/walidashri
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:15 UTC
@Krystinet tell me more
KT
@Krystinet
Nov 23 2016 03:16 UTC
@MoNag1 @djcase001 just logged back in after several days and I have not saved my code
Sorry, I know that's not helpful
first time on the chat
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:17 UTC
@Krystinet Ok. So you'll have to rewrite it . I'll help you
MoNag1
@MoNag1
Nov 23 2016 03:17 UTC
@Krystinet ok, you understand that it's asking you to first push something called item into your array arr, then remove the first element of arr
KT
@Krystinet
Nov 23 2016 03:17 UTC
yes
MoNag1
@MoNag1
Nov 23 2016 03:18 UTC
okay so we can break it down into 2 steps, lets worry about the push part first. Do you know of any method to push an item into an array?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:18 UTC
@Krystinet what challenge is it??
KT
@Krystinet
Nov 23 2016 03:18 UTC
so arr.push(item)?
@djcase001 stand in line
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:19 UTC
basic, intermediate or Advanced
MoNag1
@MoNag1
Nov 23 2016 03:19 UTC
@Krystinet yep, that's the first step done already
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:19 UTC
???
KT
@Krystinet
Nov 23 2016 03:19 UTC
right
MoNag1
@MoNag1
Nov 23 2016 03:19 UTC
@djcase001 i believe its under basic javascript?
KT
@Krystinet
Nov 23 2016 03:19 UTC
Yes javascript
MoNag1
@MoNag1
Nov 23 2016 03:20 UTC
@Krystinet ok next you need to find a way to remove the first element of an array, do you know any way that could be done?
KT
@Krystinet
Nov 23 2016 03:20 UTC
.pop
MoNag1
@MoNag1
Nov 23 2016 03:21 UTC
@Krystinet close, pop removes last element
what you're looking for is shift
KT
@Krystinet
Nov 23 2016 03:21 UTC
Right!
(sorry I did those sections twice but haven't gone back in about a week!)
MoNag1
@MoNag1
Nov 23 2016 03:22 UTC
dw we all forget, do you know how you can apply .shift()?
KT
@Krystinet
Nov 23 2016 03:23 UTC
variableName.shift()?
Joseph
@revisualize
Nov 23 2016 03:24 UTC

@cdomiano Here is the code that you posted:

function slasher(arr, howMany) {
 arr.slice(0);
arr= arr.splice(howMany);

  return arr
  ;
}

Let's evaluate

function slasher(arr, howMany) {
 arr.slice(0);          // this does nothing. So, it isn't needed.
arr= arr.splice(howMany);
                        // assigning a thinger to a thing just to return the thing is pointless.
  return arr
  ;
}

So, we can refactor all of that to...

function slasher(arr, howMany) {
  return arr.splice(howMany);
}

But, that's just my thoughts. I could be wrong.
const slasher = (a, h) => a.splice(h);

Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:24 UTC
@MoNag1 @Krystinet you have to use two array methods to solve this problem
Joseph
@revisualize
Nov 23 2016 03:24 UTC
grrrrr.
MoNag1
@MoNag1
Nov 23 2016 03:24 UTC
@Krystinet yep, and your variable name is arr, so do that
Joseph
@revisualize
Nov 23 2016 03:25 UTC
There.
MoNag1
@MoNag1
Nov 23 2016 03:25 UTC
@djcase001 yea .push() and .shift()
Joseph
@revisualize
Nov 23 2016 03:25 UTC
@cdomiano ------^^^^^^ :D
KT
@Krystinet
Nov 23 2016 03:25 UTC
@MoNag1 @djcase001 arr.shift()
arr.push()
so that part I understand
Joseph
@revisualize
Nov 23 2016 03:26 UTC
@Krystinet You have it backwards.
KT
@Krystinet
Nov 23 2016 03:26 UTC
Okay
Joseph
@revisualize
Nov 23 2016 03:26 UTC

https://gist.github.com/revisualize/ced4a3a6611c6c74bcab34a07eaa4ebf
Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.
....

var name = function() { return "Joseph"; }

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The pop() method removes the last element from an array and returns that element.

The shift() method removes the first element from an array and returns that element.

The unshift() method adds one or more elements to the beginning of an array and returns the new length of the array.

MoNag1
@MoNag1
Nov 23 2016 03:28 UTC
@Krystinet alright send your code knowing what you know now
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:28 UTC
@Krystinet first push the item, and then shift the array into item
Joseph
@revisualize
Nov 23 2016 03:28 UTC
But, you know.. meh.
KT
@Krystinet
Nov 23 2016 03:32 UTC
Do I have to set arr and item to something?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:33 UTC
@Krystinet
Joseph
@revisualize
Nov 23 2016 03:33 UTC
@Krystinet No.
@Krystinet They are parameters.
You know.. That big block of text that I just posted. With images ans stuff.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:34 UTC
@revisualize loll
KT
@Krystinet
Nov 23 2016 03:35 UTC
sorry guys, im really being dense on this one

function nextInLine(arr, item) {
// Your code here
arr.push();
item.shift();
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Joseph
@revisualize
Nov 23 2016 03:35 UTC
@Krystinet item isn't an array.
MoNag1
@MoNag1
Nov 23 2016 03:35 UTC
@Krystinet you should shift arr and not item
Joseph
@revisualize
Nov 23 2016 03:36 UTC
@Krystinet function nextInLine which has two parameters an array (arr) and a number (item).
MoNag1
@MoNag1
Nov 23 2016 03:36 UTC
@Krystinet also, you will need a place to store the new array after the first item has been removed
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:37 UTC
@Krystinet
item = arr.shift()
KT
@Krystinet
Nov 23 2016 03:37 UTC

function nextInLine(arr, item) {
// Your code here
arr.shift();
arr.push();
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Joseph
@revisualize
Nov 23 2016 03:38 UTC
@Krystinet Why did you change the order?
KT
@Krystinet
Nov 23 2016 03:38 UTC
Ahhh
I DONT KNOW
jrr5230
@jrr5230
Nov 23 2016 03:38 UTC
@Krystinet I think you should take the time to understand the whole block of info that @revisualize posted :)
Joseph
@revisualize
Nov 23 2016 03:38 UTC
@Krystinet :point_up: November 22, 2016 7:26 PM
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:38 UTC
@Krystinet
KT
@Krystinet
Nov 23 2016 03:39 UTC

function nextInLine(arr, item) {
// Your code here
item = arr.push();
item = arr.shift();
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

Joseph
@revisualize
Nov 23 2016 03:39 UTC
@Krystinet Why are you overwriting item?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:39 UTC
@Krystinet

function nextInLine(arr, item) {
  // Your code here

 arr.push();
item = arr.shift();
  return item;  // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Joseph
@revisualize
Nov 23 2016 03:39 UTC
item is the number that you need to be adding to the end of the array?
@djcase001 Also wrong.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:39 UTC
@revisualize that's how i solved it
Joseph
@revisualize
Nov 23 2016 03:40 UTC
With this lesson there is Zero need to overwrite item.
@djcase001 Then you never added item to the end of the array.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:40 UTC
@revisualize You're maybe the one who's wrong there
Joseph
@revisualize
Nov 23 2016 03:40 UTC
Maybe I am.
jrr5230
@jrr5230
Nov 23 2016 03:40 UTC
I did it completely different @djcase001
like @revisualize no need to overwrite
KT
@Krystinet
Nov 23 2016 03:41 UTC

function nextInLine(arr, item) {
// Your code here
arr.push();
arr.shift();
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

now back to this, since item does not get over written?
Joseph
@revisualize
Nov 23 2016 03:42 UTC
@djcase001 Could you critique my code and tell me if I'm wrong?
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}
I am pushing item to the end of the array ... because that is what push does.
I am removing the first element from the array because that is what shift does.
jrr5230
@jrr5230
Nov 23 2016 03:42 UTC
@Krystinet you have to push in an item into the array
Joseph
@revisualize
Nov 23 2016 03:43 UTC
But, shift also returns the element that was removed.
So... It satisfies the requirements.
@djcase001 Please let me know where my code is wrong. I'd love to hear it.
...
Look, I'm not trying to sit here and be an ass.
There is a reason that this lesson has
// Change this line
jrr5230
@jrr5230
Nov 23 2016 03:44 UTC
looks right to me +1:
Joseph
@revisualize
Nov 23 2016 03:44 UTC
You need to change that line.
I played the game Clue once or twice and I got Clue.

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.

KT
@Krystinet
Nov 23 2016 03:45 UTC
function nextInLine(arr, item) {
// Your code here
arr.push(item);
return arr.shift; // Change this line
}
Joseph
@revisualize
Nov 23 2016 03:45 UTC
var name = function() { return "Joseph"; }
@Krystinet You're missing the ()
@Krystinet You really need to understand that lesson. It is a very important Data Structure.
KT
@Krystinet
Nov 23 2016 03:46 UTC

$%@$%^%^

Joseph
@revisualize
Nov 23 2016 03:46 UTC
It's called a Queue.
jrr5230
@jrr5230
Nov 23 2016 03:46 UTC
function nextInLine(arr, item) { // Your code here arr.push(item); var removed = arr.shift(); return removed; } I just added an extra variable so mine was a little less efficient lol
KT
@Krystinet
Nov 23 2016 03:46 UTC
Thanks guys!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:46 UTC

@revisualize

nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5

How you gonna return 1, 2 or 5 if you don't overwrite the item argument

Joseph
@revisualize
Nov 23 2016 03:46 UTC
@djcase001 Re-read my code.
KT
@Krystinet
Nov 23 2016 03:46 UTC
@revisualize I absolutely want to understand the lesson! Thank you for your help
CamperBot
@camperbot
Nov 23 2016 03:46 UTC
krystinet sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2407 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 23 2016 03:47 UTC
@djcase001 The item gets added to the end of the array.
@djcase001 Then the first element gets removed.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:47 UTC
@revisualize ok I see it. but mine is good too
Joseph
@revisualize
Nov 23 2016 03:47 UTC
If there are no elements in that array.
@djcase001 Your code doesn't complete for me.
Does not complete.
Just tested it.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:48 UTC
@revisualize it completed for me
Joseph
@revisualize
Nov 23 2016 03:49 UTC
@djcase001
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:49 UTC
I admit yours was clever than mine, but mine works too
Joseph
@revisualize
Nov 23 2016 03:49 UTC
blob
FrankSD
@FrankSD
Nov 23 2016 03:49 UTC
Can someone please help me with my Javascriptpage? can not get it submitted
Joseph
@revisualize
Nov 23 2016 03:50 UTC
@djcase001 That's the code that you posted and the test cases.
KT
@Krystinet
Nov 23 2016 03:50 UTC
Thank you @djcase001 @revisualize
CamperBot
@camperbot
Nov 23 2016 03:50 UTC
krystinet sends brownie points to @djcase001 and @revisualize :sparkles: :thumbsup: :sparkles:
:warning: krystinet already gave revisualize points
:cookie: 333 | @djcase001 |http://www.freecodecamp.com/djcase001
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:50 UTC
@revisualize you didn't push item in the array first
Joseph
@revisualize
Nov 23 2016 03:50 UTC
@djcase001 I copied and pasted the code that you put into chat.
I didn't edit it.
CTRL+C ... CTRL+V
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:51 UTC
There was a mistake in this one
Joseph
@revisualize
Nov 23 2016 03:52 UTC
@Krystinet Do you understand what is going on?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52 UTC
@Krystinet Are you ok now??
KT
@Krystinet
Nov 23 2016 03:52 UTC
@revisualize I think so
@djcase001 I think I get it now
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52 UTC
@Krystinet good
KT
@Krystinet
Nov 23 2016 03:52 UTC
I'm going to do some more reading so that it sinks in
Joseph
@revisualize
Nov 23 2016 03:52 UTC
@Krystinet I have a link.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52 UTC
@Krystinet go ahead
Actually open that page.. There are two hint links and there are two non-code comments as well.
KT
@Krystinet
Nov 23 2016 03:54 UTC
@revisualize I was able to pass the lesson, but need more practice, for sure!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:55 UTC
@FrankSD What page???
KT
@Krystinet
Nov 23 2016 04:00 UTC
@revisualize read through the page, I think it was the syntax of the array mixed with the syntax of the function that threw me. Definitely have a better understanding now, still need more practice of course!
Rachel Riley
@ParadiseArtist
Nov 23 2016 04:06 UTC
Hey guys!
Anyone want to take a super easy question? Lol
jrr5230
@jrr5230
Nov 23 2016 04:08 UTC
@ParadiseArtist sounds like it'll be a trick question -_-
lol jk
go for it
Rachel Riley
@ParadiseArtist
Nov 23 2016 04:08 UTC
@jrr5230 Ha I wish I was that smart. I'm not quite getting ...
Wait you guys were working on this above. Yeay! I'm not along.
alone
jrr5230
@jrr5230
Nov 23 2016 04:09 UTC
haha there you go
Rachel Riley
@ParadiseArtist
Nov 23 2016 04:09 UTC
Let me read over the above code cause I'm stuck on the exact same question.
jrr5230
@jrr5230
Nov 23 2016 04:09 UTC
:+1:
Joseph
@revisualize
Nov 23 2016 04:16 UTC
la la la
@ParadiseArtist Just read that link that I posted.
Shubhankar Chandra Banerjee
@shubhankarb180
Nov 23 2016 04:22 UTC

Instructions
Declare a local variable myVar inside myLocalScope. Run the tests and then follow the instructions commented out in the editor.

Hint
Refreshing the page may help if you get stuck.

No global myVar variable

code-

unction myLocalScope() {
var myVar = "use strict";
console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

// Now remove the console log line to pass the test

problem solved
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 04:31 UTC
$(document).ready(function() {
var la=30;
var lo=55;
var api='api.openweathermap.org/data/2.5/weather?lat=la&lon=lo&APPID=da3ecbc1d1d3735a28ee453521d25614'
$.getJSON(api,function(response){
console.log(response);
});
});
i am not getting response pls anyone help
MoNag1
@MoNag1
Nov 23 2016 04:35 UTC
@Ankitnau25 you need to concat the api string so that it includes the variables la and lo
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 04:37 UTC
k @MoNag1
MoNag1
@MoNag1
Nov 23 2016 04:37 UTC
var api="api.openweathermap.org/data/2.5/weather?lat=" + la + "&lon=" + lo + "&APPID=da3ecbc1d1d3735a28ee453521d25614"
Anthony Drane
@Antiaccess
Nov 23 2016 04:39 UTC
Can anyone tell me why 'mouseup' 'mousedown' doesn't change the colour on the down and up mouse click of a div, instead it stays on one color, with this code:
$("#g").on("mousedown", function() {
    $("#g").toggleClass('fullGreen');
}).on("mouseup", function() {
    $("#g").toggleClass('n-green');
});
Arnaud Casamé
@arnaudcasame
Nov 23 2016 04:39 UTC
@Antiaccess Still got that problem
Anthony Drane
@Antiaccess
Nov 23 2016 04:39 UTC
@djcase001 just went out with a mate, got home
@djcase001 so basically starting where I left off
Arnaud Casamé
@arnaudcasame
Nov 23 2016 04:40 UTC
@Antiaccess ok, I'd use the click event instead of mousedown and up
Anthony Drane
@Antiaccess
Nov 23 2016 04:40 UTC
like g.onclick = function()
?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 04:45 UTC
Yeah
@Antiaccess sent you a link in private
Dominic Muttel
@domuttel
Nov 23 2016 04:49 UTC
@Terryd12345 you still here?
I got Record Collection factored but Im having trouble with it a bit?
function updateRecords(id, prop, value) {
  var newArray = [];
  if ( prop === "artist" && value !== "") {
    collection[id].artist = value;
  } 
  else if ( prop === "tracks" && value !== "" ){
    collection[id].tracks = newArray;
    collection[id].tracks[0] = value;
  }
  return collection;
}
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 04:50 UTC
@MoNag1
$(document).ready(function() {
var la;
var lo;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
la=position.coords.latitude;
lo=position.coords.longitude;
});
}
var api="api.openweathermap.org/data/2.5/weather?lat=" + la + "&lon=" + lo + "&APPID=da3ecbc1d1d3735a28ee453521d25614"
$.getJSON(api,function(response){
console.log(response);
});
});
still not getting response @MoNag1
Dominic Muttel
@domuttel
Nov 23 2016 04:51 UTC
@Terryd12345 Its passing the tests but not the quiz...
OR if anyone can help me with Record Collection
Will
@Will-is-Coding
Nov 23 2016 04:54 UTC
@Ankitnau25 try adding "http://" to the link
kevin
@leozhon
Nov 23 2016 04:57 UTC

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
myNoun=wordBlanks[0];
myAdjective=wordBlanks[1];
myVerb=wordBlanks[2];
myAdverb=wordBlanks[3];
result="My "+myNoun+" is "+myAdjective+" and "+myVerb+" so "+myAdverb;

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Dominic Muttel
@domuttel
Nov 23 2016 04:58 UTC
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  var newArray = [];
  if ( prop === "artist" && value !== "") {
    collection[id].artist = value;
  } 
  else if ( prop === "tracks" && value !== "" ){
    collection[id].tracks = newArray;
    collection[id].tracks[0] = value;
  }
  return collection;
}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA"); 
updateRecords(2548, "artist", "");

updateRecords(5439, "tracks", "Take a Chance on Me");
updateRecords(2548, "tracks", "");
updateRecords(1245, "tracks", "Addicted to Love");
Ian
@toianw
Nov 23 2016 04:59 UTC
@Antiaccess your green button already has the n-green class, so just toggle the fullGreen class on both mousedown and mouseup
Will
@Will-is-Coding
Nov 23 2016 05:00 UTC
@leozhon myNoun myAdjective myVery and myAdverb are parameters for the function. While dog big ran and quickly are arguments to the wordBlanks function. You use the parameters as placeholders. So if you were to simply print out myNoun the parameter, it would print out "dog" in this instance. You don't access them via an array of the function.
Anthony Drane
@Antiaccess
Nov 23 2016 05:00 UTC
ok
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 05:00 UTC
got it @MoNag1 but la and lo are not returning
MoNag1
@MoNag1
Nov 23 2016 05:01 UTC
@Ankitnau25 I believe you can no longer access geolocation like that, you need to get coordinates through ip-api.com. You can check out a video that explains it here
Anthony Drane
@Antiaccess
Nov 23 2016 05:01 UTC
@toianw legend! seems counterintuitive, but it works
@toianw thanks
CamperBot
@camperbot
Nov 23 2016 05:01 UTC
antiaccess sends brownie points to @toianw :sparkles: :thumbsup: :sparkles:
:cookie: 428 | @toianw |http://www.freecodecamp.com/toianw
Ken Haduch
@khaduch
Nov 23 2016 05:01 UTC
@domuttel - y ou should not have to use a special check for "artist" - the main thing that distinguishes actions based on the property names is either the property is "tracks" or it isn't. And you do not have the condition covered where the value === "" where you should delete a property.
Anthony Drane
@Antiaccess
Nov 23 2016 05:02 UTC
@toianw actually, it kind of makes sense
MoNag1
@MoNag1
Nov 23 2016 05:02 UTC
@leozhon I don't think that is what the challenge is expecting you to do, you are over thinking it
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 05:03 UTC
thanks a lot @MoNag1 can u suggest me resource for ajax calls i am getting difficulty in them
CamperBot
@camperbot
Nov 23 2016 05:03 UTC
ankitnau25 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @monag1 |http://www.freecodecamp.com/monag1
Ian
@toianw
Nov 23 2016 05:03 UTC
@Antiaccess it's just adding the class on mousedown and removing the class on mouseup.
Joseph
@revisualize
Nov 23 2016 05:03 UTC
@domuttel The instructions never mention artist.
@domuttel Why are you overwriting tracks array's that already have data?
Ken Haduch
@khaduch
Nov 23 2016 05:04 UTC
@leozhon - you are doing something that is not going to work with your access of wordBlanks[0], etc - wordBlanks is the function name, you can directly access the variables (which are the function parameters) myNoun, myAdjective, etc. in the code without the actions that you are taking to try and assign values to them. Their values are assigned by the function call.
Anthony Drane
@Antiaccess
Nov 23 2016 05:04 UTC
@toianw yeah, I think was to close to the issue that I didn't see it
Joseph
@revisualize
Nov 23 2016 05:04 UTC
@leozhon wordBlanks is not an array.. It is a function
Dominic Muttel
@domuttel
Nov 23 2016 05:07 UTC
@revisualize @khaduch I am on the right track with tracks then... Im off on artists
MoNag1
@MoNag1
Nov 23 2016 05:07 UTC
@Ankitnau25 I struggle with them too, I just learnt off viewing other people's code and seeing how they did it, not sure if that's the best way tho. Codeacademy has a course called "how to use API's with Javascript" but it's very basic
Joseph
@revisualize
Nov 23 2016 05:08 UTC
@domuttel No. You're overwriting tracks that already have data. You shouldn't be doing that.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 05:08 UTC
@Antiaccess did you see the link???
Anthony Drane
@Antiaccess
Nov 23 2016 05:08 UTC
@djcase001 nope
@djcase001 in this chat?
@djcase001 ok
@djcase001 got it
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 05:11 UTC
thanks for help @MoNag1
CamperBot
@camperbot
Nov 23 2016 05:11 UTC
ankitnau25 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:warning: ankitnau25 already gave monag1 points
Arnaud Casamé
@arnaudcasame
Nov 23 2016 05:11 UTC
@Antiaccess 👍🏽
Ken Haduch
@khaduch
Nov 23 2016 05:14 UTC
@domuttel - "artists" is definitely not necessary to handle as a special case. That being said, you could certainly make it one, but then you would also have to do that for all of the possible properties (and some of them you would potentially not know, unless you had the complete list of possible function calls that gave them to you.) So you have to have two cases - prop === "tracks" and the opposite of that - an if and an else. Also you have to be careful how you handle the tracks property and value associated with it - it is an array or should be one. If you already have an array there, you just want to add to it. Other times you don't have the array and you need to create it.
Dominic Muttel
@domuttel
Nov 23 2016 05:16 UTC
So I am essentially deleting the arrays before I do anything?
is this a case for hasOwnProperty?
Ken Haduch
@khaduch
Nov 23 2016 05:17 UTC
@domuttel - Bingo! .hasOwnProperty() is just the ticket!
Dominic Muttel
@domuttel
Nov 23 2016 05:21 UTC
( prop === collection[id].hasOwnProperty("tracks") )
Joseph
@revisualize
Nov 23 2016 05:24 UTC
@domuttel .hasOwnPropery() returns either true or false.
Dominic Muttel
@domuttel
Nov 23 2016 05:24 UTC
.hasOwnProperty is referring to artists in this case @khaduch
Kingdom Isaac
@kingisaac95
Nov 23 2016 05:25 UTC
Hello all, please my code is giving errors. Am writing algorithm scripting - find the longest word in a string

Here's my code:

function findLongestWord(str) {

var words = str.split(' ');
var maxLength = 0;

for(var i = 0; i < words.length; i++) {
if(words[i].length > maxLength) {
maxLength = words[i].lenght;
}
}

return maxLength;
}

findLongestWord("The quick brown fox jumped over the lazy dog");

heroiczero
@heroiczero
Nov 23 2016 05:28 UTC
@kingisaac95 maxLength = words[i].lenght; check length spelling on that line
Dominic Muttel
@domuttel
Nov 23 2016 05:29 UTC
@khaduch ( collection[id].hasOwnProperty("tracks") === true )
gandledorf
@gandledorf
Nov 23 2016 05:30 UTC

is there anything wrong with my code function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val){
case "1":
console.log("alpha");
break;
case "2":
console.log("beta");
break;
case "3":
console.log("gamma");
break;
case "4":
console.log("delta");
break;
}

// Only change code above this line
return answer;
}

// Change this value to test
caseInSwitch(2);

heroiczero
@heroiczero
Nov 23 2016 05:31 UTC
@gandledorf need to return alpha beta and so on so you have to set answer equal to alpha and so on for it to return answer
Sapiens Khadka
@shyrushh
Nov 23 2016 05:31 UTC

Anyone PLEASE help me with the Mad Libs "WORD BLANKS" game......WHAT SHOULD BE THE CODE BETWEEN COMMENTS BLOCK?????\

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");

Seth Church
@iEnder
Nov 23 2016 05:32 UTC
@shyrushh think you need to concat a string with those words provided
gandledorf
@gandledorf
Nov 23 2016 05:32 UTC
@heroiczero thanks
CamperBot
@camperbot
Nov 23 2016 05:32 UTC
gandledorf sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Nov 23 2016 05:32 UTC
@shyrushh just make a sentence with the variables provided by the function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) and then set it equal to result
Stanley Su
@cuddlycuddles
Nov 23 2016 05:35 UTC
@shyrushh Combine the arguments inside the wordBlanks brackets. Make sure you add a space inbetween each word so that it's a proper sentence
Sapiens Khadka
@shyrushh
Nov 23 2016 05:36 UTC
THANK YOU ALL FOR THE QUICK RESPONSE :+1:
Kingdom Isaac
@kingisaac95
Nov 23 2016 05:37 UTC
@heroiczero Thanks a lot
CamperBot
@camperbot
Nov 23 2016 05:37 UTC
:cookie: 418 | @heroiczero |http://www.freecodecamp.com/heroiczero
kingisaac95 sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
Dominic Muttel
@domuttel
Nov 23 2016 05:50 UTC
  if ( collection[id].hasOwnProperty("tracks") === false ){
    collection[id].tracks = newArray;
    collection[id].tracks.push(value);
  }
@khaduch
Joseph
@revisualize
Nov 23 2016 05:56 UTC
  if (collection[id].hasOwnProperty("tracks") === false){
    collection[id].tracks = [];
  }
  collection[id].tracks.push(value);
Dominic Muttel
@domuttel
Nov 23 2016 05:57 UTC
@revisualize thats what I have
Joseph
@revisualize
Nov 23 2016 05:58 UTC
@domuttel You have newArray defined elsewhere then you're using it.
You're only going to use newArray once.
Karthik
@karthikm0
Nov 23 2016 05:58 UTC
Hey guys I have a question regarding the Mutations JavaScript algorithms exercise
I get all the test cases right except ("hello", "hey")
My code is as follows:
Abhisek Pattnaik
@abhisekp
Nov 23 2016 05:58 UTC
@domuttel the condition part in the if statement automagically checks for truthy value
Dominic Muttel
@domuttel
Nov 23 2016 05:59 UTC
oh ok that makes way more sense
Karthik
@karthikm0
Nov 23 2016 05:59 UTC

function mutation(arr) {
valid = true;
for (var i = 0; i < arr[1][0].length; i++) {
if (arr[0].toLowerCase().indexOf(arr1.charAt(i).toLowerCase()) == -1) {
valid = false;
}
return valid;
}
}

mutation(["hello", "hey"]);

Abhisek Pattnaik
@abhisekp
Nov 23 2016 05:59 UTC
@domuttel if truthy
then execute the statements
Dominic Muttel
@domuttel
Nov 23 2016 06:00 UTC
@abhisekp but it is set to equal false
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:00 UTC
@domuttel you can negate it by using ! operator :D
@domuttel e.g.
if ( !truthy )
Dominic Muttel
@domuttel
Nov 23 2016 06:01 UTC
myObj.hasOwnProperty(checkProp) !=
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:02 UTC
if (!myObj.hasOwnProperty(checkProp))
  ...
Dominic Muttel
@domuttel
Nov 23 2016 06:02 UTC
oh duh
@revisualize
```
@revisualize
  if ( !collection[id].hasOwnProperty("tracks") ){
    collection[id].tracks = [];
  } 
  collection[id].tracks.push(value);
  else {

  }
is this the right dirrection?
Im really struggling with this one...
Joseph
@revisualize
Nov 23 2016 06:09 UTC
@domuttel What's the else going to be?
Dominic Muttel
@domuttel
Nov 23 2016 06:11 UTC
Im wondering about adding the aritist name
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:18 UTC
@karthikm0
```js  [shift + enter for newline]

<code here>

```    [ctrl + enter to post]
Alla Panchenko
@erselnordlys
Nov 23 2016 06:53 UTC

hello guys! need help.

Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".

my code:

var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  if (true) {
    myObj.hasOwnProperty(checkProp);
    return myObj.checkProp;
  }
  return "Change Me!";
}
checkObj("gift");

the function doesn't work, console displays nothing. why?

Markus Kiili
@Masd925
Nov 23 2016 06:53 UTC
@erselnordlys Test the hasOwnProperty expression, not true.
You also need to use the bracket notation then the property key is in a variable like checkProp.
Alla Panchenko
@erselnordlys
Nov 23 2016 06:57 UTC
@Masd925
ok, now this is what the function looks like. console displays "Change me!". what is wrong?
function checkObj(checkProp) {
  if (myObj.hasOwnProperty[checkProp]) {
    return myObj[checkProp];
  }
  return "Change Me!";
}
Markus Kiili
@Masd925
Nov 23 2016 06:57 UTC
@erselnordlys ...hasOwnProperty(...) <- parens here, it is a method.
Alla Panchenko
@erselnordlys
Nov 23 2016 06:58 UTC
@Masd925 why exactly bracket notation instead of dot?
Markus Kiili
@Masd925
Nov 23 2016 06:58 UTC
@erselnordlys The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Alla Panchenko
@erselnordlys
Nov 23 2016 06:58 UTC
@Masd925 sure, parens! thanks
CamperBot
@camperbot
Nov 23 2016 06:58 UTC
erselnordlys sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2982 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Nov 23 2016 06:59 UTC
Question.. In Russia. If I want AK47 ... Do I just go to middle school and they build me one? Is it one of those situations where I get an AK and they get a good grade?
Markus Kiili
@Masd925
Nov 23 2016 07:01 UTC
Boolean("Do I just go to middle school and they build me one? Is it one of those situations where I get an AK and they get a good grade?"); // true
kirbyedy
@kirbyedy
Nov 23 2016 07:02 UTC
@revisualize lol
Markus Kiili
@Masd925
Nov 23 2016 07:03 UTC
@erselnordlys So, bracket notation evaluates the expression inside the brackets into a string and uses it as a key, and dot notation just uses the string written after the dot.
Joseph
@revisualize
Nov 23 2016 07:04 UTC
I swear.. It should be like a shop class assignment.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:04 UTC
@Masd925 so what is the type of key "checkProp" in this code? and what are valid JS identifiers for example?
Markus Kiili
@Masd925
Nov 23 2016 07:06 UTC
@erselnordlys checkProp is the function parameter (a variable in the function execution context that holds the passed key). The passed key is a string.
kirbyedy
@kirbyedy
Nov 23 2016 07:06 UTC
@revisualize you americans have a really wrong impression about russians :D
btw. I am not a russian :)
Joseph
@revisualize
Nov 23 2016 07:07 UTC
@kirbyedy Actually, I just want a really bad ass Russian built AK-47.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:07 UTC
@Masd925 i got it, thanks a lot!
CamperBot
@camperbot
Nov 23 2016 07:07 UTC
erselnordlys sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: erselnordlys already gave masd925 points
Dan Couper
@DanCouper
Nov 23 2016 07:08 UTC

@erselnordlys that goes into a lot of detail, but this is the important bit

An identifier must start with $, _, or any character in the Unicode categories “Uppercase letter (Lu)”, “Lowercase letter (Ll)”, “Titlecase letter (Lt)”, “Modifier letter (Lm)”, “Other letter (Lo)”, or “Letter number (Nl)”.

Joseph
@revisualize
Nov 23 2016 07:08 UTC
@kirbyedy I have a crappy American Made one.
Okay maybe it isn't crappy. But, still .. you get the idea.
Dan Couper
@DanCouper
Nov 23 2016 07:08 UTC
@erselnordlys so if you want, you can write all of your variables in arabic or chinese or russian or whatever.
Darth Skywalker
@adityaparab
Nov 23 2016 07:09 UTC
You Americans are fucking stupid... Just like the rest of us really!
Joseph
@revisualize
Nov 23 2016 07:09 UTC
@adityaparab Yee haw?
Darth Skywalker
@adityaparab
Nov 23 2016 07:09 UTC
:laughing:
Alla Panchenko
@erselnordlys
Nov 23 2016 07:10 UTC
@DanCouper i'm not that deep in JS yet... I dont get it now
Joseph
@revisualize
Nov 23 2016 07:10 UTC

Parameters are variables that represent the values that get passed into your function from the function call.
https://cs.wellesley.edu/~cs110/lectures/L16/images/function-anatomy.png
Notice how the variables level and score in the function definition addScore are called parameters.
However, when we invoke the function like in:
addScore(3, 10) or addScore(6, 20)
the values are called arguments. Here is an important lesson:
You define a function with parameters, you call a function with arguments.

Another example of this:

function hello(fName, uName) {
     return "Hello " + fName + " " + uName + ", How is your day?";
}
hello("Joseph", "@revisualize"); // "Hello Joseph @revisualize, How is your day?"
hello("Bella", "@bellaknoti"); // "Hello Bella @bellaknoti, How is your day?"
hello("Andy", "@dirn"); // "Hello Andy @dirn, How is your day?"

You can use the fName and uName parameters just like a variable inside of your function.

Other important things to remember:
* A function can have zero parameters. You still have to use the parentheses to define it.
* A function might have no return statements. In this case we say that the function returns undefined.

Dan Couper
@DanCouper
Nov 23 2016 07:10 UTC
just as long as you don’t call your variable “var” or “function” or whatever you’ll be fine
Joseph
@revisualize
Nov 23 2016 07:10 UTC
...
@Masd925 Do I need to fix that text?
Dan Couper
@DanCouper
Nov 23 2016 07:11 UTC
var π = Math.PI;
var ಠ_ಠ = "ahem";
var λ = function() {};
Abhisek Pattnaik
@abhisekp
Nov 23 2016 07:11 UTC
@DanCouper ahem...ahem...
Joseph
@revisualize
Nov 23 2016 07:11 UTC
@erselnordlys ----^^^ ... checkProp is a parameter.
kirbyedy
@kirbyedy
Nov 23 2016 07:12 UTC
@revisualize lovely graph mate, thanks
CamperBot
@camperbot
Nov 23 2016 07:12 UTC
kirbyedy sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2409 | @revisualize |http://www.freecodecamp.com/revisualize
Darth Skywalker
@adityaparab
Nov 23 2016 07:12 UTC
very impressive! very impressive!
vveeeeerryy impressive
Joseph
@revisualize
Nov 23 2016 07:13 UTC
Crap.. Look at the time.
Okay it is 1113pm here in Seattle.
I need to jet.
:v:
Darth Skywalker
@adityaparab
Nov 23 2016 07:14 UTC
Same in San Francisco
Alla Panchenko
@erselnordlys
Nov 23 2016 07:14 UTC
@revisualize how does it works with zero parameters? What will it return?
@DanCouper well I got it haha! var function is fun
Joseph
@revisualize
Nov 23 2016 07:14 UTC
@erselnordlys You have to code around it.
@erselnordlys Something like this.
Dan Couper
@DanCouper
Nov 23 2016 07:14 UTC
var Hͫ̆̒̐ͣ̊̄ͯ͗͏̵̗̻̰̠̬͝ͅE̴̷̬͎̱̘͇͍̾ͦ͊͒͊̓̓̐_̫̠̱̩̭̤͈̑̎̋ͮͩ̒͑̾͋͘Ç̳͕̯̭̱̲̣̠̜͋̍O̴̦̗̯̹̼ͭ̐ͨ̊̈͘͠M̶̝̠̭̭̤̻͓͑̓̊ͣͤ̎͟͠E̢̞̮̹͍̞̳̣ͣͪ͐̈T̡̯̳̭̜̠͕͌̈́̽̿ͤ̿̅̑Ḧ̱̱̺̰̳̹̘̰́̏ͪ̂̽͂̀͠ = 'Zalgo';
Abhisek Pattnaik
@abhisekp
Nov 23 2016 07:14 UTC
@DanCouper why are the texts crying? :'(
Joseph
@revisualize
Nov 23 2016 07:14 UTC

@erselnordlys

var name = function() { return "Joseph"; }

What do you think the value of the variable name is?

Darth Skywalker
@adityaparab
Nov 23 2016 07:15 UTC
@DanCouper : THere is name for people who use variables like that... It's called "animals"
Alla Panchenko
@erselnordlys
Nov 23 2016 07:15 UTC
@revisualize i spose it will be "Joseph', right?
Joseph
@revisualize
Nov 23 2016 07:15 UTC
@erselnordlys You'll find out later about the arguments key word. And what it allows you to do.
@erselnordlys that's correct.
Darth Skywalker
@adityaparab
Nov 23 2016 07:15 UTC
@erselnordlys : It'll be [Function name] ;)
Joseph
@revisualize
Nov 23 2016 07:15 UTC
@erselnordlys Save that knowledge for later. It will be useful.
Dan Couper
@DanCouper
Nov 23 2016 07:16 UTC
T̵͎̠h̤̣̗̙̥͝o̟̮͎̯̕s͉̦̘̠̥e͉̮̥ ̻a͎̖̪̰r̴͈e͇̺͙͢ ̨͖̫̺̤̦̠̱t̗͓̠̞͓̕h̭̗̘̦̦ẹ̳̼͝ ̸̰̖̘͓̪̱̭c̡̳͈̣̖̮h̷͈͍͎ͅo̷̪̘̜se̡̞̝̺̱n̻͎̲̭̱͡, ̮͍̬̜̫̝̀t̡͇̭̯̟̹̣̲ḩ̰͍̯òṣ͎͈͚͚̰̼e͙̞̘̹̻͢ ̛̩͉̣̼͓̥w͈̙̟h̷̥͈̩̺̯͙o̢̫͇͈͉͖ͅͅ ̥̫̝̭͔̤͉u̻̩̰͙̣̖͝s͕̫̩͉e̪̪̥̮͙ ̺̯͡ͅͅt̫̰h̜̙̗̯͎̰͚̕e ̠̤͟V̗͍͙̩̤̹̹A̙̟̜̰̕R̨̲̹Í̩͖̣A͈BL͍̰͚E̷̲̳̪̳S͇̣ ͇̭o̲f͈̺̲ ̴̹Z͔͔͓̩ͅḀ̢̣LG͓̺͚̘̯̭O͚̘
Darth Skywalker
@adityaparab
Nov 23 2016 07:16 UTC
var name is assigned to a function. But that function is not called. So the value of name will be a function.
Joseph
@revisualize
Nov 23 2016 07:16 UTC
meh.. Kind of.
Dan Couper
@DanCouper
Nov 23 2016 07:16 UTC
:point_up:
RishiRex
@rishirex
Nov 23 2016 07:17 UTC
How to Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator?
Dan Couper
@DanCouper
Nov 23 2016 07:17 UTC
remainder = 11 % 3
literally the same as you wrote it
Darth Skywalker
@adityaparab
Nov 23 2016 07:17 UTC
let remainder = 11%3;
Joseph
@revisualize
Nov 23 2016 07:17 UTC
Okay. technically yes.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:18 UTC
@revisualize @DanCouper well thanks! i'll keep going
CamperBot
@camperbot
Nov 23 2016 07:18 UTC
erselnordlys sends brownie points to @revisualize and @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 359 | @dancouper |http://www.freecodecamp.com/dancouper
:star2: 2410 | @revisualize |http://www.freecodecamp.com/revisualize
Dominic Muttel
@domuttel
Nov 23 2016 07:18 UTC
@revisualize Is the AK thing pointed towards me?
Joseph
@revisualize
Nov 23 2016 07:19 UTC
@domuttel Technically yes. Technically, it is currently pointed in the direction of everyone on this planet.
Henry Cabello
@hacu9
Nov 23 2016 07:19 UTC
Hey! Can anyone check my pen?https://codepen.io/cabello986/pen/rrgdpV?editors=1010
specifically the animate function,if you click ON and try playing along well....the animations arent working correctly
Joseph
@revisualize
Nov 23 2016 07:20 UTC
Stupid Earth being an oval and not a sphere.
Dominic Muttel
@domuttel
Nov 23 2016 07:21 UTC
Have you thought about a UV lamp?
Joseph
@revisualize
Nov 23 2016 07:21 UTC
Here...
function getName() { return "Joseph" }
var name = getName();
console.log(name);
@domuttel What? Why?
OKAY!
I must get the :zzz:
:v:
Dominic Muttel
@domuttel
Nov 23 2016 07:23 UTC
Man take a break dont lash out... We all are just trying to learn. Im not looking for an answer but some guidance. This stuff is hard
Joseph
@revisualize
Nov 23 2016 07:23 UTC
Was that directed at me?
:| I don't get it.
I sleep.
:v:
Markus Kiili
@Masd925
Nov 23 2016 07:25 UTC
@revisualize I think that the function explanation text is good. If you would like to be more precise, parameters are part of the function declaration and when the function is called, an execution context is formed and there parameters are variables that hold the passed arguments. So just calling them variables is less correct in my opinion.
Darth Skywalker
@adityaparab
Nov 23 2016 07:25 UTC
Go sleep!
Joseph
@revisualize
Nov 23 2016 07:25 UTC
@Masd925 Thanks. I will look at seeing if I can correct the text a little.
CamperBot
@camperbot
Nov 23 2016 07:25 UTC
revisualize sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2983 | @masd925 |http://www.freecodecamp.com/masd925
Abhisek Pattnaik
@abhisekp
Nov 23 2016 07:29 UTC
@Masd925 :point_up: November 21, 2016 7:11 PM
Samuel-Mumo
@Samuel-Mumo
Nov 23 2016 07:31 UTC
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)){
return myObj.checkProp;
}
return "Not Found";
}
checkObj("gift");
someone to help me debug the code above, its printing undefined, what could be wrong?
kyauhen
@kyauhen
Nov 23 2016 07:34 UTC
@Samuel-Mumo your prop is actual string and you can't access an object this way
@Samuel-Mumo it looks like myObj."gift"
However there's always another way to access objects
Markus Kiili
@Masd925
Nov 23 2016 07:38 UTC
@abhisekp ok, thanks.
CamperBot
@camperbot
Nov 23 2016 07:38 UTC
masd925 sends brownie points to @abhisekp :sparkles: :thumbsup: :sparkles:
:star2: 3192 | @abhisekp |http://www.freecodecamp.com/abhisekp
Samuel-Mumo
@Samuel-Mumo
Nov 23 2016 07:46 UTC
@kyauhen thanks, i haved used myObj[gift] and it worked
CamperBot
@camperbot
Nov 23 2016 07:46 UTC
samuel-mumo sends brownie points to @kyauhen :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for kyauhen
Anthony Drane
@Antiaccess
Nov 23 2016 08:05 UTC
Hey guys, I've been working on the simon game and I'm having all of the notes play at the same time despite a time interval. I think I'm using it wrong. Can anyone confirm:
  for (var i = 0; i < simonArr.length; i++){
    setTimeout(output(simonArr[i], 1000));
  }
codepen link^
You'll notice all the sounds & color-changes happen simultaneously
making the game unplayable
any awake aussies here?
FengChen
@liuyueweilan
Nov 23 2016 08:20 UTC

var phoneticLookup= {

// Only change code below this line

"alpha": "Adams",

 "bravo": "Boston",

 "charlie":"Chicago",

"delta": "Denver",

"echo":  "Easy",

"foxtrot": "Frank"

// Only change code above this line

};

// Change this value to test
phoneticLookup("charlie");

whats problem?
Stefaan Walleghem
@lawfets
Nov 23 2016 08:20 UTC
hello, I have a problem sorting an array with numbers.
FengChen
@liuyueweilan
Nov 23 2016 08:20 UTC
phoneticLookup("") should be undefined
cannot use case, switch, or if
Stefaan Walleghem
@lawfets
Nov 23 2016 08:21 UTC
commaArraySort =commaArray.sort(function (a, b) {  return a - b;  });
this should sort the numbers from low to high, right?
Islam Ibakaev
@dagman
Nov 23 2016 08:22 UTC
yep
Stefaan Walleghem
@lawfets
Nov 23 2016 08:22 UTC
but it doesn't
if I return commaArraySort it still gives the array as before
Islam Ibakaev
@dagman
Nov 23 2016 08:23 UTC
it works
FengChen
@liuyueweilan
Nov 23 2016 08:23 UTC
the typeError is phoneticLookup is not a function
Islam Ibakaev
@dagman
Nov 23 2016 08:23 UTC
correctly
Markus Kiili
@Masd925
Nov 23 2016 08:24 UTC
var commaArraySort = [1,453,2,3,55,1];
commaArraySort =commaArraySort.sort(function (a, b) {  return a - b;  }); // [ 1, 1, 2, 3, 55, 453 ]
FengChen
@liuyueweilan
Nov 23 2016 08:24 UTC
but i didnot use function ,right?
Markus Kiili
@Masd925
Nov 23 2016 08:24 UTC
@lawfets Sort is a mutator method, so commaArraySort.sort... is enough.
Stefaan Walleghem
@lawfets
Nov 23 2016 08:24 UTC
how come it doesn't work with me???
Markus Kiili
@Masd925
Nov 23 2016 08:25 UTC
@lawfets Post the whole code.
Stefaan Walleghem
@lawfets
Nov 23 2016 08:25 UTC
@Masd925 yes but I want to know why it doesn't work my way and it works for others
Islam Ibakaev
@dagman
Nov 23 2016 08:25 UTC
@Masd925 [1,453,2,3,55,1].sort(function (a, b) { return a - b; }); is enough
Markus Kiili
@Masd925
Nov 23 2016 08:26 UTC
@dagman Yes, I said that already.
Islam Ibakaev
@dagman
Nov 23 2016 08:26 UTC
@lawfets [1,453,2,3,55,1].sort(function (a, b) { return a - b; }); is enough
@Masd925 sorry i see
FengChen
@liuyueweilan
Nov 23 2016 08:27 UTC
@lawfets
Stefaan Walleghem
@lawfets
Nov 23 2016 08:30 UTC
@dagman @Masd925 @liuyueweilan thx for the help, the fault is not in that line, just found out what is wrong
CamperBot
@camperbot
Nov 23 2016 08:30 UTC
lawfets sends brownie points to @dagman and @masd925 and @liuyueweilan :sparkles: :thumbsup: :sparkles:
:cookie: 2 | @liuyueweilan |http://www.freecodecamp.com/liuyueweilan
:star2: 2984 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 639 | @dagman |http://www.freecodecamp.com/dagman
elminsterrr
@elminsterrr
Nov 23 2016 08:30 UTC
Hi to all! :smile:
Stefaan Walleghem
@lawfets
Nov 23 2016 08:33 UTC
I had to use the string.split to change string into array instead of putting string into array
elminsterrr
@elminsterrr
Nov 23 2016 08:33 UTC
What is the simplest way to deal with this in JavaScript? Anyone knows?
input array = [ [ 1, 'Hair Pin' ],
  [ 2, 'Hair Pin' ],
  [ 21, 'Bowling Ball' ],
  [ 67, 'Bowling Ball' ] ]

result = [ [ 3, 'Hair Pin' ],
  [ 88, 'Bowling Ball' ],
]
Ryan Ledford
@rledford
Nov 23 2016 08:36 UTC
@elminsterrr nested for loops for the 2d input array and use another array to put your results in while your looping though the input looking for matching conditions. this can be done with filteras well.
Alexander Huynh
@caesarsalad93
Nov 23 2016 08:36 UTC
HI guys
Ryan Ledford
@rledford
Nov 23 2016 08:36 UTC
filter would be simplest way.
Alexander Huynh
@caesarsalad93
Nov 23 2016 08:37 UTC
Why does parseInt(021, 8); return 15?
instead of 17
elminsterrr
@elminsterrr
Nov 23 2016 08:40 UTC

@rledford I tried something like this:

arraysOfDuplicate.filter(function(arrayofDupEl) {
    arraysOfDuplicate.filter(function(arrayofDupOneMoreTime) {
      if (arrayofDupEl[1] === arrayofDupOneMoreTime[1]) {
        sum += arrayofDupOneMoreTime[0];
      }
    });
    console.log('...', arrayofDupEl);
  });
  console.log(sum);

But my output is: 182 :(


[ [ 1, 'Hair Pin' ],
[ 2, 'Hair Pin' ],
[ 21, 'Bowling Ball' ],
[ 67, 'Bowling Ball' ] ]
... [ 1, 'Hair Pin' ]
... [ 2, 'Hair Pin' ]
... [ 21, 'Bowling Ball' ]
... [ 67, 'Bowling Ball' ]
182

Abhisek Pattnaik
@abhisekp
Nov 23 2016 08:40 UTC
I wish Array#sort were not a mutator method.
elminsterrr
@elminsterrr
Nov 23 2016 08:41 UTC
@rledford My logic is broken here
Emerson
@DikoFaji
Nov 23 2016 08:45 UTC
is there a way to contain the notation in a variable? i know this one don't work
  var arr1 = [1,2,[1,[3]]];
  link = arr1[2][1];

  return link[0]; //would like to return 3
Samuel-Mumo
@Samuel-Mumo
Nov 23 2016 08:45 UTC
@liuyueweilan use phoneticLookup["charlie"];
Annika Williamson
@AnnikaKW
Nov 23 2016 08:46 UTC
So I've been running into some Codepen issues in the intermediate front end challenges, and have since read that these are common headaches that well may be eliminated with the curriculum update that requires totally different projects for certification... Is it worth battling through the current projects? I've kind of hit a motivational wall here, any input would be appreciated. :)
Ryan Ledford
@rledford
Nov 23 2016 08:46 UTC
@elminsterrr array.filter(function(arr){ if (arr[0] === someValue) reurn newArr;}); it will be something like that your are trying to get the result you specified above. also where newArr is a local variable inside the filter function defined. sry for my formatting. on mobile.
not return... appened to newArr and return after all items have been looked at sry.
Dirkra
@Dirkra
Nov 23 2016 08:47 UTC
I need some help with the "Stand in Line" challenge, one of the javascript exercises
I have a function with an array and a number as arguments, I have to add the number to the end of the array, then remove the first element of the array and return said element
I used .push to add the number, then I tried with .shift to remove the first element, but idk how to return it
Shift returns the element removed.
So, just return the shift.
Dirkra
@Dirkra
Nov 23 2016 08:51 UTC
Oh, I see
I thought that would return the array without the 1st element
Thanks, @revisualize
CamperBot
@camperbot
Nov 23 2016 08:52 UTC
dirkra sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2411 | @revisualize |http://www.freecodecamp.com/revisualize
Alexander Huynh
@caesarsalad93
Nov 23 2016 08:53 UTC
\
josephinemonica
@josephinemonica
Nov 23 2016 08:55 UTC
Hi please help me : how is the first function a , different with the second function a. here's my code http://codepen.io/alienmon/pen/mOmpBR?editors=1010

```function a() {
$.ajax({
url: "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Albert%20Einstein&origin=*&format=json&utf8=",
dataType: 'json',
type: 'POST',
headers: {
'Api-User-Agent': 'josephine monica'
},

}).done(function(data) {
$("#data").html(JSON.stringify(data));
})

};```

function a() {
  $.ajax({
    url: "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Albert%20Einstein&origin=*&format=json&utf8=",
    dataType: 'json',
    type: 'POST',
    headers: {
      'Api-User-Agent': 'josephine monica'
    },

  }).done(function(data) {
    $("#data").html(JSON.stringify(data));
  })

};
function a() {
  $.ajax({
    url: "https://en.wikipedia.org/w/api.php?origin=*",
    dataType: 'json',
    type: 'POST',
    headers: {
      'Api-User-Agent': 'josephine monica'
    },
    context: {
      "action": "query",
      "list": "search",
      "srsearch": "Albert Einstein",
      // "origin":"*",
      "format": "json",
      "utf8": ""
    }
  }).done(function(data) {
    $("#data").html(JSON.stringify(data));
  })
};
How's the two dunctions above different?
The first function work, while the second function doesn't..
In the second function I put things inside the context, while in the first function put it after the question mark url
please advise
Actually both functions give no error in console... but the first function prints the JSON respones to the #data
BUT the second doesn't print
please help me :)
Markus Kiili
@Masd925
Nov 23 2016 08:59 UTC
@elminsterrr Reduce is the correct method here. For example like this:
var array = [ [ 1, 'Hair Pin' ],
  [ 2, 'Hair Pin' ],
  [ 21, 'Bowling Ball' ],
  [ 67, 'Bowling Ball' ] ];

array.reduce(function(acc,curr,index){
  if (index>0 && curr[1]===acc[acc.length-1][1]) acc[acc.length-1][0]+=curr[0];
  else acc.push(curr);
  return acc;
},[]);  // [ [ 3, 'Hair Pin' ], [ 88, 'Bowling Ball' ] ]
elminsterrr
@elminsterrr
Nov 23 2016 08:59 UTC

@rledford ok, so far I have samoething like this, better then before :smile:

var newArrHP = [];
var newArrBB = [];

var array = [ 
  [ 1, 'Hair Pin' ],
  [ 2, 'Hair Pin' ],
  [ 21, 'Bowling Ball' ],
  [ 67, 'Bowling Ball' ] 
  ];



array.filter(function(arr) {
  console.log(arr[0]);
  console.log(arr[1]);
  if (arr[1] === 'Hair Pin') {
    newArrHP.push(arr[0]);
  }
  if (arr[1] === 'Bowling Ball') {
    newArrBB.push(arr[0]);
  }
  return 99999;
});

console.log('newArrHP', newArrHP);
console.log('newArrBB', newArrBB);

OUTPUT:
1
Hair Pin
2
Hair Pin
21
Bowling Ball
67
Bowling Ball

newArrHP [ 1, 2 ]
newArrBB [ 21, 67 ]

@Masd925 wow, nice one!
Markus Kiili
@Masd925
Nov 23 2016 09:00 UTC
@elminsterrr You are not removing elements from array, so filter doesn't work here.
elminsterrr
@elminsterrr
Nov 23 2016 09:01 UTC
@Masd925 what is the role of "index" in your code?
Markus Kiili
@Masd925
Nov 23 2016 09:01 UTC
@elminsterrr It is the index of the array element being iterated by reduce.
When we are at the first index, it is sure that there is no such item there in the result array.
elminsterrr
@elminsterrr
Nov 23 2016 09:07 UTC
@Masd925 ok, very nice and short solution
but I dpn't understand this -> [acc.length-1]
Markus Kiili
@Masd925
Nov 23 2016 09:07 UTC
@elminsterrr arr[arr.length-1] is always the last element of an array arr.
Mateusz Kadlubowski
@xeho91
Nov 23 2016 09:08 UTC
@esgameco I think the only mistake you made is the typo in word sentence. You got a instead of e
Chance Vodnoy
@esgameco
Nov 23 2016 09:08 UTC
@xeho91 Oh, thanks
CamperBot
@camperbot
Nov 23 2016 09:08 UTC
esgameco sends brownie points to @xeho91 :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @xeho91 |http://www.freecodecamp.com/xeho91
Markus Kiili
@Masd925
Nov 23 2016 09:09 UTC
@elminsterrr So if the item being iterated has the same name as the last item in the accumulator, we add the number to the quantity of the last item in the accumulator.
Daria Doronina
@Skidle
Nov 23 2016 09:09 UTC
hey guys I'm stuck :( it's "Falsy Bouncer" challenge and here's my code

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var boolean = "";
  for (var i = 0; i < arr.length; i++) {
     boolean = Boolean(arr[i]);
   if (arr[i] !== false && arr[i] !== null && arr[i] !== 0 && arr[i] !== "" && arr[i] !== undefined && !isNaN(arr[i])) {
    return boolean;
   }
  } 

}



bouncer([7, "ate", "", false, 9]);
Markus Kiili
@Masd925
Nov 23 2016 09:09 UTC
@Skidle isNaN is not a test for value NaN.
isNaN("cat"); // true
Daria Doronina
@Skidle
Nov 23 2016 09:10 UTC
@Masd925 oh thanks
CamperBot
@camperbot
Nov 23 2016 09:10 UTC
skidle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2985 | @masd925 |http://www.freecodecamp.com/masd925
Daria Doronina
@Skidle
Nov 23 2016 09:11 UTC
@Masd925 so I write it as arr[i] !== NaN ?
Markus Kiili
@Masd925
Nov 23 2016 09:11 UTC
@Skidle That won't work because NaN is not equal to any value.
Even NaN===NaN is false.
Daria Doronina
@Skidle
Nov 23 2016 09:12 UTC
@Masd925 that's crazy :smile:
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:12 UTC
weird
Markus Kiili
@Masd925
Nov 23 2016 09:12 UTC
@Skidle A test for value not being NaN is val===val
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:12 UTC
that's the key!
Daria Doronina
@Skidle
Nov 23 2016 09:12 UTC
@Masd925 thank you!
CamperBot
@camperbot
Nov 23 2016 09:12 UTC
skidle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave masd925 points
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:14 UTC
developers had to test for NaN so much so that they invented Number.isNaN method
Number.isNaN = function isNaN(value) {
  return value !== value;
}
developers are crazy!!!!
Daria Doronina
@Skidle
Nov 23 2016 09:25 UTC
I don't understand how to use array.filter(); I already checked out the documentation and some exampes but I still don't get it
do I need to put a function inside those brackets?
Markus Kiili
@Masd925
Nov 23 2016 09:25 UTC
@Skidle You pass a callback function there that tells filter which elements to keep. Filter passes each array element into the callback function and keeps those that return true.
Daria Doronina
@Skidle
Nov 23 2016 09:27 UTC
@Masd925 ok so I need a function (I guess Boolean();) which returns true or false ?
Markus Kiili
@Masd925
Nov 23 2016 09:28 UTC
@Skidle You need to pass a function, so you would pass Boolean, not Boolean() which would be the return value when you call it without arguments.
Daria Doronina
@Skidle
Nov 23 2016 09:32 UTC
@Masd925 I thought that the function always has brackets... :worried: thanks I'll try to do it now!
CamperBot
@camperbot
Nov 23 2016 09:32 UTC
skidle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave masd925 points
How can I increment or decrement a global variable from inside a function?

var count = 0;

function cc(card) {
// Only change code below this line
var count = 0;
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
break;
case 10:
case 'A':
case 'J':
case 'K':
case 'Q':
count--;
break;

}
if(count > 0){
return "Bet";
}
else if (count <= 0){
return "Hold";
}
return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
This is what I've written and it doesn't seemed to work. Please help :0

Markus Kiili
@Masd925
Nov 23 2016 09:34 UTC
@DevD01 By just incrementing it. count++ for example.
J. Kilgore
@jkilgore07
Nov 23 2016 09:34 UTC
im converting celsius to fahrenheit. and dont understand what im doing wrong.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:34 UTC
@Masd925 I don't get it sorry
Markus Kiili
@Masd925
Nov 23 2016 09:34 UTC
You need to return count + " Bet" etc.
Mo Zargham
@Mozar10
Nov 23 2016 09:35 UTC
@jkilgore07 where are you stuck
Aditi Roy
@AlluringAditi
Nov 23 2016 09:36 UTC
@Masd925 I've defined a local variable count inside the function, have I done that right?
Markus Kiili
@Masd925
Nov 23 2016 09:37 UTC
@DevD01 No, you should just use the global variable.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:37 UTC
@Masd925 okay, then how am I suppose to alter a global variable from inside the function, you are getting it
Markus Kiili
@Masd925
Nov 23 2016 09:38 UTC
@DevD01 You can use global variables inside functions.
Mo Zargham
@Mozar10
Nov 23 2016 09:38 UTC
@DevD01 if you declare a function inside the function then it turns to 0 every time the function is called, just use the global variable, a global variable is accessible everywhere, even inside functions
Aditi Roy
@AlluringAditi
Nov 23 2016 09:38 UTC
I tried that but it's not working
Markus Kiili
@Masd925
Nov 23 2016 09:39 UTC
Problem is the return values.
samkessaram
@samkessaram
Nov 23 2016 09:39 UTC
@DevD01 global means you don't have to declare it (ie 'var = count' ) again.
J. Kilgore
@jkilgore07
Nov 23 2016 09:39 UTC

@Mozar10 The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Mo Zargham
@Mozar10
Nov 23 2016 09:39 UTC
@jkilgore07 so where are you getting stuck?
Markus Kiili
@Masd925
Nov 23 2016 09:39 UTC
@DevD01 Return count + " Bet" etc.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:40 UTC
@Masd925 if I'm using return then I'm getting an error: unreachable break after return
J. Kilgore
@jkilgore07
Nov 23 2016 09:40 UTC
im not sure how to build the equation. the number for celsuis x9/5+32?
when i try that it works for a few then it gives me errors
Mo Zargham
@Mozar10
Nov 23 2016 09:40 UTC
paste your code
J. Kilgore
@jkilgore07
Nov 23 2016 09:42 UTC

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=30*1.8+32;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Blauelf
@Blauelf
Nov 23 2016 09:42 UTC
@jkilgore07 Use parameter celsius, not fixed value 30
Mo Zargham
@Mozar10
Nov 23 2016 09:43 UTC
@jkilgore07 celsius * (9/5) + 32
Blauelf
@Blauelf
Nov 23 2016 09:43 UTC
@jkilgore07 When you call convertToF with argument 30, the first parameter (celsius) will receive the value 30 for that function call.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:44 UTC
Okay Guys here's my Code:
var count = 0;
function cc(card) {
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
return count++ + "Bet";
case 7:
case 8:
case 9:
return count;
case 10:
case 'A':
case 'J':
case 'K':
case 'Q':
return count-- + "Hold";
}
if(count > 0){
return "Bet";
}
else if (count <= 0){
return "Hold";
}
return "Change Me";
Mo Zargham
@Mozar10
Nov 23 2016 09:44 UTC
@jkilgore07 having (celsius) in the brackets like that is the same as if you said var = celsius, inside your function. It's just a variable inside the function
Blauelf
@Blauelf
Nov 23 2016 09:44 UTC
@DevD01 Don't return inside the switch. Just increment or decrement, or do nothing. Don't forget to break.
@DevD01 You should however return count + " Bet" (note that extra space, as there should be one between the number and the word) in your if-else (which does not need a second if).
Mo Zargham
@Mozar10
Nov 23 2016 09:46 UTC
@DevD01 and you should delete return "Change Me" eventhough you won't ever reach it
Aditi Roy
@AlluringAditi
Nov 23 2016 09:47 UTC
@Mozar10 @Blauelf :
var count = 0;
function cc(card) {
switch (card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
break;
case 10:
case 'A':
case 'J':
case 'K':
case 'Q':
count--;
break;
}
if(count > 0){
return count +"Bet";
}
else
return count+"Hold";
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Mo Zargham
@Mozar10
Nov 23 2016 09:48 UTC
return count + " Bet";
and return count + " Hold";
Blauelf
@Blauelf
Nov 23 2016 09:48 UTC

@DevD01 Remember what I said about the space?

@DevD01 You should however return count + " Bet" (note that extra space, as there should be one between the number and the word) in your if-else (which does not need a second if).

Aditi Roy
@AlluringAditi
Nov 23 2016 09:49 UTC
@Blauelf @Mozar10 right on it, checking that!
@Blauelf @Mozar10 Yayyyyyyy!!
it worked!!
Thanks guys!!
Blauelf
@Blauelf
Nov 23 2016 09:50 UTC
:+1:
Mo Zargham
@Mozar10
Nov 23 2016 09:50 UTC
:thumbsup:
J. Kilgore
@jkilgore07
Nov 23 2016 09:50 UTC
@Blauelf @Mozar10 hmmmm. maybe im getting caught up onn the wrong thing, but i am confused as to how the equation knows to pull the correct input numbers to plug in where (celsius) is?
Mo Zargham
@Mozar10
Nov 23 2016 09:51 UTC
when you call the function at the end you are giving it a number right? that is the Celsius value
Blauelf
@Blauelf
Nov 23 2016 09:52 UTC
@jkilgore07 When you call convertToF with convertToF(30), its first parameter will receive the value 30. That parameter is named celsius, and behaves about like a pre-initialized variable, initialized to that value 30. Name is arbitrary, but that's how you can access the argument passed to your function.
function greet(name) {
  console.log("Hello, " + name);
}
greet("Blauelf"); // prints Hello, Blauelf
Mo Zargham
@Mozar10
Nov 23 2016 09:53 UTC
@jkilgore07 Whatever number you use as the argument i.e. inside the brackets when you call the function, is the value of Celsius, That's how the function knows....
convertToF(50) means Celsius is 50, convertToF(20) means Celsius is 20 and so on...
J. Kilgore
@jkilgore07
Nov 23 2016 09:56 UTC
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Blauelf
@Blauelf
Nov 23 2016 09:56 UTC
@jkilgore07 In my example, I pass "Blauelf" as the first argument. That value is then assigned to the parameter variable name in my function, which I can use to access the string.
J. Kilgore
@jkilgore07
Nov 23 2016 09:56 UTC
these are the checks for the test
Daria Doronina
@Skidle
Nov 23 2016 09:56 UTC
I'm on a "Falsy Bouncer" challenge now and this code works for everything but that particular arr How can I fix this, please?

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    Boolean(arr[i]);
    if (Boolean(arr[i]) === false) {
     newArr = arr.filter(Boolean);
    } else 
      newArr = arr;
  } 
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
J. Kilgore
@jkilgore07
Nov 23 2016 09:57 UTC

i only put in 30 at the bottom to define celsius so why is solving all the others as well?
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit=celsius*1.8+32;

// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(30);

Mo Zargham
@Mozar10
Nov 23 2016 09:58 UTC
@jkilgore07 The test cases are to ensure that your solution is written correctly, and not specifically for one scenario
°C x 9/5 + 32
@jkilgore07 use 9/5
J. Kilgore
@jkilgore07
Nov 23 2016 10:00 UTC
@Mozar10 ok lol. i was so confused on how it was getting the other answers when i didnt input them. I thought i was completely lost.thanks
Mo Zargham
@Mozar10
Nov 23 2016 10:01 UTC
:thumbsup:
J. Kilgore
@jkilgore07
Nov 23 2016 10:01 UTC
@Blauelf thank you as well. Makes perfect sense now
CamperBot
@camperbot
Nov 23 2016 10:01 UTC
jkilgore07 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2987 | @blauelf |http://www.freecodecamp.com/blauelf
Daria Doronina
@Skidle
Nov 23 2016 10:02 UTC

I'm on a "Falsy Bouncer" challenge now and this code works for everything but that particular arr How can I fix this, please?

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    Boolean(arr[i]);
    if (Boolean(arr[i]) === false) {
     newArr = arr.filter(Boolean);
    } else 
      newArr = arr;
  } 
  return newArr;
}

bouncer([7, "ate", "", false, 9]);

Do I need another if condition maybe?

Ashirwad Joshi
@aashu1829
Nov 23 2016 10:03 UTC
Hi All
Hope you all are doing great
Can someone please help me with "Using Objects for Lookups"
Daria Doronina
@Skidle
Nov 23 2016 10:04 UTC
@aashu1829 what is the problem?
Ashirwad Joshi
@aashu1829
Nov 23 2016 10:04 UTC
I am not able to get what needs to be done here
Daria Doronina
@Skidle
Nov 23 2016 10:05 UTC
@aashu1829 do you have an object set up?
Blauelf
@Blauelf
Nov 23 2016 10:05 UTC
@jkilgore07 You will see that in all the algorithmic challenges, your code is run once (and there's usually a sample test case inside, so you can check if it's likely correct), and then the function you are meant to implement is run by the test cases multiple times, with different input.
Ashirwad Joshi
@aashu1829
Nov 23 2016 10:05 UTC
@Skidle yeah I have created the lookup
how can I share the code here
so that everyone can see
Blauelf
@Blauelf
Nov 23 2016 10:05 UTC
@Skidle Either use a loop and push all truthy elements to the new array, or use filter. Don't do both.
Daria Doronina
@Skidle
Nov 23 2016 10:06 UTC
@aashu1829 you copy it and paste inside backticks ` (3 backticks on the each side of code)
Mateusz Kadlubowski
@xeho91
Nov 23 2016 10:06 UTC
@aashu1829 You need to assign the certain value in lookup object to result
@aashu1829 because so far result always is equal to ""
Daria Doronina
@Skidle
Nov 23 2016 10:08 UTC
@Blauelf wow thanks! maybe you can also explain why it works if I only use one of them? It works but I don't understand why :(
CamperBot
@camperbot
Nov 23 2016 10:08 UTC
skidle sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2988 | @blauelf |http://www.freecodecamp.com/blauelf
J. Kilgore
@jkilgore07
Nov 23 2016 10:09 UTC
@Blauelf ya i was thinking i had to use converToF(30) in the actual equation and keep changing the numbers in the argument, and have 6 different equations. Thanks alot
CamperBot
@camperbot
Nov 23 2016 10:09 UTC
jkilgore07 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: jkilgore07 already gave blauelf points
Ashirwad Joshi
@aashu1829
Nov 23 2016 10:10 UTC

~~~// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup={

 alpha: "Adams",


bravo : "Boston",


charlie:  "Chicago",


delta:  "Denver",


echo:  "Easy",

foxtrot: "Frank"
};

// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("charlie");
~~~

Daria Doronina
@Skidle
Nov 23 2016 10:11 UTC
@Blauelf I think I GOT IT thanks! :laughing: I was trying to explain my opinion here and suddenly I understood it xD
CamperBot
@camperbot
Nov 23 2016 10:11 UTC
skidle sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave blauelf points
Blauelf
@Blauelf
Nov 23 2016 10:11 UTC

@Skidle filter iterates an array, so you don't need to. So those two are about equivalent:

  var newArr = arr.filter(Boolean);

and

  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    if (Boolean(arr[i])) {
      newArr.push(arr[i]);
    }
  }

but as if does its own conversion to boolean (just for evaluation), this would work, too:

  var newArr = [];
  for (var i = 0; i < arr.length; i++) {
    if (arr[i]) {
      newArr.push(arr[i]);
    }
  }

and filter works the same, does not rely on true/false but truthy/falsy:

  var newArr = arr.filter(function(x){ return x; });
darkflikk
@darkflikk
Nov 23 2016 10:12 UTC
@Blauelf hey, i have a question for you :)
Daria Doronina
@Skidle
Nov 23 2016 10:12 UTC
@Blauelf thank you very much for the explanation!
CamperBot
@camperbot
Nov 23 2016 10:12 UTC
skidle sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave blauelf points
darkflikk
@darkflikk
Nov 23 2016 10:16 UTC
@Blauelf
table.selectAll("tbody  .table-row").each(function(trData) {
    var needed = trData.value.attribute;
    $(this).on("click", function(e) {
        document.location = "tesst.html#" + needed;  // how do i get "needed" in here?
    }
}
Blauelf
@Blauelf
Nov 23 2016 10:18 UTC
@darkflikk The needed inside the callback is actually the needed from the scope it was defined in. So whatever value trData.value.attribute had at that time.
darkflikk
@darkflikk
Nov 23 2016 10:18 UTC
So it should work?
Blauelf
@Blauelf
Nov 23 2016 10:19 UTC
@darkflikk If that variable has meaningful content, it should. The file name "tesst.html" is interesting :D
Anthony Drane
@Antiaccess
Nov 23 2016 10:19 UTC
Anyone here familiar with a wait or time delay function? I'm using setTimeout but it isn't working the way I want
darkflikk
@darkflikk
Nov 23 2016 10:20 UTC
@Blauelf haha, do i need the variable "needed" or can i use the "trData"?
Blauelf
@Blauelf
Nov 23 2016 10:20 UTC
@Antiaccess What do you want? Some "wait 10s, then continue in the same function"? There can be only one code running at a given time, so that would block the browser for 10s, that's why we use asynchronous callbacks.
@darkflikk You can, sure, parameters are essentially like function-scope variables, just pre-initialized.
darkflikk
@darkflikk
Nov 23 2016 10:21 UTC
@Blauelf Just tested it. looks like i don't need the "needed" variabkle :D
Anthony Drane
@Antiaccess
Nov 23 2016 10:21 UTC
okay, is there a good resource on asyncronous callbcks @Blauelf
?
darkflikk
@darkflikk
Nov 23 2016 10:24 UTC

@Blauelf

table.selectAll("tbody  .table-row").each(function(trData) {
    $(this).on("click", function(e) {
        document.location = "tesst.html#" + trData.value.attribute;
    }
}

ok, now i know how it works. though i don't want to change document location but open a modal with a table that contains more information about that data set :)

@Blauelf thanks
CamperBot
@camperbot
Nov 23 2016 10:24 UTC
darkflikk sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2989 | @blauelf |http://www.freecodecamp.com/blauelf
darkflikk
@darkflikk
Nov 23 2016 10:24 UTC
you're almost at 3k ;)
Markus Kiili
@Masd925
Nov 23 2016 10:25 UTC
@darkflikk Yes, now only points for @Blauelf for really solid advice. We don't wan't him to think he got it in vain.
Blauelf
@Blauelf
Nov 23 2016 10:26 UTC
@darkflikk But note that if you use the extra variable, it will use trData.value.attribute of the definition time. If you use it directly, and trData has been changed in the meantime (probably not relevant here), you might get other values.
Markus Kiili
@Masd925
Nov 23 2016 10:27 UTC
@darkflikk Me you can reward loosely, because I have 2985 and I wan't to beat him.
Blauelf
@Blauelf
Nov 23 2016 10:27 UTC
about @Masd925
CamperBot
@camperbot
Nov 23 2016 10:27 UTC
:star2: 2985 | @masd925 |http://www.freecodecamp.com/masd925
darkflikk
@darkflikk
Nov 23 2016 10:27 UTC
@Blauelf you are wrong. it is relevant ;)
Blauelf
@Blauelf
Nov 23 2016 10:27 UTC
That's close.
theCember
@theCember
Nov 23 2016 10:28 UTC
hey everybody, could someone check one of my exercies from freecodecamp, cause there are 2 test that I can't go through :/
WAINGOR
@WAINGOR
Nov 23 2016 10:28 UTC
Hi all
darkflikk
@darkflikk
Nov 23 2016 10:29 UTC
@Blauelf at least i think so
@Blauelf would have to check
WAINGOR
@WAINGOR
Nov 23 2016 10:29 UTC
I have a question on JS: why does the JS documentation keep talking about "prototype" inside of array functions like here: Array.prototype.reverse()
and when you look at their examples they never use "prototype" in these function names...
Blauelf
@Blauelf
Nov 23 2016 10:32 UTC
@WAINGOR If you say arr.slice(), your array arr does not have a property "slice". It is found on the prototype chain on Array.prototype, so you essentially call Array.prototype.slice, and set the this to arr, all that happens in a convenient arr.slice().
J Player
@Heyjp
Nov 23 2016 10:33 UTC
@theCember just post your code someone will be able to help
darkflikk
@darkflikk
Nov 23 2016 10:33 UTC
@Blauelf hmm, maybe it is not relevant. But since i am not 100% sure yet, i'll just use the trData. Building a statistic site with graphs using dc.js
theCember
@theCember
Nov 23 2016 10:34 UTC
Okay, i put it here
WAINGOR
@WAINGOR
Nov 23 2016 10:34 UTC
aha! So do I understand correctly that this type of calling a function "borrows" a method from this so called prototype chain? @Blauelf
Blauelf
@Blauelf
Nov 23 2016 10:34 UTC
@WAINGOR Those functions exist once for all arrays, or all strings, on a common prototype. Whenever you say new Array() (or an implicit version of that), the created object will have Array set as the constructor and Array.prototype installed in its prototype chain.
Anthony Drane
@Antiaccess
Nov 23 2016 10:34 UTC
@Blauelf You seem busy, but if you get a moment (i'll be around for a bit) can you tell me how you might turn this simon game's timing events to work 'asynchronously': https://codepen.io/antiaccess/pen/wogRwp
darkflikk
@darkflikk
Nov 23 2016 10:34 UTC
@Masd925 i will thank you whenever you can help me, so the competition between you and blauelf is fair. haha. (there, have some points)
CamperBot
@camperbot
Nov 23 2016 10:34 UTC
darkflikk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2986 | @masd925 |http://www.freecodecamp.com/masd925
theCember
@theCember
Nov 23 2016 10:34 UTC
It is record collection exercie from javascript
darkflikk
@darkflikk
Nov 23 2016 10:35 UTC
Oh, totaly unintentional
Blauelf
@Blauelf
Nov 23 2016 10:35 UTC
@WAINGOR It's called delegation. What isn't found at the current object is delegated to its associated prototype object.
WAINGOR
@WAINGOR
Nov 23 2016 10:35 UTC
allright thanks
how do I send brownie points?
J Player
@Heyjp
Nov 23 2016 10:36 UTC
@theCember you can post your code directly to gitter, just follow the style guidelines https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Code-Formatting
Blauelf
@Blauelf
Nov 23 2016 10:36 UTC
@WAINGOR Mention someone (@Name) and use some variation of "thank you" in the same sentence.
WAINGOR
@WAINGOR
Nov 23 2016 10:36 UTC
@Blauelf thank you !
CamperBot
@camperbot
Nov 23 2016 10:36 UTC
waingor sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 2990 | @blauelf |http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Nov 23 2016 10:36 UTC
@Masd925 :P
darkflikk
@darkflikk
Nov 23 2016 10:36 UTC
@Blauelf why didnt you give him points with that?
Myroili
@Myroili
Nov 23 2016 10:36 UTC
i have problem with counting card in java script
WAINGOR
@WAINGOR
Nov 23 2016 10:36 UTC

```function reverseString(str) {
str.split("");
str.reverse();
str.join();
return str;
}

reverseString("hello");```

``` function reverseString(str) {
str.split("");
str.reverse();
str.join();
return str;
}

reverseString("hello");

theCember
@theCember
Nov 23 2016 10:37 UTC

var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
//myObj.hasOwnProperty(checkProp)
if(prop=="artist"&&value!==""){
collection[id].artist = value;
} else if (prop==="artist"&&value===""){
delete collection[id].artist;
} else if (prop==="tracks"&&value!==""){
delete collection[id].artist;
} else if (prop==="tracks"&&value===""){
delete collection[id].tracks;
} else if (prop==="tracks"&&value!==""){
collection[id].tracks.push(value);
} else if (prop==="tracks"&&value!==""&&collection[id].hasOwnProperty(prop)){
collection[id].tracks.push(value);
} else if (prop==="tracks"&&value!==""&&collection[id].hasOwnProperty(prop)===false){
var tracks = [value];
collection[id] = tracks;
}

return collection;
}

oops im sorry
WAINGOR
@WAINGOR
Nov 23 2016 10:37 UTC
hmmm how do I send code in this chat again?
I messed up too XD
Stanley Su
@cuddlycuddles
Nov 23 2016 10:38 UTC
@WAINGOR use ``` before and after your code
Myroili
@Myroili
Nov 23 2016 10:38 UTC

var count=0;

function cc(card) {
// Only change code below this line

switch (card) {
case 2,3,4,5,6:
count=count+1;

  break;
case 7,8,9:
  break;
case 10,"J","Q","K","A":
  count=-1;
  break;
  }
   if(count>0){
     return count;
   }else {
     return count;
   }

return "Change Me";
// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2);
cc(7);
cc(9);
cc(7);
cc(8);

darkflikk
@darkflikk
Nov 23 2016 10:39 UTC
☨est
ah i see
Stanley Su
@cuddlycuddles
Nov 23 2016 10:39 UTC
@WAINGOR You should try to define each of those lines, that's what I did and it helped. Or you can do it all in one line, by combining the methods.