These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Nov 2016
Joseph
@revisualize
Nov 23 2016 00:00
@domuttel No.
You're supposed to re-assign the result variable.
But, meh.
Dominic Muttel
@domuttel
Nov 23 2016 00:01
Oh I see then so I guess I gotta get more smarts together
lol
Joseph
@revisualize
Nov 23 2016 00:01
What's the point of doing this...
Dominic Muttel
@domuttel
Nov 23 2016 00:01
haha
Joseph
@revisualize
Nov 23 2016 00:01
result = thing.thinger;
return result;
Why not just do...
return thing.thinger;
Dominic Muttel
@domuttel
Nov 23 2016 00:02
As to have clear code?
Joseph
@revisualize
Nov 23 2016 00:02
The top one is not clearer than the bottom one.
Dominic Muttel
@domuttel
Nov 23 2016 00:03
Hmmmmm...
Joseph
@revisualize
Nov 23 2016 00:03
@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
No I think I see what you are saying
Joseph
@revisualize
Nov 23 2016 00:04
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
I see
Joseph
@revisualize
Nov 23 2016 00:05
BUT! If you get into a function that calls another function .. Maybe it would be better.
Dominic Muttel
@domuttel
Nov 23 2016 00:05
Right! I totally see wat you are saying
tommy
@tommygebru
Nov 23 2016 00:06
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
@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
Red light, Green light, refactor
Joseph
@revisualize
Nov 23 2016 00:07
Though... Seek and Destroy is still my original code.. I think.
Dominic Muttel
@domuttel
Nov 23 2016 00:08
hahahaha
Joseph
@revisualize
Nov 23 2016 00:08
Oh,.... I did refactor that one.
Dominic Muttel
@domuttel
Nov 23 2016 00:08
I dig
Joseph
@revisualize
Nov 23 2016 00:08
That challenge SUCKS!
Anyhow!
Dominic Muttel
@domuttel
Nov 23 2016 00:10
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
having a problem with----Adding a default option in Switch statements
Dominic Muttel
@domuttel
Nov 23 2016 00:13
@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

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
put the break in the if
SoteroX
@SoteroX
Nov 23 2016 00:15
try that already
Yang Lu
@ylu01
Nov 23 2016 00:15
actually no, you do case "a"
so the if is not necessary
SoteroX
@SoteroX
Nov 23 2016 00:17
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
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

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
@domuttel return lagest numbers in array
Stephen James
@sjames1958gm
Nov 23 2016 00:23
@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
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
@cdomiano If you read the docs on slice - a single slice will do the trick here
OleksandrNedobitkov
@OleksandrNedobitkov
Nov 23 2016 00:27
I have a problem with writing escape sequences
Caden Damiano
@cdomiano
Nov 23 2016 00:27
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
@cdomiano Does slice modify the array in place?
Stephen James
@sjames1958gm
Nov 23 2016 00:28
@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
@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
@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
@OleksandrNedobitkov What do you have so far
Caden Damiano
@cdomiano
Nov 23 2016 00:33
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
@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
@cdomiano or you cant just use splice
Matt
@airborneprayer
Nov 23 2016 00:38
Hello world!
CamperBot
@camperbot
Nov 23 2016 00:38

welcome to FreeCodeCamp @airborneprayer!

TheMightyPingu
@TheMightyPingu
Nov 23 2016 00:38
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
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
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
@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
I'm new to this guys I need big time help.
Stephen James
@sjames1958gm
Nov 23 2016 00:40
This is the place for big time help :)
Emily Christensen
@emmalee113
Nov 23 2016 00:40
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
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
some people use api, i hard coded a bunch in @emmalee113
Daria Doronina
@Skidle
Nov 23 2016 00:44
@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
@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
@emmalee113 This is one way:
http://codepen.io/JohnnyBizzel/pen/QGvvob
Yang Lu
@ylu01
Nov 23 2016 00:45
@emmalee113 if the box is a div you can just next them in that
Stephen James
@sjames1958gm
Nov 23 2016 00:45
@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
@ylu01 nest all my javascript in the div?
@sjames1958gm would that simply go in my <h3> ?
Stephen James
@sjames1958gm
Nov 23 2016 00:47
@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
Seek and Destroy bonfire, can anyone guide me please?
Johnny
@JohnnyBizzel
Nov 23 2016 00:49
@marioecg Filter out the unwanted numbers
Array.filter() method
LB
@lbg232
Nov 23 2016 00:50
@marioecg https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter the first example shows well what you need to do.
Steve
@marioecg
Nov 23 2016 00:50
@JohnnyBizzel @lbg232 same as with the Falsy bonfire?
Johnny
@JohnnyBizzel
Nov 23 2016 00:50
@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
@JohnnyBizzel thanks
CamperBot
@camperbot
Nov 23 2016 00:51
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
i dont understand .keys() at all
can someone help me udnerstand
Emily Christensen
@emmalee113
Nov 23 2016 00:52

@JohnnyBizzel so i have this:

<div>
<h3 class = quotebox>

quote

</h3>

</div>

Johnny
@JohnnyBizzel
Nov 23 2016 00:52
@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
@lbg232 thnks
LB
@lbg232
Nov 23 2016 00:53
@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
In: Testing Objects for Properties... Do I need a for loop?
Steve
@marioecg
Nov 23 2016 00:53
@lbg232 alright, thanks
CamperBot
@camperbot
Nov 23 2016 00:53
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
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
@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
@domuttel what's your query?
Moisés Man
@moigithub
Nov 23 2016 00:59
wonder why [0] at the end @domuttel
also probably u should use hasOwnProperty
this is mine
LB
@lbg232
Nov 23 2016 00:59
@domuttel
myObj.hasOwnProperty(...)
Emily Christensen
@emmalee113
Nov 23 2016 00:59
@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
emmalee113 sends brownie points to @ylu01 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ylu01
Yang Lu
@ylu01
Nov 23 2016 01:00
np
Joanna
@Joanna15
Nov 23 2016 01:00
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
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');
});
LB
@lbg232
Nov 23 2016 01:00
@ylu01 "China - Donald Tromp" X,DDD
tramp*
Anthony Drane
@Antiaccess
Nov 23 2016 01:00
Here's the codepen for anyone who can help
https://codepen.io/antiaccess/pen/wogRwp
Yang Lu
@ylu01
Nov 23 2016 01:00
@lbg232 trump*
Anthony Drane
@Antiaccess
Nov 23 2016 01:01
try clicking on green
ADIL KARMOUZI
@mradil16
Nov 23 2016 01:02
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
looking for some assistance on this js challenge
Dominic Muttel
@domuttel
Nov 23 2016 01:03
@lbg232 Do I need a if else?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:03
@Antiaccess Your this might be out of scope
JacobY
@jyelton4
Nov 23 2016 01:04
I can't get past the 'no global myVar variable' test
tommy
@tommygebru
Nov 23 2016 01:06
@revisualize yeah same here and my front-end html/css was horrible too :smile:
Walid Ashri
@walidashri
Nov 23 2016 01:07
@jyelton4 your code please
@Joanna15 what is the issue?
JacobY
@jyelton4
Nov 23 2016 01:08
@walidashri I just needed to refresh apparently, code was correct
Walid Ashri
@walidashri
Nov 23 2016 01:08
@jyelton4 :) :+1:
Richie
@Richie2
Nov 23 2016 01:09
Hello campers
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:10
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
Hello Rich :)
Dominic Muttel
@domuttel
Nov 23 2016 01:10

// 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
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
Hi Walid :smile:
Walid Ashri
@walidashri
Nov 23 2016 01:12
@BrennanGlynn cauze all the time this is true collection[element].pre === undefined)
Brennan Glynn
@BrennanGlynn
Nov 23 2016 01:12
@walidashri mhhhhh thanks haha
CamperBot
@camperbot
Nov 23 2016 01:12
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
@Antiaccess It works fine for me
Joanna
@Joanna15
Nov 23 2016 01:12
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
How do you check for all the values like null undefined NaN etc...?
Richie
@Richie2
Nov 23 2016 01:14
@BrennanGlynn try stepping through with debugger; then you can see actually happen
Moisés Man
@moigithub
Nov 23 2016 01:14
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
@Richie2 do I have to code in a seperate program to do that?
Richie
@Richie2
Nov 23 2016 01:15
@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
@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
It still doesn't work..
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:19
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
@OsakaStarbux Yes 3 tick before code then 3 ticks after
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:20
thanks!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:20
@OsakaStarbux 3 backticks before the code, 3 backticks after
coffeebeanzz
@coffeebeanzz
Nov 23 2016 01:20
'''
CamperBot
@camperbot
Nov 23 2016 01:20
:bulb: to format code use backticks! ``` more info
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:21

```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
The backticks have to be on their own lines
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:21
sorry
coffeebeanzz
@coffeebeanzz
Nov 23 2016 01:21
Np
lowcities
@lowcities
Nov 23 2016 01:21
@OsakaStarbux press shift +enter to do a line break after ticks
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:22
ha! my next question
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:22
No problem @OsakaStarbux . Try again
lowcities
@lowcities
Nov 23 2016 01:22
Does anyone have any advice for me? I posted some code further up the chat
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:24
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
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
I'm guessing my regex might be wrong but..
Walid Ashri
@walidashri
Nov 23 2016 01:25
@lowcities you need only one loop
Anthony Drane
@Antiaccess
Nov 23 2016 01:25
@djcase001 thanks for replying. I wonder why it would work for you and not me
CamperBot
@camperbot
Nov 23 2016 01:25
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
[1,2,3].map(n=>{num: n}) this returns an array of undefined
lowcities
@lowcities
Nov 23 2016 01:26
@walidashri Ahh OK, I'll try that, Thanks!
CamperBot
@camperbot
Nov 23 2016 01:26
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
@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
@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
@djcase001 no, it stays solid light-green
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:28
OK I'm gonna check your codepen to see what the problem is
Aaron Bell
@awb715
Nov 23 2016 01:28
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
@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
@djcase001 thanks
CamperBot
@camperbot
Nov 23 2016 01:29
:warning: antiaccess already gave djcase001 points
antiaccess sends brownie points to @djcase001 :sparkles: :thumbsup: :sparkles:
Aaron Bell
@awb715
Nov 23 2016 01:29
ive read about a for in while loop, is that something i need to use
Arnaud Casamé
@arnaudcasame
Nov 23 2016 01:29
Send me your codepen
Adress
Aaron Bell
@awb715
Nov 23 2016 01:29
me?
lowcities
@lowcities
Nov 23 2016 01:30
@MoNag1 Yup, that does it, Thanks!
CamperBot
@camperbot
Nov 23 2016 01:30
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
@wordyallen [1,2,3].map(n=>{return{'num': n}})
Kevin Bradley
@OsakaStarbux
Nov 23 2016 01:33
thanks @coffeebeanzz
CamperBot
@camperbot
Nov 23 2016 01:33
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
thanks @lowcities
CamperBot
@camperbot
Nov 23 2016 01:33
osakastarbux sends brownie points to @lowcities :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @lowcities |http://www.freecodecamp.com/lowcities
Richie
@Richie2
Nov 23 2016 01:33
@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
@walidashri did you see my code
Joanna
@Joanna15
Nov 23 2016 01:38
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
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
Escape sequences in strings
Dominic Muttel
@domuttel
Nov 23 2016 01:45
@djcase001
```
jrr5230
@jrr5230
Nov 23 2016 01:46
@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
@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
@Joanna15 yeah what @jrr5230 said
CamperBot
@camperbot
Nov 23 2016 01:47
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
@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
Im struggling with how to show the value in an objects list of name value pairs
Walid Ashri
@walidashri
Nov 23 2016 01:48
@awb715 you need to loop through hold items it's an array
Joanna
@Joanna15
Nov 23 2016 01:48
The point is that everything is correct but text is still coded
Coy Sanders
@coymeetsworld
Nov 23 2016 01:49
@domuttel your return statement if you find the property doesn't look right
jrr5230
@jrr5230
Nov 23 2016 01:49
@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
@Joanna15 no theres some problems with your string
Dominic Muttel
@domuttel
Nov 23 2016 01:49
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
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
Hello,
I've found bug in Chunky Monkey course.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:50
take that line and replace the words like newline with its code in the table above
Joanna
@Joanna15
Nov 23 2016 01:50
I've got it thank you..
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:50
The result is correct, but i can't pass the course.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:51
nothing more or less
Spencer Kuzara
@kodaxx
Nov 23 2016 01:51
Anyone skilled with node.js in here?
Coy Sanders
@coymeetsworld
Nov 23 2016 01:51
ok
jrr5230
@jrr5230
Nov 23 2016 01:51
@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
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
@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
@domuttel were you able to pass that lesson with your code?
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:51

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
@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
Then how can i solve this problem?
I just need to use global variables
Coy Sanders
@coymeetsworld
Nov 23 2016 01:54
you dont need global variables to solve this
Andrei Luca
@AndreiLuca99
Nov 23 2016 01:54
if not, it's complicated to finish this one.
Coy Sanders
@coymeetsworld
Nov 23 2016 01:54
try using a for loop instead of recursion to iterate through the array
Walid Ashri
@walidashri
Nov 23 2016 01:55
@chhuang are you sure of this quotes? ‘input’ ‘hello!’;
Matt
@Matteoo7
Nov 23 2016 01:57
@kodaxx I'm not, but a lot of the folks here https://gitter.im/nodejs/node are
Chang
@chhuang
Nov 23 2016 01:57
@walidashri yep
DestroyingLight
@DestroyingLight
Nov 23 2016 02:02
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
looks ok to me at first glance @DestroyingLight, is there a problem with it
DestroyingLight
@DestroyingLight
Nov 23 2016 02:05
it works, but in terms of style, can it be done better?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:05
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
curr.length >= accu.length ? curr : accu
like that?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:08
think you need the return statement still
but you can put it at the beginning once
DestroyingLight
@DestroyingLight
Nov 23 2016 02:10
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
i think it just works
DestroyingLight
@DestroyingLight
Nov 23 2016 02:11
it shows me warnings
chazztizer
@chazztizer
Nov 23 2016 02:11

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
blob
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12
warnings aren't a big deal
DestroyingLight
@DestroyingLight
Nov 23 2016 02:12
can you see it there?
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12
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
@chazztizer indexOf returns -1 when it cannot find element in args
Coy Sanders
@coymeetsworld
Nov 23 2016 02:12
yeah im trying it now
Walid Ashri
@walidashri
Nov 23 2016 02:12
@chhuang it's not valid :)
Stephen James
@sjames1958gm
Nov 23 2016 02:13
@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
@walidashri what is not valid?
chazztizer
@chazztizer
Nov 23 2016 02:14
@sjames1958gm So arr is being returned, but is filtering out the "element" of args?
Walid Ashri
@walidashri
Nov 23 2016 02:14
@chhuang the qoutes it's " or '
@DestroyingLight add 'jshint esversion:6' as 1st line in ur code
Chang
@chhuang
Nov 23 2016 02:15
sorry I may have put in the wrong quote, but the problem is not the quote
Stephen James
@sjames1958gm
Nov 23 2016 02:15
@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
@sjames1958gm Maybe i'm just dumb. Thanks though
CamperBot
@camperbot
Nov 23 2016 02:17
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
@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
walidashri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 23 2016 02:18
@DestroyingLight
return str.split(' ').reduce((accu, curr) => accu > curr.length ? accu : curr.length, 0);
CamperBot
@camperbot
Nov 23 2016 02:18
:star2: 4481 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 23 2016 02:18
@walidashri Hello -
DestroyingLight
@DestroyingLight
Nov 23 2016 02:20
@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
return str.split(" ").sort().shift().length;
DestroyingLight
@DestroyingLight
Nov 23 2016 02:25
@moigithub that sorts a alphabetically
I think
Moisés Man
@moigithub
Nov 23 2016 02:25
yea.. probably need a callback on sort...
.sort((a,b)=>a.length-b.length)
DestroyingLight
@DestroyingLight
Nov 23 2016 02:26
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
@DestroyingLight /*jshint esversion: 6 */
DestroyingLight
@DestroyingLight
Nov 23 2016 02:28
thanks @walidashri ! no warnings now
CamperBot
@camperbot
Nov 23 2016 02:28
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
@DestroyingLight const findLongestWord = str => Math.max(...str.split(' ').map(w => w.length))
Dominic Muttel
@domuttel
Nov 23 2016 02:36
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
Am I meant to update the object before I start?
Chang
@chhuang
Nov 23 2016 02:43
@walidashri https://jsfiddle.net/pe46d6tp/1/ you can try it in there
Terryd12345
@Terryd12345
Nov 23 2016 02:44
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
@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
@walidashri thanks!
CamperBot
@camperbot
Nov 23 2016 02:46
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
@cdrainxv shut up
blob
@chhuang
yoojuu
@yoojuu
Nov 23 2016 02:48
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
@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
@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
@Terryd12345 OK so this will take a bit of work!
Terryd12345
@Terryd12345
Nov 23 2016 02:50
@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
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
@DikoFaji by its name
Dominic Muttel
@domuttel
Nov 23 2016 02:52
^ assign it to a variable?
:|
Moisés Man
@moigithub
Nov 23 2016 02:52
to CALL a function add a set of () at the end of its name
Emerson
@DikoFaji
Nov 23 2016 02:53
@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
@DikoFaji you gotta use a built-in JS function in this exercise
Emerson
@DikoFaji
Nov 23 2016 02:57
and i thought that by returning the var func will run the function. but not
alex_wang
@wangzhenalex
Nov 23 2016 02:57
How to make a regular expression matching Symbol “:” in JavaScript
Arnaud Casamé
@arnaudcasame
Nov 23 2016 02:58
@DikoFaji go take a look back at the built-in array methods
Walid Ashri
@walidashri
Nov 23 2016 03:00
@chhuang debugger issue
Emerson
@DikoFaji
Nov 23 2016 03:01
@djcase001 my question now is why is the function is placed in argument func?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:02
@DikoFaji it is a callback function that executes once you call the main function
Alejandro Tejada
@wannabecoding
Nov 23 2016 03:04
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
@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
@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
@wannabecoding I'd use an if statement instead
Emerson
@DikoFaji
Nov 23 2016 03:07
@djcase001 i think im getting it. ok ill try first
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:08
@DikoFaji ok bro
Alejandro Tejada
@wannabecoding
Nov 23 2016 03:10
@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
@wannabecoding definitely much easier
@wannabecoding
```
@wannabecoding
if(card >= 2 && card <= 6){
     // your logic
}
jrr5230
@jrr5230
Nov 23 2016 03:14
@wannabecoding nah...it'll be like count ++;
count--;
KT
@Krystinet
Nov 23 2016 03:15
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
then answer = count + string
MoNag1
@MoNag1
Nov 23 2016 03:15
@Krystinet let us see what you have so far or at least what you tried
Chang
@chhuang
Nov 23 2016 03:15
@walidashri thanks!
CamperBot
@camperbot
Nov 23 2016 03:15
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
@Krystinet tell me more
KT
@Krystinet
Nov 23 2016 03:16
@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
@Krystinet Ok. So you'll have to rewrite it . I'll help you
MoNag1
@MoNag1
Nov 23 2016 03:17
@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
yes
MoNag1
@MoNag1
Nov 23 2016 03:18
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
@Krystinet what challenge is it??
KT
@Krystinet
Nov 23 2016 03:18
so arr.push(item)?
@djcase001 stand in line
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:19
basic, intermediate or Advanced
MoNag1
@MoNag1
Nov 23 2016 03:19
@Krystinet yep, that's the first step done already
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:19
???
KT
@Krystinet
Nov 23 2016 03:19
right
MoNag1
@MoNag1
Nov 23 2016 03:19
@djcase001 i believe its under basic javascript?
KT
@Krystinet
Nov 23 2016 03:19
Yes javascript
MoNag1
@MoNag1
Nov 23 2016 03:20
@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
.pop
MoNag1
@MoNag1
Nov 23 2016 03:21
@Krystinet close, pop removes last element
what you're looking for is shift
KT
@Krystinet
Nov 23 2016 03:21
Right!
(sorry I did those sections twice but haven't gone back in about a week!)
MoNag1
@MoNag1
Nov 23 2016 03:22
dw we all forget, do you know how you can apply .shift()?
KT
@Krystinet
Nov 23 2016 03:23
variableName.shift()?
Joseph
@revisualize
Nov 23 2016 03:24

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

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
@Krystinet alright send your code knowing what you know now
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:28
@Krystinet first push the item, and then shift the array into item
Joseph
@revisualize
Nov 23 2016 03:28
But, you know.. meh.
KT
@Krystinet
Nov 23 2016 03:32
Do I have to set arr and item to something?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:33
@Krystinet
Joseph
@revisualize
Nov 23 2016 03:33
@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
@revisualize loll
KT
@Krystinet
Nov 23 2016 03:35
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
@Krystinet item isn't an array.
MoNag1
@MoNag1
Nov 23 2016 03:35
@Krystinet you should shift arr and not item
Joseph
@revisualize
Nov 23 2016 03:36
@Krystinet function nextInLine which has two parameters an array (arr) and a number (item).
MoNag1
@MoNag1
Nov 23 2016 03:36
@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
@Krystinet
item = arr.shift()
KT
@Krystinet
Nov 23 2016 03:37

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
@Krystinet Why did you change the order?
KT
@Krystinet
Nov 23 2016 03:38
Ahhh
I DONT KNOW
jrr5230
@jrr5230
Nov 23 2016 03:38
@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
@Krystinet :point_up: November 22, 2016 7:26 PM
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:38
@Krystinet
KT
@Krystinet
Nov 23 2016 03:39

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
@Krystinet Why are you overwriting item?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:39
@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
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
@revisualize that's how i solved it
Joseph
@revisualize
Nov 23 2016 03:40
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
@revisualize You're maybe the one who's wrong there
Joseph
@revisualize
Nov 23 2016 03:40
Maybe I am.
jrr5230
@jrr5230
Nov 23 2016 03:40
I did it completely different @djcase001
like @revisualize no need to overwrite
KT
@Krystinet
Nov 23 2016 03:41

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
@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
@Krystinet you have to push in an item into the array
Joseph
@revisualize
Nov 23 2016 03:43
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
looks right to me +1:
Joseph
@revisualize
Nov 23 2016 03:44
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
function nextInLine(arr, item) {
// Your code here
arr.push(item);
return arr.shift; // Change this line
}
Joseph
@revisualize
Nov 23 2016 03:45
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

$%@$%^%^

Joseph
@revisualize
Nov 23 2016 03:46
It's called a Queue.
jrr5230
@jrr5230
Nov 23 2016 03:46
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
Thanks guys!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:46

@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
@djcase001 Re-read my code.
KT
@Krystinet
Nov 23 2016 03:46
@revisualize I absolutely want to understand the lesson! Thank you for your help
CamperBot
@camperbot
Nov 23 2016 03:46
krystinet sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 2407 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Nov 23 2016 03:47
@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
@revisualize ok I see it. but mine is good too
Joseph
@revisualize
Nov 23 2016 03:47
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
@revisualize it completed for me
Joseph
@revisualize
Nov 23 2016 03:49
@djcase001
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:49
I admit yours was clever than mine, but mine works too
Joseph
@revisualize
Nov 23 2016 03:49
blob
FrankSD
@FrankSD
Nov 23 2016 03:49
Can someone please help me with my Javascriptpage? can not get it submitted
Joseph
@revisualize
Nov 23 2016 03:50
@djcase001 That's the code that you posted and the test cases.
KT
@Krystinet
Nov 23 2016 03:50
Thank you @djcase001 @revisualize
CamperBot
@camperbot
Nov 23 2016 03:50
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
@revisualize you didn't push item in the array first
Joseph
@revisualize
Nov 23 2016 03:50
@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
There was a mistake in this one
Joseph
@revisualize
Nov 23 2016 03:52
@Krystinet Do you understand what is going on?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52
@Krystinet Are you ok now??
KT
@Krystinet
Nov 23 2016 03:52
@revisualize I think so
@djcase001 I think I get it now
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52
@Krystinet good
KT
@Krystinet
Nov 23 2016 03:52
I'm going to do some more reading so that it sinks in
Joseph
@revisualize
Nov 23 2016 03:52
@Krystinet I have a link.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:52
@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
@revisualize I was able to pass the lesson, but need more practice, for sure!
Arnaud Casamé
@arnaudcasame
Nov 23 2016 03:55
@FrankSD What page???
KT
@Krystinet
Nov 23 2016 04:00
@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
Hey guys!
Anyone want to take a super easy question? Lol
jrr5230
@jrr5230
Nov 23 2016 04:08
@ParadiseArtist sounds like it'll be a trick question -_-
lol jk
go for it
Rachel Riley
@ParadiseArtist
Nov 23 2016 04:08
@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
haha there you go
Rachel Riley
@ParadiseArtist
Nov 23 2016 04:09
Let me read over the above code cause I'm stuck on the exact same question.
jrr5230
@jrr5230
Nov 23 2016 04:09
:+1:
Joseph
@revisualize
Nov 23 2016 04:16
la la la
@ParadiseArtist Just read that link that I posted.
shubhankarb180
@shubhankarb180
Nov 23 2016 04:22

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
$(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
@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
k @MoNag1
MoNag1
@MoNag1
Nov 23 2016 04:37
var api="api.openweathermap.org/data/2.5/weather?lat=" + la + "&lon=" + lo + "&APPID=da3ecbc1d1d3735a28ee453521d25614"
Anthony Drane
@Antiaccess
Nov 23 2016 04:39
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
@Antiaccess Still got that problem
Anthony Drane
@Antiaccess
Nov 23 2016 04:39
@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
@Antiaccess ok, I'd use the click event instead of mousedown and up
Anthony Drane
@Antiaccess
Nov 23 2016 04:40
like g.onclick = function()
?
Arnaud Casamé
@arnaudcasame
Nov 23 2016 04:45
Yeah
@Antiaccess sent you a link in private
Dominic Muttel
@domuttel
Nov 23 2016 04:49
@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
@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
@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
@Ankitnau25 try adding "http://" to the link
kevin
@leozhon
Nov 23 2016 04:57

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
// 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
@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
@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
ok
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 05:00
got it @MoNag1 but la and lo are not returning
MoNag1
@MoNag1
Nov 23 2016 05:01
@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
@toianw legend! seems counterintuitive, but it works
@toianw thanks
CamperBot
@camperbot
Nov 23 2016 05:01
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
@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
@toianw actually, it kind of makes sense
MoNag1
@MoNag1
Nov 23 2016 05:02
@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
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
ankitnau25 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @monag1 |http://www.freecodecamp.com/monag1
Ian
@toianw
Nov 23 2016 05:03
@Antiaccess it's just adding the class on mousedown and removing the class on mouseup.
Joseph
@revisualize
Nov 23 2016 05:03
@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
@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
@toianw yeah, I think was to close to the issue that I didn't see it
Joseph
@revisualize
Nov 23 2016 05:04
@leozhon wordBlanks is not an array.. It is a function
Dominic Muttel
@domuttel
Nov 23 2016 05:07
@revisualize @khaduch I am on the right track with tracks then... Im off on artists
MoNag1
@MoNag1
Nov 23 2016 05:07
@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
@domuttel No. You're overwriting tracks that already have data. You shouldn't be doing that.
Arnaud Casamé
@arnaudcasame
Nov 23 2016 05:08
@Antiaccess did you see the link???
Anthony Drane
@Antiaccess
Nov 23 2016 05:08
@djcase001 nope
@djcase001 in this chat?
@djcase001 ok
@djcase001 got it
Ankit Nautiyal
@Ankitnau25
Nov 23 2016 05:11
thanks for help @MoNag1
CamperBot
@camperbot
Nov 23 2016 05:11
ankitnau25 sends brownie points to @monag1 :sparkles: :thumbsup: :sparkles:
:warning: ankitnau25 already gave monag1 points
Arnaud Casamé
@arnaudcasame
Nov 23 2016 05:11
@Antiaccess 👍🏽
Ken Haduch
@khaduch
Nov 23 2016 05:14
@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
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
@domuttel - Bingo! .hasOwnProperty() is just the ticket!
Dominic Muttel
@domuttel
Nov 23 2016 05:21
( prop === collection[id].hasOwnProperty("tracks") )
Joseph
@revisualize
Nov 23 2016 05:24
@domuttel .hasOwnPropery() returns either true or false.
Dominic Muttel
@domuttel
Nov 23 2016 05:24
.hasOwnProperty is referring to artists in this case @khaduch
Kingdom Isaac
@kingisaac95
Nov 23 2016 05:25
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
@kingisaac95 maxLength = words[i].lenght; check length spelling on that line
Dominic Muttel
@domuttel
Nov 23 2016 05:29
@khaduch ( collection[id].hasOwnProperty("tracks") === true )
gandledorf
@gandledorf
Nov 23 2016 05:30

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
@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

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
@shyrushh think you need to concat a string with those words provided
gandledorf
@gandledorf
Nov 23 2016 05:32
@heroiczero thanks
CamperBot
@camperbot
Nov 23 2016 05:32
gandledorf sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @heroiczero |http://www.freecodecamp.com/heroiczero
heroiczero
@heroiczero
Nov 23 2016 05:32
@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
@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
THANK YOU ALL FOR THE QUICK RESPONSE :+1:
Kingdom Isaac
@kingisaac95
Nov 23 2016 05:37
@heroiczero Thanks a lot
CamperBot
@camperbot
Nov 23 2016 05:37
: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
  if ( collection[id].hasOwnProperty("tracks") === false ){
    collection[id].tracks = newArray;
    collection[id].tracks.push(value);
  }
@khaduch
Joseph
@revisualize
Nov 23 2016 05:56
  if (collection[id].hasOwnProperty("tracks") === false){
    collection[id].tracks = [];
  }
  collection[id].tracks.push(value);
Dominic Muttel
@domuttel
Nov 23 2016 05:57
@revisualize thats what I have
Joseph
@revisualize
Nov 23 2016 05:58
@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
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
@domuttel the condition part in the if statement automagically checks for truthy value
Dominic Muttel
@domuttel
Nov 23 2016 05:59
oh ok that makes way more sense
Karthik
@karthikm0
Nov 23 2016 05:59

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
@domuttel if truthy
then execute the statements
Dominic Muttel
@domuttel
Nov 23 2016 06:00
@abhisekp but it is set to equal false
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:00
@domuttel you can negate it by using ! operator :D
@domuttel e.g.
if ( !truthy )
Dominic Muttel
@domuttel
Nov 23 2016 06:01
myObj.hasOwnProperty(checkProp) !=
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:02
if (!myObj.hasOwnProperty(checkProp))
  ...
Dominic Muttel
@domuttel
Nov 23 2016 06:02
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
@domuttel What's the else going to be?
Dominic Muttel
@domuttel
Nov 23 2016 06:11
Im wondering about adding the aritist name
Abhisek Pattnaik
@abhisekp
Nov 23 2016 06:18
@karthikm0
```js  [shift + enter for newline]

<code here>

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

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
@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
@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
@erselnordlys ...hasOwnProperty(...) <- parens here, it is a method.
Alla Panchenko
@erselnordlys
Nov 23 2016 06:58
@Masd925 why exactly bracket notation instead of dot?
Markus Kiili
@Masd925
Nov 23 2016 06:58
@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
@Masd925 sure, parens! thanks
CamperBot
@camperbot
Nov 23 2016 06:58
erselnordlys sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2982 | @masd925 |http://www.freecodecamp.com/masd925
Joseph
@revisualize
Nov 23 2016 06:59
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
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
@revisualize lol
Markus Kiili
@Masd925
Nov 23 2016 07:03
@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
I swear.. It should be like a shop class assignment.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:04
@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
@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
@revisualize you americans have a really wrong impression about russians :D
btw. I am not a russian :)
Joseph
@revisualize
Nov 23 2016 07:07
@kirbyedy Actually, I just want a really bad ass Russian built AK-47.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:07
@Masd925 i got it, thanks a lot!
CamperBot
@camperbot
Nov 23 2016 07:07
erselnordlys sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: erselnordlys already gave masd925 points
Dan Couper
@DanCouper
Nov 23 2016 07:08

@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
@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
@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
You Americans are fucking stupid... Just like the rest of us really!
Joseph
@revisualize
Nov 23 2016 07:09
@adityaparab Yee haw?
Darth Skywalker
@adityaparab
Nov 23 2016 07:09
:laughing:
Alla Panchenko
@erselnordlys
Nov 23 2016 07:10
@DanCouper i'm not that deep in JS yet... I dont get it now
Joseph
@revisualize
Nov 23 2016 07:10

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
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
...
@Masd925 Do I need to fix that text?
Dan Couper
@DanCouper
Nov 23 2016 07:11
var π = Math.PI;
var ಠ_ಠ = "ahem";
var λ = function() {};
Abhisek Pattnaik
@abhisekp
Nov 23 2016 07:11
@DanCouper ahem...ahem...
Joseph
@revisualize
Nov 23 2016 07:11
@erselnordlys ----^^^ ... checkProp is a parameter.
kirbyedy
@kirbyedy
Nov 23 2016 07:12
@revisualize lovely graph mate, thanks
CamperBot
@camperbot
Nov 23 2016 07:12
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
very impressive! very impressive!
vveeeeerryy impressive
Joseph
@revisualize
Nov 23 2016 07:13
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
Same in San Francisco
Alla Panchenko
@erselnordlys
Nov 23 2016 07:14
@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
@erselnordlys You have to code around it.
@erselnordlys Something like this.
Dan Couper
@DanCouper
Nov 23 2016 07:14
var Hͫ̆̒̐ͣ̊̄ͯ͗͏̵̗̻̰̠̬͝ͅE̴̷̬͎̱̘͇͍̾ͦ͊͒͊̓̓̐_̫̠̱̩̭̤͈̑̎̋ͮͩ̒͑̾͋͘Ç̳͕̯̭̱̲̣̠̜͋̍O̴̦̗̯̹̼ͭ̐ͨ̊̈͘͠M̶̝̠̭̭̤̻͓͑̓̊ͣͤ̎͟͠E̢̞̮̹͍̞̳̣ͣͪ͐̈T̡̯̳̭̜̠͕͌̈́̽̿ͤ̿̅̑Ḧ̱̱̺̰̳̹̘̰́̏ͪ̂̽͂̀͠ = 'Zalgo';
Abhisek Pattnaik
@abhisekp
Nov 23 2016 07:14
@DanCouper why are the texts crying? :'(
Joseph
@revisualize
Nov 23 2016 07:14

@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
@DanCouper : THere is name for people who use variables like that... It's called "animals"
Alla Panchenko
@erselnordlys
Nov 23 2016 07:15
@revisualize i spose it will be "Joseph', right?
Joseph
@revisualize
Nov 23 2016 07:15
@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
@erselnordlys : It'll be [Function name] ;)
Joseph
@revisualize
Nov 23 2016 07:15
@erselnordlys Save that knowledge for later. It will be useful.
Dan Couper
@DanCouper
Nov 23 2016 07:16
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
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
meh.. Kind of.
Dan Couper
@DanCouper
Nov 23 2016 07:16
:point_up:
RishiRex
@rishirex
Nov 23 2016 07:17
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
remainder = 11 % 3
literally the same as you wrote it
Darth Skywalker
@adityaparab
Nov 23 2016 07:17
let remainder = 11%3;
Joseph
@revisualize
Nov 23 2016 07:17
Okay. technically yes.
Alla Panchenko
@erselnordlys
Nov 23 2016 07:18
@revisualize @DanCouper well thanks! i'll keep going
CamperBot
@camperbot
Nov 23 2016 07:18
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
@revisualize Is the AK thing pointed towards me?
Joseph
@revisualize
Nov 23 2016 07:19
@domuttel Technically yes. Technically, it is currently pointed in the direction of everyone on this planet.
Henry Cabello
@hacu9
Nov 23 2016 07:19
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
Stupid Earth being an oval and not a sphere.
Dominic Muttel
@domuttel
Nov 23 2016 07:21
Have you thought about a UV lamp?
Joseph
@revisualize
Nov 23 2016 07:21
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
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
Was that directed at me?
:| I don't get it.
I sleep.
:v:
Markus Kiili
@Masd925
Nov 23 2016 07:25
@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
Go sleep!
Joseph
@revisualize
Nov 23 2016 07:25
@Masd925 Thanks. I will look at seeing if I can correct the text a little.
CamperBot
@camperbot
Nov 23 2016 07:25
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
@Masd925 :point_up: November 21, 2016 7:11 PM
Samuel-Mumo
@Samuel-Mumo
Nov 23 2016 07:31
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
@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
@abhisekp ok, thanks.
CamperBot
@camperbot
Nov 23 2016 07:38
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
@kyauhen thanks, i haved used myObj[gift] and it worked
CamperBot
@camperbot
Nov 23 2016 07:46
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
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

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
hello, I have a problem sorting an array with numbers.
FengChen
@liuyueweilan
Nov 23 2016 08:20
phoneticLookup("") should be undefined
cannot use case, switch, or if
Stefaan Walleghem
@lawfets
Nov 23 2016 08:21
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
yep
Stefaan Walleghem
@lawfets
Nov 23 2016 08:22
but it doesn't
if I return commaArraySort it still gives the array as before
Islam Ibakaev
@dagman
Nov 23 2016 08:23
it works
FengChen
@liuyueweilan
Nov 23 2016 08:23
the typeError is phoneticLookup is not a function
Islam Ibakaev
@dagman
Nov 23 2016 08:23
correctly
Markus Kiili
@Masd925
Nov 23 2016 08:24
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
but i didnot use function ,right?
Markus Kiili
@Masd925
Nov 23 2016 08:24
@lawfets Sort is a mutator method, so commaArraySort.sort... is enough.
Stefaan Walleghem
@lawfets
Nov 23 2016 08:24
how come it doesn't work with me???
Markus Kiili
@Masd925
Nov 23 2016 08:25
@lawfets Post the whole code.
Stefaan Walleghem
@lawfets
Nov 23 2016 08:25
@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
@Masd925 [1,453,2,3,55,1].sort(function (a, b) { return a - b; }); is enough
Markus Kiili
@Masd925
Nov 23 2016 08:26
@dagman Yes, I said that already.
Islam Ibakaev
@dagman
Nov 23 2016 08:26
@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
@lawfets
Stefaan Walleghem
@lawfets
Nov 23 2016 08:30
@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
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
Hi to all! :smile:
Stefaan Walleghem
@lawfets
Nov 23 2016 08:33
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
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
@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
HI guys
Ryan Ledford
@rledford
Nov 23 2016 08:36
filter would be simplest way.
Alexander Huynh
@caesarsalad93
Nov 23 2016 08:37
Why does parseInt(021, 8); return 15?
instead of 17
elminsterrr
@elminsterrr
Nov 23 2016 08:40

@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
I wish Array#sort were not a mutator method.
elminsterrr
@elminsterrr
Nov 23 2016 08:41
@rledford My logic is broken here
Emerson
@DikoFaji
Nov 23 2016 08:45
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
@liuyueweilan use phoneticLookup["charlie"];
Annika Williamson
@AnnikaKW
Nov 23 2016 08:46
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
@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
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
Oh, I see
I thought that would return the array without the 1st element
Thanks, @revisualize
CamperBot
@camperbot
Nov 23 2016 08:52
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
\
josephinemonica
@josephinemonica
Nov 23 2016 08:55
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
@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

@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
@elminsterrr You are not removing elements from array, so filter doesn't work here.
elminsterrr
@elminsterrr
Nov 23 2016 09:01
@Masd925 what is the role of "index" in your code?
Markus Kiili
@Masd925
Nov 23 2016 09:01
@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
@Masd925 ok, very nice and short solution
but I dpn't understand this -> [acc.length-1]
Markus Kiili
@Masd925
Nov 23 2016 09:07
@elminsterrr arr[arr.length-1] is always the last element of an array arr.
Mateusz Kadlubowski
@xeho91
Nov 23 2016 09:08
@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
@xeho91 Oh, thanks
CamperBot
@camperbot
Nov 23 2016 09:08
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
@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
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
@Skidle isNaN is not a test for value NaN.
isNaN("cat"); // true
Daria Doronina
@Skidle
Nov 23 2016 09:10
@Masd925 oh thanks
CamperBot
@camperbot
Nov 23 2016 09:10
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
@Masd925 so I write it as arr[i] !== NaN ?
Markus Kiili
@Masd925
Nov 23 2016 09:11
@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
@Masd925 that's crazy :smile:
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:12
weird
Markus Kiili
@Masd925
Nov 23 2016 09:12
@Skidle A test for value not being NaN is val===val
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:12
that's the key!
Daria Doronina
@Skidle
Nov 23 2016 09:12
@Masd925 thank you!
CamperBot
@camperbot
Nov 23 2016 09:12
skidle sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave masd925 points
Abhisek Pattnaik
@abhisekp
Nov 23 2016 09:14
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
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
@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
@Masd925 ok so I need a function (I guess Boolean();) which returns true or false ?
Markus Kiili
@Masd925
Nov 23 2016 09:28
@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
@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
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
@DevD01 By just incrementing it. count++ for example.
J. Kilgore
@jkilgore07
Nov 23 2016 09:34
im converting celsius to fahrenheit. and dont understand what im doing wrong.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:34
@Masd925 I don't get it sorry
Markus Kiili
@Masd925
Nov 23 2016 09:34
You need to return count + " Bet" etc.
Mo Zargham
@Mozar10
Nov 23 2016 09:35
@jkilgore07 where are you stuck
Aditi Roy
@AlluringAditi
Nov 23 2016 09:36
@Masd925 I've defined a local variable count inside the function, have I done that right?
Markus Kiili
@Masd925
Nov 23 2016 09:37
@DevD01 No, you should just use the global variable.
Aditi Roy
@AlluringAditi
Nov 23 2016 09:37
@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
@DevD01 You can use global variables inside functions.
Mo Zargham
@Mozar10