These are chat archives for FreeCodeCamp/HelpJavaScript

19th
Aug 2016
Carl Rodgers
@Afterlife0102
Aug 19 2016 00:00
Thanks Margaret and Shola, .map() is a better idea
Diego Mayer
@Chrono79
Aug 19 2016 00:00
@criticalady paste what you did
Moisés Man
@moigithub
Aug 19 2016 00:00

@CageEcharte

var myArray = [
     [1,2,3], 
     [4,5,6], 
     [7,8,9], 
    [[10,11,12], 13, 14]
];

ok.. myArray is an array of array (2 dimension)
(array indices start on 0 )
to access the value 2... u do myArray[0][1]
cuz myArray[0] return an array [1,2,3]
and 2 value.. in on the second position.. counting from 0 is 1..
thats why u get myArray[0][1]
this return a value.. u need to assign to a variable
myvariable = myArray[0][1]

criticalady
@criticalady
Aug 19 2016 00:01
Thanks @Chrono79 !! I must have done it incorrectly when I tried that before... It worked after I tried it again. Thank you!! I
CamperBot
@camperbot
Aug 19 2016 00:01
criticalady sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1848 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 19 2016 00:01
:+1:
Olga C
@Octopinky
Aug 19 2016 00:01
I need some help with loading a json file in my codepen
Moisés Man
@moigithub
Aug 19 2016 00:02
$.getJSON ? @Octopinky
Olga C
@Octopinky
Aug 19 2016 00:03
@moigithub
Moisés Man
@moigithub
Aug 19 2016 00:03
u need a external host if u wanna upload ur own json file @Octopinky
like http://myjson.com/
Olga C
@Octopinky
Aug 19 2016 00:03
hmm?
Cage Echarte
@CageEcharte
Aug 19 2016 00:03
@moigithub okay can you give me the solution by it self ??.... I'm a little confused.. If you give me the solution it will make more sense.
Moisés Man
@moigithub
Aug 19 2016 00:05
@CageEcharte just find where the 8 value is... which index u need to use.....
its on first subarray??? on second ? third ?
inside subarray.. which position ?
i did with value 2... its the same thing
just count.. indices start on 0
Olga C
@Octopinky
Aug 19 2016 00:06
@moigithub codepen can not upload files from free code camp?
Moisés Man
@moigithub
Aug 19 2016 00:06

@CageEcharte

var myArray = [
     [1,2,3], 
     [4,5,6], 
     [7,8,9], 
    [[10,11,12], 13, 14]
];

if u want value 8.. on which subarray its located ??

Cage Echarte
@CageEcharte
Aug 19 2016 00:07
@moigithub on the 7th correct?
Moisés Man
@moigithub
Aug 19 2016 00:07
nope.. that array.. only have 4 elements... which are arrays also (an array containing others arrays ) @CageEcharte
@Octopinky nope... can not.. u need to use external host services (or ur own host) codepen not allow.. as i know
Cage Echarte
@CageEcharte
Aug 19 2016 00:09
so it would be 1 correct? @moigithub
Olga C
@Octopinky
Aug 19 2016 00:09
@moigithub ok. Thank you. I think that github will work
CamperBot
@camperbot
Aug 19 2016 00:09
octopinky sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1943 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Aug 19 2016 00:10
@CageEcharte each subarray element i placed on different lines... 8 is on third line...
but since array indices start counting from 0....
its NOT 1
jamesscruggs
@jamesscruggs
Aug 19 2016 00:12
anyway to simplify this code?
function largestOfFour(arr) {
  var largestNum = 0;
  var moveToArray = [];
  for (var i = 0; i < arr.length; i++) {
    largestNum = Math.max.apply(null, arr[i]);
    moveToArray.push(largestNum);
  }
  return moveToArray;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Cage Echarte
@CageEcharte
Aug 19 2016 00:13
@moigithub when you put them on different lines what does that do?
Moisés Man
@moigithub
Aug 19 2016 00:13
@CageEcharte does nothing.. makes more readable
Cage Echarte
@CageEcharte
Aug 19 2016 00:16
@moigithub // If I count from 1-8 starting with 1 as "0" then that would mean 8 is equal to 7
Mike R
@mikeinmiami
Aug 19 2016 00:16
can any one give me a hint on how to solve gold code challenge?
andersholen94
@andersholen94
Aug 19 2016 00:16
function mutation(arr) { 
  var arrOne = arr[0].toLowerCase().split("");
  var arrTwo = arr[1].toLowerCase().split("");

  for(var i = 0; i < arrOne.length; i++){
    if(arrTwo.indexOf(arrOne[i]) > -1){
      return true;
    } else if(arrTwo.indexOf(arrOne[i]) === -1){
      return false;
    }

  }

}

mutation(["hello", "hey"]);
this gives me almost everything correct, I don't see why it won't give everything correct, can anyone explain what's wrong here ?
Mike R
@mikeinmiami
Aug 19 2016 00:16
Im starting from Birdie to double bogey am i on the right track?
Margaret
@Margaret2
Aug 19 2016 00:16
@jamesscruggs you could probably take out the first line and just put "var largestNum = " within the for loop
Moisés Man
@moigithub
Aug 19 2016 00:17
@CageEcharte the array only have 4 sub-arrays inside
u counting the subarray elements as part of the main array element
jamesscruggs
@jamesscruggs
Aug 19 2016 00:18
@Margaret2 What's the difference?
Margaret
@Margaret2
Aug 19 2016 00:19
you said simplify, so I was just thinking it gets rid of an extra statement - because you're declaring and assigning the variable in the same statement
Mike R
@mikeinmiami
Aug 19 2016 00:19
anyone?
help on gold code challenge
CamperBot
@camperbot
Aug 19 2016 00:19
no wiki entry for: on gold code challenge
Mike R
@mikeinmiami
Aug 19 2016 00:20
i mean golf
golf code
Shola Abaogun
@codephoo
Aug 19 2016 00:21
@mikeinmiami
help golf code
Mike R
@mikeinmiami
Aug 19 2016 00:21
@codephoo yeah that one
I just need a hint
I'm stuck
Shola Abaogun
@codephoo
Aug 19 2016 00:21
help golf code
CamperBot
@camperbot
Aug 19 2016 00:21

:point_right: challenge golf code [wiki]

Challenge Golf Code

:triangular_flag_on_post: Remember to use Read-Search-Ask if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

In the game of golf each hole has a par meaning the average number of strokes a golfer is expected to make in order to sink the ball in a hole to complete the play. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed par and strokes arguments. You've to return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"
>= par + 3 "Go Home!"

:pencil: read more about challenge golf code on the FCC Wiki

Shola Abaogun
@codephoo
Aug 19 2016 00:22
@mikeinmiami show the code you have tried
Mike R
@mikeinmiami
Aug 19 2016 00:23

function golfScore(par, strokes) {
// Only change code below this line
if (par <= strokes - 2 ){
return "Eagle";
}

else if (par > strokes - 1){
return "Birdie";
}

else if (par == strokes){
return "Par";
}

else if (par < strokes + 1){
return "Bogey";
}
else if (par < strokes + 2){
return "Double Bogey";
}
else if (par <= strokes + 3){
return "Go Home!";
}
else{
return "Hole-in-one!";}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

Let me know if i'm close or far lol
Moisés Man
@moigithub
Aug 19 2016 00:25
@mikeinmiami u not using the table for comparation
if strokes IS par - 1 return "Birdie"
urs... else if (par > strokes - 1){
coffeebeanzz
@coffeebeanzz
Aug 19 2016 00:25
@mikeinmiami all of them except eagle should be ==
Shola Abaogun
@codephoo
Aug 19 2016 00:25
@mikeinmiami you need to change the order of your comparison
Margaret
@Margaret2
Aug 19 2016 00:26
@mikeinmiami you probably need to use strokes == statements in the parentheses. Here are the first few lines of my code,
 if (strokes==1) {
    return "Hole-in-one!";
  } else if (strokes <= par-2) {
    return "Eagle";
Mike R
@mikeinmiami
Aug 19 2016 00:26
I have a feeling it's better to put strokes on the left side of the operator
coffeebeanzz
@coffeebeanzz
Aug 19 2016 00:27
u are right about that @mikeinmiami
rolanjose7
@rolanjose7
Aug 19 2016 00:27
hey, can somebody please help me with the counting cards challenge? i have my code ready but i dont know what's wrong
andersholen94
@andersholen94
Aug 19 2016 00:28
function mutation(arr) { 
  var arrOne = arr[0].toLowerCase().split("");
  var arrTwo = arr[1].toLowerCase().split("");

  for(var i = 0; i < arrOne.length; i++){
    if(arrTwo.indexOf(arrOne[i]) > -1){
      return true;
    } else if(arrTwo.indexOf(arrOne[i]) === -1){
      return false;
    }

  }

}

mutation(["hello", "hey"]);
could anyone tell me why this doesn't work on every input ?
rolanjose7
@rolanjose7
Aug 19 2016 00:29
Here's my code:
alhajit21
@alhajit21
Aug 19 2016 00:29
why I have a reverse hello and a regular hello // reverse a string challenge
Scott Metz
@scorp72
Aug 19 2016 00:29
I am kind of confused with the wordBlanks. what are they looking for?
Moisés Man
@moigithub
Aug 19 2016 00:29
@andersholen94 looks like ur loop only iterating 1 time...
it reach the return keyword on each condition.. and return exit the function
@scorp72 u get passed 4 words.. u need to return a phrase (using the variables/arguments )
Stephen James
@sjames1958gm
Aug 19 2016 00:30
@scorp72 Take the four parameters and form them into a single string, separated them by spaces, add other words if you want
Scott Metz
@scorp72
Aug 19 2016 00:30
two phrases or just one dog and cat?
Moisés Man
@moigithub
Aug 19 2016 00:31
@andersholen94 u can check ur code here pythontutor.com/javascript.html
rolanjose7
@rolanjose7
Aug 19 2016 00:31

Help please! with counting cards challengue:
´´´
var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count+=1;
break;
case 7:
case 8:
case 9:
count+=0;
break;
case 10:
case "J":
case "Q":
case "K":
case "A":
count-=1;
break;
}
if (count > 0){
return count +" Bet!";
} else
{
return count +" Hold";
}
// 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');
´´´

CamperBot
@camperbot
Aug 19 2016 00:31
no wiki entry for: please with counting cards challenguevar count 0function cccard only change code below this line switchcard case 2 case 3 case 4 case 5 case 6 count1 break case 7 case 8 case 9 count0 break case 10 case j case q case k case a count-1 break if count 0 return count bet else return count hold only change code above this line addremove calls to test your function note only the last will displaycc2 cc3 cc7 cck cca
alhajit21
@alhajit21
Aug 19 2016 00:31

function reverseString(str) {
var rstr = str.split("").reverse().join("");

return rstr += str;
}

reverseString("hello");

TanerAlbayrak
@TanerAlbayrak
Aug 19 2016 00:31
anyone have tips on the find the longest word in a string challenge? My thinking is split the string on the spaces and places each word into an array then check which word in the array is the longest
Moisés Man
@moigithub
Aug 19 2016 00:31
@scorp72 the test already provides the words.. u only need to "play" with the variables
Stephen James
@sjames1958gm
Aug 19 2016 00:31
@alhajit21 Why are you adding the two strings together?
alhajit21
@alhajit21
Aug 19 2016 00:32
@sjames1958gm oops
Stephen James
@sjames1958gm
Aug 19 2016 00:32
@TanerAlbayrak Rather than place them in the array, test for the longest at that time.
Shola Abaogun
@codephoo
Aug 19 2016 00:32
that should work @TanerAlbayrak
TanerAlbayrak
@TanerAlbayrak
Aug 19 2016 00:32
hmm
Stephen James
@sjames1958gm
Aug 19 2016 00:32
@rolanjose7 There is no ! in the results. Also, use `
andersholen94
@andersholen94
Aug 19 2016 00:32
@moigithub but it returns true on some of the inputs where the first letters are different
rolanjose7
@rolanjose7
Aug 19 2016 00:33
@sjames1958gm yeah, you were right...thanks man
Stephen James
@sjames1958gm
Aug 19 2016 00:34
@andersholen94 If the first letter is anywhere in the string it will return true without checking any others.
@rolanjose7 :+1:
encount
@encount
Aug 19 2016 00:34
@TanerAlbayrak have an initial count var set to the length of first word - then if next word is longer than count update it to new value
andersholen94
@andersholen94
Aug 19 2016 00:35
@sjames1958gm @moigithub I see what to do now, thanks :)
CamperBot
@camperbot
Aug 19 2016 00:35
andersholen94 sends brownie points to @sjames1958gm and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2716 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1944 | @moigithub |http://www.freecodecamp.com/moigithub
Margaret
@Margaret2
Aug 19 2016 00:36
This message was deleted
@TanerAlbayrak that's basically what i did, i put the words in an array, then I sorted the array by item length and just returned the first item
*length of first item
Stephen James
@sjames1958gm
Aug 19 2016 00:40
@andersholen94 :checkered_flag:
TanerAlbayrak
@TanerAlbayrak
Aug 19 2016 00:41
@encount @Margaret2 i like both of those ways to do it, thanks so much :) not sure how i would do it without an array
CamperBot
@camperbot
Aug 19 2016 00:41
taneralbayrak sends brownie points to @encount and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @margaret2 |http://www.freecodecamp.com/margaret2
:cookie: 312 | @encount |http://www.freecodecamp.com/encount
Nik
@breza123
Aug 19 2016 00:41

var myVar = 87;

// Only change code below this line
myVar = ++myVar;

i dont get it

Mike R
@mikeinmiami
Aug 19 2016 00:42
@coffeebeanzz @codephoo @Margaret2 @coffeebeanzz thanks
CamperBot
@camperbot
Aug 19 2016 00:42
mikeinmiami sends brownie points to @coffeebeanzz and @codephoo and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 381 | @codephoo |http://www.freecodecamp.com/codephoo
:cookie: 974 | @coffeebeanzz |http://www.freecodecamp.com/coffeebeanzz
:cookie: 302 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Aug 19 2016 00:42
@mikeinmiami :D
Stephen James
@sjames1958gm
Aug 19 2016 00:42
@breza123 The examples show replacing i = i + 1 with i++ what should you replace myVar = myVar + 1 ?
coffeebeanzz
@coffeebeanzz
Aug 19 2016 00:42
np @mikeinmiami :)
Mike R
@mikeinmiami
Aug 19 2016 00:43
Thanks guys I ended up figuring it out. I guess I wasn't trying to look at the table for the sake of me trying to figure it out
on my own
LPR-309
@LPR-309
Aug 19 2016 00:43
@Nik You only need myVar++; to increment. I'm pretty sure assignment isn't needed. 95%
Nik
@breza123
Aug 19 2016 00:44
ty i got it now :D
Stephen James
@sjames1958gm
Aug 19 2016 00:44
@breza123 :+1:
Chris Cullen
@123xylem
Aug 19 2016 00:49
var time=3600;

$("#action").click(function setInterval(time){
  time-=1; },1000);                          

  $("#face").text(getTime(time));
    $("#set1").text(getTime(time)); 


});
Hi can someone explain what is wrong with my setInterval click function?
Joseph
@revisualize
Aug 19 2016 00:50
Would someone please take a second to look this over?
https://gist.github.com/revisualize/fdc7f63fccdfd83739d33307b6dbc453
I'm trying to help people understand the challenge for Nesting For Loops challenge
But, I feel that I also need to explain Complex Arrays as well to give them an understanding of the process.
I think it will even help people with complex objects in general.
..
Anyone that doesn't want to see that box. Please type:
/collapse-all
@sjames1958gm --^
Stephen James
@sjames1958gm
Aug 19 2016 00:55
@revisualize For this To access the single element of "f2" maybe drop the of
Other than that looks good.
Joseph
@revisualize
Aug 19 2016 00:56
@sjames1958gm Fixed.
Hopefully that will help people understand the whole concept. I was thinking about defining nested in there as well.
mjamil016
@mjamil016
Aug 19 2016 00:58
need some help with lesson "Global Scope and Functions". how do I assign 5 to "oopsGlobal" without using var ???
encount
@encount
Aug 19 2016 01:02
@mjamil016 of you assign a var (without var) inside a function it automatically become global i believe
Margaret
@Margaret2
Aug 19 2016 01:03
@mjamil016 basically you're purposefully doing wrong code for learning purposes, just use =
mjamil016
@mjamil016
Aug 19 2016 01:04
@Margaret2 so where do I put that equal sign ?
Margaret
@Margaret2
Aug 19 2016 01:05
oopsGlobal = 5; @mjamil016
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:05
Can someone please help me with the challenge (JavaScript) "Accessing Nested Objects" my code is "gloveBoxContents.myStorage["glove box"] = "maps"; " I'm not sure what I did incorrect and I can't exactly understand what it is asking of me.
mjamil016
@mjamil016
Aug 19 2016 01:06
@Margaret2 does that go inside the parenthesis or no?
Margaret
@Margaret2
Aug 19 2016 01:06
@angelmontes12 hint: it goes down through each level in the object, so it starts with myStorage.car
encount
@encount
Aug 19 2016 01:06
@angelmontes12 from memory aren’t you supposed to get whats in the glovebox not assign it to the glove box
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:07
@Margaret2 Ill try the hint. Much appreciated
Margaret
@Margaret2
Aug 19 2016 01:07
@mjamil016 it goes inside fun1 brackets
mjamil016
@mjamil016
Aug 19 2016 01:07
@Margaret2 okay got it. Thanks!
CamperBot
@camperbot
Aug 19 2016 01:07
mjamil016 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @margaret2 |http://www.freecodecamp.com/margaret2
Chris Cullen
@123xylem
Aug 19 2016 01:09
This message was deleted
Margaret
@Margaret2
Aug 19 2016 01:09
@angelmontes12 @encount is right, var gloveboxcontents = myStorage.car etc...
Chris Cullen
@123xylem
Aug 19 2016 01:09
$("#action").click(function setInterval (countdown,1000){//every sec use countdown
  function countdown(time){ 

    $("#face").text(getTime(time)); //show time 
    $("#set1").text(getTime(time));

    time--;                //take 1 second off each second


    if(time===0)  //When timer is over

    {clearInterval(countdown);} //stop function

});                          
});
Quick Q: How do i make my setInteval function work?
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:11
@Margaret2 I am still not sure how it is supposed to appear..is myStorage.car after the equals of gloveBoxContents? like this "var gloveBoxContents = myStorage.car"?
Margaret
@Margaret2
Aug 19 2016 01:11
yes @angelmontes12
if you can't get it to work, paste your code again @angelmontes12
Tricia Mendoza
@gatorgalaga
Aug 19 2016 01:13
need to make sure if there is a bug with Make Instances of Objects with a Constructor Function https://www.freecodecamp.com/challenges/make-instances-of-objects-with-a-constructor-function
Lennard Neuwirth
@BinaryHound
Aug 19 2016 01:14
So I'm trying to find out what's going wrong here? can anyone help me. The error says it's null.

function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for(var firstTime = 0; firstTime < arr.length; firstTime++){
for(var secondTime = 0; secondTime < arr[firstTime].length; secondTime++){
product = product * arr[secondTime];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

Joseph
@revisualize
Aug 19 2016 01:15
@gatorgalaga I just solved the challenge.
@BinaryHound Your array isn't drilling down far enough.
@BinaryHound Maybe Read this? Hashtag-I.wrote.it
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:16
@Margaret2 I now have this "var gloveBoxContents = myStorage.car["inside"].glovebox = "maps";" I seem to have gloveBoxContents = maps , but I don't know how to combine the dot and bracket notation to access myStorage. I am confused of how its asking me to do that.
Lennard Neuwirth
@BinaryHound
Aug 19 2016 01:16
@revisualize is it one more layer? i thought that was the problem :/
Margaret
@Margaret2
Aug 19 2016 01:17
@angelmontes12 .inside["glove box"];
@BinaryHound you're suppose to use two for loops like in the instructions
for (i=0; i<arr.length; i++){
    for (j=0; j<arr[i].length; j++){
// put something here to multiply
}
}
Lennard Neuwirth
@BinaryHound
Aug 19 2016 01:19
@revisualize I did. I set my variables for firstTime = i ad secondtime = j. So the only thing is the error states the actual array is null.
talhayasir95
@talhayasir95
Aug 19 2016 01:20
hey
can smeone help me with building up a cart
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:20
@Margaret2 I now have "var gloveBoxContents = myStorage.car.inside.["glove box"] = "maps";" yet it still says incorrect coding.
talhayasir95
@talhayasir95
Aug 19 2016 01:20
i dont know how to di that
Margaret
@Margaret2
Aug 19 2016 01:21
@angelmontes12 you don't need the ="maps", just the semicolon after ["glove box"]
encount
@encount
Aug 19 2016 01:21
@angelmontes12 you need to remove the last = sign to start with - remember your getting something
Kantra
@removed~kantrakantra
Aug 19 2016 01:22

Hey guys, I've been working on a code exercise and I'm stuck on a couple of issues. I'm working backwards from this solution:

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);

Firstly I'm not exactly understanding the purpose of the .call method and the fact that .slice is written without parentheses (). As well, I'm still unsure of the exact meaning behind .prototype. I've gotten some clarification from the chat so far, it's just still not clicking for some reason. I was hoping someone might be able to help explain some of this stuff to me.

Margaret
@Margaret2
Aug 19 2016 01:23
@BinaryHound you should be using product *= arr[i][j];
sorry, formatting did something funny there for a minute
Angel Montes De Oca
@angelmontes12
Aug 19 2016 01:23
@Margaret2 Thank you! It passed through. I had the equals map part removed but it was incorrect until I removed the extra dot notation in front of ".inside["glove box"];" thank you once again.
CamperBot
@camperbot
Aug 19 2016 01:23
angelmontes12 sends brownie points to @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @margaret2 |http://www.freecodecamp.com/margaret2
Margaret
@Margaret2
Aug 19 2016 01:24
:D
@BinaryHound putting in whatever you're using for i and j of course
Samvel Bazeyan
@Samo777
Aug 19 2016 01:24
who can help me with a task?
talhayasir95
@talhayasir95
Aug 19 2016 01:25
i
what task ?
come private
Samvel Bazeyan
@Samo777
Aug 19 2016 01:25
how i can?
talhayasir95
@talhayasir95
Aug 19 2016 01:25
i send you a message
Samvel Bazeyan
@Samo777
Aug 19 2016 01:25
ok
talhayasir95
@talhayasir95
Aug 19 2016 01:25
do you received it ?
Samvel Bazeyan
@Samo777
Aug 19 2016 01:26
i think no
go skype?
talhayasir95
@talhayasir95
Aug 19 2016 01:27
hover on my profile there will be something like chat prvatly click there
Samvel Bazeyan
@Samo777
Aug 19 2016 01:29
go there
talhayasir95
@talhayasir95
Aug 19 2016 01:30
then send me a message
Samvel Bazeyan
@Samo777
Aug 19 2016 01:30
i send go private
Tricia Mendoza
@gatorgalaga
Aug 19 2016 01:36
@revisualize sorry, computer did auto update and restarted.
TanerAlbayrak
@TanerAlbayrak
Aug 19 2016 01:36
@gatorgalaga lol same here... smh windows
alhajit21
@alhajit21
Aug 19 2016 01:36
which is better to solve factorialize a number algorithm
a for loop or a if statment
Angel J Piscola
@Redmega
Aug 19 2016 01:36
Hey y'all
Margaret
@Margaret2
Aug 19 2016 01:37
@kantrakantra you can read about prototypes here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Inheritance_and_the_prototype_chain
In my understanding, Array.prototype is like Javascript's built-in template with all the stuff you can do to any array you make. And I guess you have to .call it because you're using the prototype version and not the normal version of slice?
@alhajit21 i used a for loop, very efficient
Tricia Mendoza
@gatorgalaga
Aug 19 2016 01:39

@revisualize this is what I ran:

var myCar = new Car();
myCar.engineType = "rotary engine";

Mostafa Syam
@pro-mos
Aug 19 2016 01:39
@alhajit21 a combination of both actually
Joseph
@revisualize
Aug 19 2016 01:40
@gatorgalaga arent you supposed to be giving your car a nickname ?
encount
@encount
Aug 19 2016 01:41
@kantrakantra as you dont know how many arguments are going to be passed - in this case 2 but it could be 5 - var args return an array of the extra arguments in this case
Mostafa Syam
@pro-mos
Aug 19 2016 01:41
What does the ... mean in JS?
Tricia Mendoza
@gatorgalaga
Aug 19 2016 01:42
well well, I apparently don't know how to read properly....lol...thanks @revisualize
Joseph
@revisualize
Aug 19 2016 01:42
Spread operator.
Mostafa Syam
@pro-mos
Aug 19 2016 01:43
@revisualize what it does?
@revisualize ok found it on FCC wiki :smile: thnx
CamperBot
@camperbot
Aug 19 2016 01:44
pro-mos sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1679 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 19 2016 01:44
I am on my phone currently. Could you maybe google: js spread operator
Tricia Mendoza
@gatorgalaga
Aug 19 2016 01:45
@revisualize thanks
CamperBot
@camperbot
Aug 19 2016 01:45
gatorgalaga sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1680 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 19 2016 01:46
@gatorgalaga no problem. Best of luck to you moving forward. :)
Samvel Bazeyan
@Samo777
Aug 19 2016 01:55
who can help me with a task?
Joseph
@revisualize
Aug 19 2016 01:57
Depends on the task. That is like walking into a bad situation with a question like that. I am on my phone. So, I'm limited.
Kantra
@removed~kantrakantra
Aug 19 2016 01:58
@Redmega Hey Angel, thx for helping me lastnight. I had a couple new questions, if you have any time I sent them to you in direct chat.
CamperBot
@camperbot
Aug 19 2016 01:58
kantrakantra sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
:cookie: 91 | @redmega |http://www.freecodecamp.com/redmega
Stephen James
@sjames1958gm
Aug 19 2016 02:01
@Samo777 Ask another question.
Angel J Piscola
@Redmega
Aug 19 2016 02:02
@kantrakantra Sure, check your chat :)
Ilyes Hammadi
@Ilyes-Hammadi
Aug 19 2016 02:05
Guys need help on the "Escape Sequences in Strings", here is my solution
var myStr; // Change this line

myStr = 'FirstLine\n\b\\SecondLine\\\b\rThirdLine';
Stephen James
@sjames1958gm
Aug 19 2016 02:06
@Ilyes-Hammadi Why the \b are in there?
Ilyes Hammadi
@Ilyes-Hammadi
Aug 19 2016 02:07
@sjames1958gm it's in the challenge instructions "FirstLine newline backslash SecondLine backslash carriage-return ThirdLine"
Stephen James
@sjames1958gm
Aug 19 2016 02:07
@Ilyes-Hammadi \b is backspace - there is no backspace (there are only 4 keywords and you have six escape sequences)
Ilyes Hammadi
@Ilyes-Hammadi
Aug 19 2016 02:09
@sjames1958gm it's working thank you so much :smile:
CamperBot
@camperbot
Aug 19 2016 02:09
ilyes-hammadi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2717 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 19 2016 02:09
@Ilyes-Hammadi :+1:
Mostafa Syam
@pro-mos
Aug 19 2016 02:11
// I didn't know about parseInt(, 2) to convert binary
  function toDecimal(binary) {
    var decimal = 0, i;
    for (i = 0; i < binary.length; i++) {
      decimal += parseInt(binary[i]) * Math.pow(2, binary.length - 1 - i);
    }
    return decimal;
  }
i don't understand why i need binary.length - 1 - i in Math.pow why not just Math.pow(2, i) as the math formula for binary - decimal conversion
Kantra
@removed~kantrakantra
Aug 19 2016 02:14
@Redmega thx
CamperBot
@camperbot
Aug 19 2016 02:14
:warning: kantrakantra already gave redmega points
kantrakantra sends brownie points to @redmega :sparkles: :thumbsup: :sparkles:
long123456
@xiaosamianbao
Aug 19 2016 02:15
Diff Two Arrays? who did it?
Kevin Mulligan
@kmulligan
Aug 19 2016 02:18
@xiaosamianbao I have
Stephen James
@sjames1958gm
Aug 19 2016 02:18
@pro-mos Your powers are the reverse of the array indexes. Index 0 is the highest power.
long123456
@xiaosamianbao
Aug 19 2016 02:19
@kmulligan can you tell me about it
Kevin Mulligan
@kmulligan
Aug 19 2016 02:21
@xiaosamianbao What do you want to know?
Mostafa Syam
@pro-mos
Aug 19 2016 02:22
@sjames1958gm oh, i get it now thnx
CamperBot
@camperbot
Aug 19 2016 02:22
pro-mos sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2718 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Moisés Man
@moigithub
Aug 19 2016 02:22
binary
long123456
@xiaosamianbao
Aug 19 2016 02:23
@kmulligan how to find out the diffrent in two arrays?
Mike
@MikeJSchorah
Aug 19 2016 02:23
function getIndexToIns(arr, num) {
    arr.push(num);
    arr.sort(function(a, b) { return a-b; });
    return arr.indexOf(num);

getIndexToIns([40, 60], 50);

@sjames1958gm Please explain the solution to Where do I belong. I just don't understand how it works.

Kevin Mulligan
@kmulligan
Aug 19 2016 02:23
@xiaosamianbao you need to find a way to compare the two arrays. have you looked at the links in the left sidebar that hint toward some options?
Mostafa Syam
@pro-mos
Aug 19 2016 02:24
@moigithub this makes a lot of sense thnx a lot, i think i just didn't notice that it's in reversed order
CamperBot
@camperbot
Aug 19 2016 02:24
pro-mos sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1945 | @moigithub |http://www.freecodecamp.com/moigithub
long123456
@xiaosamianbao
Aug 19 2016 02:26
@kmulligan i see but i understand how to find out their diffrent elments
Mostafa Syam
@pro-mos
Aug 19 2016 02:26
@MikeJSchorah first you insert the number to the array then sort it from lowest to greatest, then return the proper index for the number you inserted before.
Kevin Mulligan
@kmulligan
Aug 19 2016 02:26
@xiaosamianbao Think about how you could use indexOf
Stephen James
@sjames1958gm
Aug 19 2016 02:27
@MikeJSchorah You want to know where num would go in the arr. So you put it in the array and then sort the array and find out where num ended up.
long123456
@xiaosamianbao
Aug 19 2016 02:30
@kmulligan thank you i try
CamperBot
@camperbot
Aug 19 2016 02:30
xiaosamianbao sends brownie points to @kmulligan :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @kmulligan |http://www.freecodecamp.com/kmulligan
Kevin Mulligan
@kmulligan
Aug 19 2016 02:30
@xiaosamianbao indexOf will tell you, if you set it up right, whether something you are looking for is in an array
Mike
@MikeJSchorah
Aug 19 2016 02:32
Ok. So...
arr.push(num) <-------This is inserting num into an array
arr.sort(function(a, b) { return a-b;}); <-------This is sorting the array from highest to lowest
return arr.indexOf(num) <-------This is grabbing the first index of array which is num (and thus the lowest from sort)
Is this a good explanation?
And we use num because the returned value should be a number
Joseph
@revisualize
Aug 19 2016 02:34
@MikeJSchorah .push() adds a value to the end of an array.
@MikeJSchorah That .sort() function does do a numeric sort from ... Some point to some point.
@MikeJSchorah return arr.indexOf(num) does grab the first index of the number that you just added to the array that was sorted.
@MikeJSchorah you use num because that is the value passed into the function.
It doesn't have to be num if you have a different param in your function.
function happyCat(list_of_cat_names, myCatsName) {
    list_of_cat_names.push(myCatsName);
// ...
Diego Mayer
@Chrono79
Aug 19 2016 02:38
@MikeJSchorah arr.sort(function(a, b) { return a-b;}); <-------This is sorting the array from highest to lowest. <- No, it sorts from lowest to highest
Joseph
@revisualize
Aug 19 2016 02:38
That point to that point.
Diego Mayer
@Chrono79
Aug 19 2016 02:41
@revisualize use camelCase :P
Angel J Piscola
@Redmega
Aug 19 2016 02:44
@revisualize Go back to python Dx
Lol
Joseph
@revisualize
Aug 19 2016 02:46
@Chrono79 Hashtag-I.did.that.ship.on.porpoise.
Angel J Piscola
@Redmega
Aug 19 2016 02:46
:^)
Mike
@MikeJSchorah
Aug 19 2016 02:49
Thanks @Chrono79 @Blauelf @wearenotgroot @revisualize @Masd925 @pro-mos @sjames1958gm
CamperBot
@camperbot
Aug 19 2016 02:49
mikejschorah sends brownie points to @chrono79 and @blauelf and @wearenotgroot and @revisualize and @masd925 and @pro-mos and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1849 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 315 | @pro-mos |http://www.freecodecamp.com/pro-mos
:star2: 2719 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 2393 | @blauelf |http://www.freecodecamp.com/blauelf
:star2: 1403 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
:star2: 2320 | @masd925 |http://www.freecodecamp.com/masd925
:star2: 1681 | @revisualize |http://www.freecodecamp.com/revisualize
Mike
@MikeJSchorah
Aug 19 2016 02:49
...most of the usual
Hopefully, I can be one of you guys someday :D
Joseph
@revisualize
Aug 19 2016 02:50
Meh. Don't be me. I suck.
greg
@wearenotgroot
Aug 19 2016 02:50
@MikeJSchorah :+1:
Angel J Piscola
@Redmega
Aug 19 2016 02:51
It's true @MikeJSchorah, @revisualize is a chronic procrastinator :^)
Joseph
@revisualize
Aug 19 2016 02:52
Is that a pot talking crap about the kettle?
Mike
@MikeJSchorah
Aug 19 2016 02:53
@Redmega Yeah, he was mad at me at one point... can't remember why....... I don't think he can remember either! Lol
Oh yeah, when I said I think I need a boot camp instead of his direction, LOL
I've always received good advice, though, from @revisualize
Angel J Piscola
@Redmega
Aug 19 2016 02:54
@revisualize It's the kettle calling the pot !(!black)
Speaking of double negatives
Guess what I saw in production code from 5 years back
Diego Mayer
@Chrono79
Aug 19 2016 02:55
A boot in the ass pointed in the right direction, I'll think about that ;)
Angel J Piscola
@Redmega
Aug 19 2016 02:55
!(someBoolean != null)
Mike
@MikeJSchorah
Aug 19 2016 02:57
@Chrono79 I'm still sold on the boot camp only to increase my skill set further and the connections, but I've definitely learned a ton on here. You guys definitely know your stuff!
Joseph
@revisualize
Aug 19 2016 02:57
!!someBoolean == null
Angel J Piscola
@Redmega
Aug 19 2016 02:59
~!~!~!x.indexOf(y);
I'm curious actually, what would that give me...
Joseph
@revisualize
Aug 19 2016 02:59
What is ~ ?
Angel J Piscola
@Redmega
Aug 19 2016 03:00
It always gives me -1. Not actually that fun :(
Joseph
@revisualize
Aug 19 2016 03:05
Double You Tea Eph May-Eight
Angel J Piscola
@Redmega
Aug 19 2016 03:06
~ary.indexOf(ele); is much cleaner to me than ary.indexOf(ele)>-1
Joseph
@revisualize
Aug 19 2016 03:08
That's really really interesting.
So, you take (N+1) * -1
Angel J Piscola
@Redmega
Aug 19 2016 03:11
Of course, now that includes() exists, that's kind of moot
Joseph
@revisualize
Aug 19 2016 03:11
Ummm.
Sure.
Angel J Piscola
@Redmega
Aug 19 2016 03:13
For readability anyway
TylersCode
@TylersCode
Aug 19 2016 03:18
This message was deleted
Justin Clark
@jeclark9063
Aug 19 2016 03:20
Got this algorithm working correctly but it seems like I could implement some of the JS built in functions to make it a little cleaner, any opinions?
function diffArray(arr1, arr2) {
  var newArr = [];
  var hold = 0;
  var count = 0;
  var isunique = true;

  for (var i = 0; i < arr1.length; i++){
    isunique = true;
    for (var j = 0; j < arr2.length; j++){
      if (arr1[i] === arr2[j])
        isunique = false;
    }
    if (isunique){
      newArr[count] = arr1[i];
      count++;
    }
  }

  for (var k = 0; k < arr2.length; k++){
    isunique = true;
    for (var h = 0; h < arr1.length; h++){
      if (arr2[k] === arr1[h])
        isunique = false;
    }
    if (isunique){
      newArr[count] = arr2[k];
      count++;
    }
  }
  return newArr;
}

diffArray(["andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
Joseph
@revisualize
Aug 19 2016 03:22
@TylersCode You didn't do anything.
@TylersCode Let's do this.
var num = 5;
num = num + 1; // 6
num += 1; // 7
 num++; // 8
greg
@wearenotgroot
Aug 19 2016 03:23
@revisualize :smile:
Joseph
@revisualize
Aug 19 2016 03:24
@wearenotgroot Am I an ass for stating that?
Xavier Artot
@xavierartot
Aug 19 2016 03:24
hey there
Chris Hutchinson
@pablanopete
Aug 19 2016 03:25
Stuck on this problem...anyone think they could help? I don't know why I feel like i'm missing explanation.
greg
@wearenotgroot
Aug 19 2016 03:25
@revisualize no, :smile:
Chris Hutchinson
@pablanopete
Aug 19 2016 03:25
Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use bracket notation for properties with a space in their name.
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line

var gloveBoxContents = ""; // Change this line
mzedlach
@mzedlach
Aug 19 2016 03:25
Goooood evening!
Joseph
@revisualize
Aug 19 2016 03:25
hi
greg
@wearenotgroot
Aug 19 2016 03:26
@hutchie25 so tell us your plan?
mzedlach
@mzedlach
Aug 19 2016 03:26
I am having issues getting all my words to come back together.

function titleCase(str) {
  var words = str.toLowerCase().split(" "); //Sets to lower case and separates into words
  for (var i = 0; i < words.length ; i++){
    var letters = words[i].split(""); // Splits first word into letters
    letters[0] = letters[0].toUpperCase(); //Makes first letter capital
    words[i] = letters.join("");//Change words array with new capitalized word
  }
  words.join(" "); //Join words to create a string
  return words; //returns changed array
}

titleCase("I'm a little tea pot");
I know there is something wrong with words.join(" ")
Chris Hutchinson
@pablanopete
Aug 19 2016 03:26
I'm so confused on how to access the myStorage object, every assignment i've used is acting crazy. I think i'm burnt out tonight lol. @wearenotgroot
greg
@wearenotgroot
Aug 19 2016 03:27
@hutchie25 remember from previous lessons you can use .(dot) and bracket notation
Chris Cullen
@123xylem
Aug 19 2016 03:27
var time=72;
var time2=20;

function getTime(seconds) {
    var leftover = seconds;
    var hours = Math.floor(leftover / 3600);
    var minutes = Math.floor(leftover / 60); 
  leftover=leftover-(minutes*60);
console.log(hours,leftover,minutes);

  if(minutes>= 1 && minutes<=59){
        return(minutes + ':' + leftover);
    }
    else
    return(0 + ':'+ leftover);
 }
getTime(time);
Why isnt my clock reading this right!!?
Minutes doesnt get shown and seconds becomes nan
greg
@wearenotgroot
Aug 19 2016 03:28
@hutchie25 these lessons
  • Accessing Objects Properties with the Dot Operator
  • Accessing Objects Properties with Bracket Notation
Joseph
@revisualize
Aug 19 2016 03:29
Let's see...
@mzedlach hmmm
greg
@wearenotgroot
Aug 19 2016 03:30

@mzedlach you dont need to do

var letters = words[i].split(""); // Splits first word into letters

you can just

var letters = words[i][0]; //to access the first letter
Chris Hutchinson
@pablanopete
Aug 19 2016 03:30
@wearenotgroot Thanks, I got it on the first try when I remembered the earlier lesson.
CamperBot
@camperbot
Aug 19 2016 03:30
hutchie25 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1404 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Aug 19 2016 03:31
@hutchie25 :+1:
Chris Hutchinson
@pablanopete
Aug 19 2016 03:31
It's hard coming back to a lesson after 3 days of working lol.
O_O
mzedlach
@mzedlach
Aug 19 2016 03:31
@wearenotgroot OKay, both work. But why is the output not giving one solid string?
@wearenotgroot Even in the visualizer, words.join(" ") does not seam to do anything to the array.
greg
@wearenotgroot
Aug 19 2016 03:32
@mzedlach you need to use slice to get the rest of the string(rest of the letters)
Chris Hutchinson
@pablanopete
Aug 19 2016 03:32
It's like they up the variable for me and i'm looking to write the code myself and i make something that's supposed to be really easy harder. haha.
Joseph
@revisualize
Aug 19 2016 03:33
Okay.. Who needs help on something?
I'm willing to get on a pair programming site and help someone with almost any lesson that I've completed.
greg
@wearenotgroot
Aug 19 2016 03:34
@mzedlach oh and you need to either store the string given by the .join(' ') to some variable or just return it
mzedlach
@mzedlach
Aug 19 2016 03:34
@wearenotgroot I don't see how slice would aply
Joseph
@revisualize
Aug 19 2016 03:34
@mzedlach It applies 100%
greg
@wearenotgroot
Aug 19 2016 03:34
@mzedlach on your current code i guess you dont need to
@mzedlach the problem was you didnt store or return the value of the .join(' ')
return words.join(" ");
mzedlach
@mzedlach
Aug 19 2016 03:35
I'm just reading up on slice for the first time... it just selects certain elements from an array?
Joseph
@revisualize
Aug 19 2016 03:35
@mzedlach Want to pair?
mzedlach
@mzedlach
Aug 19 2016 03:35
@wearenotgroot That's it!?
Joseph
@revisualize
Aug 19 2016 03:36
@mzedlach I can give you 4 different ways to solve that challenge and explain each one.
mzedlach
@mzedlach
Aug 19 2016 03:36
@revisualize I have never paired before... I'm not really sure what it entails
Joseph
@revisualize
Aug 19 2016 03:36
Do you have speakers?
mzedlach
@mzedlach
Aug 19 2016 03:36
I'm on a mac, so yes :)
Joseph
@revisualize
Aug 19 2016 03:36
Okay.
mzedlach
@mzedlach
Aug 19 2016 03:37
Thank you @wearenotgroot
CamperBot
@camperbot
Aug 19 2016 03:37
mzedlach sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1405 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Michael Noronha
@mtn
Aug 19 2016 03:37
unrelated, but does anyone in here have experience working in ruby?
Joseph
@revisualize
Aug 19 2016 03:37
I'd be willing to walk you through that whole challenge.
greg
@wearenotgroot
Aug 19 2016 03:37
@mzedlach :+1:
Joseph
@revisualize
Aug 19 2016 03:37
FreeCodeCamp/HelpJavaScript
mzedlach
@mzedlach
Aug 19 2016 03:37
@revisualize Sure :)
Joseph
@revisualize
Aug 19 2016 03:37
@mzedlach Sweet. Let me get a url and PM you.
Pogg
@fogkio
Aug 19 2016 03:37
hello
i need help
anyone?
Michael Noronha
@mtn
Aug 19 2016 03:38
@fogkio on?
Pogg
@fogkio
Aug 19 2016 03:38
i stuck in this solve


var count = 0;

function cc(card) {
  var i = 0;
  // Only change code below this line
  switch (card){
    case 2: case 3: case 4: case 5: case 6:
      i++;
      break;
    case 7: case 8: case 9:
      break;
    case 10: case'J': case 'Q': case 'K': case 'A':
      i--;
      break;
  }
  if(count>0)
    return i;
  else if(count<0)
    return i;
 // 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');
greg
@wearenotgroot
Aug 19 2016 03:39
@fogkio why not use count instead of i
Pogg
@fogkio
Aug 19 2016 03:39
why i use this to return then its doesnt work
no no
i use count
i just a sample i try
greg
@wearenotgroot
Aug 19 2016 03:39
@fogkio yeah but you increas and decrease i so? you didnt change the value of count
Pogg
@fogkio
Aug 19 2016 03:40
but doesnt work
wait
Chris Wu
@chriswudotnet
Aug 19 2016 03:40
I think I found a bug on the Mutations Algo Challenge
greg
@wearenotgroot
Aug 19 2016 03:40
@fogkio try and log the value to console, it will be 0
@chriswudotnet do tell? or show?
Pogg
@fogkio
Aug 19 2016 03:41
console.log?
greg
@wearenotgroot
Aug 19 2016 03:42
@fogkio yes
Chris Wu
@chriswudotnet
Aug 19 2016 03:42
function mutation(arr) {
  var newArr = arr[0].toLowerCase();
  var index = arr[1].toLowerCase().split("");
  for (var i = 0; i < index.length; i++) {
    return newArr.indexOf(index[i]) !== -1;
  }
}
function mutation(arr) {
var newArr = arr[0].toLowerCase();
var index = arr[1].toLowerCase().split("");
for (var i = 0; i < index.length; i++) {
return newArr.indexOf(index[i]) !== -1;
}
}
I have this code
all verified except the first one
mutation(["hello", "hey"])
i ran it manually, and it did returned a -1 on index[2]
greg
@wearenotgroot
Aug 19 2016 03:43
@chriswudotnet what does return do`? do you remember?
Chris Wu
@chriswudotnet
Aug 19 2016 03:43
and it should return false
the mutation need to contain all the letter in array[1]
which in this case does not. hello has no 'y'
greg
@wearenotgroot
Aug 19 2016 03:44
@chriswudotnet how many time do you thing that for loop will iterate?
Abis Mal
@abisthecodermal
Aug 19 2016 03:44
@darrenfJ around?
Chris Wu
@chriswudotnet
Aug 19 2016 03:44
3 times, from 0 to 2
Pogg
@fogkio
Aug 19 2016 03:45
did i forgot somethings?
greg
@wearenotgroot
Aug 19 2016 03:45
@chriswudotnet you sure?
Chris Wu
@chriswudotnet
Aug 19 2016 03:45
@wearenotgroot yes
greg
@wearenotgroot
Aug 19 2016 03:45
@chriswudotnet here, check the value of i
function mutation(arr) {
  var newArr = arr[0].toLowerCase();
  var index = arr[1].toLowerCase().split("");
  for (var i = 0; i < index.length; i++) {
    console.log(i); //check the value of i
    return newArr.indexOf(index[i]) !== -1;
  }
}
mutation(["hello", "hey"]);
Pogg
@fogkio
Aug 19 2016 03:46
This message was deleted


var count = 0;

function cc(card) {
  // Only change code below this line
  switch (card){
    case 2: case 3: case 4: case 5: case 6:
      count++;
      break;
    case 7: case 8: case 9:
      break;
    case 10: case'J': case 'Q': case 'K': case 'A':
      count--;
      break;
  }
  if(count>0)
    console.log(count+"Bet");
  else if(count<0)
    console.log(count+"Hold");
 // 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');
Diego Mayer
@Chrono79
Aug 19 2016 03:46
@fogkio 3 things:
return, don't use console.log
leave a space between count and Bet or Hold
what if count is 0?
Pogg
@fogkio
Aug 19 2016 03:47
where bro?
greg
@wearenotgroot
Aug 19 2016 03:47
@chriswudotnet so what is the value of i?(it's 0)
Pogg
@fogkio
Aug 19 2016 03:47
i?
wheree?
Abis Mal
@abisthecodermal
Aug 19 2016 03:48
@fogkio why do you want to print it?
greg
@wearenotgroot
Aug 19 2016 03:48
@chriswudotnet remember what happens to you code when it encounter a return
Abis Mal
@abisthecodermal
Aug 19 2016 03:48
remove console.log what is the objective?
Pogg
@fogkio
Aug 19 2016 03:49
help me how to fix this
CamperBot
@camperbot
Aug 19 2016 03:49
no wiki entry for: me how to fix this
Abis Mal
@abisthecodermal
Aug 19 2016 03:49
no problem. State the challenge name
Pogg
@fogkio
Aug 19 2016 03:49
Counting Cards
Diego Mayer
@Chrono79
Aug 19 2016 03:50
@fogkio already told you
greg
@wearenotgroot
Aug 19 2016 03:50
@abisthecodermal @Chrono79 was supposed to check the value of count, since he thought he was changing it's value
Chris Wu
@chriswudotnet
Aug 19 2016 03:50
@wearenotgroot thanks. I think i know what my mistake is
CamperBot
@camperbot
Aug 19 2016 03:50
chriswudotnet sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1406 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Aug 19 2016 03:50
@chriswudotnet :+1:
Abis Mal
@abisthecodermal
Aug 19 2016 03:50
You need a space between count and bet
that's 1
Pogg
@fogkio
Aug 19 2016 03:51
did it
Abis Mal
@abisthecodermal
Aug 19 2016 03:51
for second, you need to return a value
Pogg
@fogkio
Aug 19 2016 03:51
what next bro
Diego Mayer
@Chrono79
Aug 19 2016 03:51
@fogkio 3 things:
return, don't use console.log
leave a space between count and Bet or Hold
what if count is 0?
Pogg
@fogkio
Aug 19 2016 03:51
let me think
if i dont use console.log
Abis Mal
@abisthecodermal
Aug 19 2016 03:52
every function must return a value. Once you get to the exception, you will know which functions don't return a value ;)
yes @fogkio
Pogg
@fogkio
Aug 19 2016 03:54
ok i return its
i was add return in my function
now its work
Abis Mal
@abisthecodermal
Aug 19 2016 03:55
instead of console.log, you need return statements @fogkio
Pogg
@fogkio
Aug 19 2016 03:55
ohhhh
okay
let me try
Abis Mal
@abisthecodermal
Aug 19 2016 03:55
post your updated code @fogkio
Pogg
@fogkio
Aug 19 2016 03:57
posting


var count = 0;

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
Abis Mal
@abisthecodermal
Aug 19 2016 03:58
Where are the return statements?
Pogg
@fogkio
Aug 19 2016 03:58
inside function
now result
is 5
because count increse 5 times
but console log doesnt work
Abis Mal
@abisthecodermal
Aug 19 2016 03:59
if(count>0){
  return count + " Bet";
}
else if (count=<0){
  return count + " Hold";
}
Pogg
@fogkio
Aug 19 2016 03:59
did i forgot something?
Abis Mal
@abisthecodermal
Aug 19 2016 03:59
something like this….
Pogg
@fogkio
Aug 19 2016 04:00
let me try
Abis Mal
@abisthecodermal
Aug 19 2016 04:00
I have edited the above code @fogkio
Pogg
@fogkio
Aug 19 2016 04:01
cant
return not in function
that is mistake
name of mistake
Abis Mal
@abisthecodermal
Aug 19 2016 04:02
every function must have a return statement. Remember this for now…..
and the place where you place return ends the function...
return is a function terminator...
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:04
Hey guys, I'm not seeing my if statement work the way that I feel it should be, do you guys have any clues?

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
   var checkVal = function(obj){
     var sourceKeys = Object.keys(source);
     var soFarSoGood = true;
     for(var e = 0; e<sourceKeys.length;e++){
       console.log(obj[sourceKeys[e]]);
       console.log(source[sourceKeys[e]]);

       if(!obj.hasOwnProperty(sourceKeys[e])&&obj[sourceKeys[e]]!==source[sourceKeys[e]]){
         soFarSoGood=false;
         console.log(obj);
         break;
       }
     }

     if(soFarSoGood)
       return obj;
    };


  arr = collection.filter(checkVal);

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

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Abis Mal
@abisthecodermal
Aug 19 2016 04:05
  return count; //<-- the function terminates here….
 //Rest of the code does not execute...
}
if(count>=0){
  console.log(count + "Bet");
}
else if (count<0){
  console.log(count + "Hold");
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
@fogkio
Pogg
@fogkio
Aug 19 2016 04:05
Im done
:)))
Abis Mal
@abisthecodermal
Aug 19 2016 04:06
completed the challenge? @fogkio
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:06
It's returning every object when my console.logs suggest that the information that I'm testing should be failing for the first two objects
Pogg
@fogkio
Aug 19 2016 04:06
do you want to see what am i doing
yes
greg
@wearenotgroot
Aug 19 2016 04:06
@GikuyuNderitu remember how filter work? if you want to keep the item the return true otherwise return false on your callback function
Pogg
@fogkio
Aug 19 2016 04:06
@abisthecodermal
Abis Mal
@abisthecodermal
Aug 19 2016 04:07
sure @fogkio
Pogg
@fogkio
Aug 19 2016 04:07


var count = 0;

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

  }
  if(count>0)
    return count + " Bet";
  if(count<=0)
    return count +" Hold";
 // Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
:smile:
Abis Mal
@abisthecodermal
Aug 19 2016 04:07
Now explain this code. It will increase your understanding of a code… @fogkio
Pogg
@fogkio
Aug 19 2016 04:07
that it's :))
Abis Mal
@abisthecodermal
Aug 19 2016 04:08
:clap: :clap: good job @fogkio
Pogg
@fogkio
Aug 19 2016 04:08
i explain my code to you?
Abis Mal
@abisthecodermal
Aug 19 2016 04:08
yes
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:08
@wearenotgroot oh yea, that's right. when I change it to return my boolean value, i'm still not seeing the result set I suspect I should be seeing
greg
@wearenotgroot
Aug 19 2016 04:08

@GikuyuNderitu and this line

var sourceKeys = Object.keys(source);

should be outside your callback function otherwise you would be re-executing it

Pogg
@fogkio
Aug 19 2016 04:08
my english is not good at all
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:08
@wearenotgroot good point, I'll remove that
Pogg
@fogkio
Aug 19 2016 04:09
:worried: im worry about it
Abis Mal
@abisthecodermal
Aug 19 2016 04:09
that's the story about most of us. Do not worry
Pogg
@fogkio
Aug 19 2016 04:10
let me tell my stories =)) firstly, i wrong about when i think must have console.log to print to screen
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:10

function titleCase(str) {
  var arrayStr = [];
  var arraySent = [];
  var arrayWord = [];

  arrayStr = str.split(" ");
  str = "";

  for (var i = 0; i < arrayStr.length; i++){
    arraySent = arrayStr[i].split("");

    for (var j = 0; j < arraySent.length; j++){
      arrayWord.push(arraySent[j].toLowerCase()); 
    }

    arrayWord[0] = arrayWord[0].toUpperCase();
    str += arrayWord.join("") + " ";
    arrayWord = [];


  }
  return str;
This returns the correct outputs but isn't being counted as correct
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:11
@wearenotgroot do you have any clue as to why my if statement isn't catching Romeo and Mercutio?
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:11
Oh, this is for the title case assignment
Abis Mal
@abisthecodermal
Aug 19 2016 04:11
@mayhawstudios why is the return outside the function? or its not?
Pogg
@fogkio
Aug 19 2016 04:11
1 function must have return inside
greg
@wearenotgroot
Aug 19 2016 04:11
@GikuyuNderitu use || since you tested the opposite (not equal)
when either the property doesnt exist or its value is not equal then return false
Pogg
@fogkio
Aug 19 2016 04:12
it's a rules
i forgot this
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:12
@abisthecodermal It's not. I forgot to copy the closing bracket for the function.
Abis Mal
@abisthecodermal
Aug 19 2016 04:12
oh.. ok @mayhawstudios
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:12
@wearenotgroot I see that that worked, thanks
CamperBot
@camperbot
Aug 19 2016 04:12
gikuyunderitu sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1408 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:13
@wearenotgroot do you know why it worked though? the second control should compare the value of the last name
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:13
function titleCase(str) {
  var arrayStr = [];
  var arraySent = [];
  var arrayWord = [];

  arrayStr = str.split(" ");
  str = "";

  for (var i = 0; i < arrayStr.length; i++){
    arraySent = arrayStr[i].split("");

    for (var j = 0; j < arraySent.length; j++){
      arrayWord.push(arraySent[j].toLowerCase()); 
    }

    arrayWord[0] = arrayWord[0].toUpperCase();
    str += arrayWord.join("") + " ";
    arrayWord = [];


  }
  return str;
}
Is how the function actually looks.
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:13
and if those don't match up, it shouldn't past the test?
Pogg
@fogkio
Aug 19 2016 04:13
did freecodecamp learn SQL bro???
Abis Mal
@abisthecodermal
Aug 19 2016 04:14
not all function need return statements @fogkio But we discuss that some other time. After you complete more assignments
Pogg
@fogkio
Aug 19 2016 04:14
okaayyy
@abisthecodermal thanks
CamperBot
@camperbot
Aug 19 2016 04:14
fogkio sends brownie points to @abisthecodermal :sparkles: :thumbsup: :sparkles:
:cookie: 357 | @abisthecodermal |http://www.freecodecamp.com/abisthecodermal
Abis Mal
@abisthecodermal
Aug 19 2016 04:14
@mayhawstudios why are you splitting the empty array?
You are welcome @fogkio
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:15
@abisthecodermal which line are you referring to?
greg
@wearenotgroot
Aug 19 2016 04:16
@GikuyuNderitu if either one is true then the statement triggere(using ||) with && you need both to be true
Abis Mal
@abisthecodermal
Aug 19 2016 04:16
function titleCase(str) {
  var arrayStr = [];
  var arraySent = [];
  var arrayWord = [];

  arrayStr = str.split(" ");
@mayhawstudios
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:17
I think that's meant to split the str var into individual words and populate the array.
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:17
@wearenotgroot wow... I must be exhausted. I was telling myself that the whole time as a reason for its unnecesity, I guess it takes someone else to say it for the logic to actually hit. Thanks again!
CamperBot
@camperbot
Aug 19 2016 04:17
:warning: gikuyunderitu already gave wearenotgroot points
gikuyunderitu sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Aug 19 2016 04:17
@GikuyuNderitu using or allows you to do it quicker since you only need to check either the property exist, if not then no need to check the value. but if it exist then check the value
@GikuyuNderitu :+1:
Abis Mal
@abisthecodermal
Aug 19 2016 04:18

arrayStr is blank

var arrayStr = [];

you cannot split an empty array at spaces

arrayStr = str.split(" ");
@mayhawstudios
greg
@wearenotgroot
Aug 19 2016 04:19
anyways going to :zzz:
GL and Happy Coding to everyone!
Abis Mal
@abisthecodermal
Aug 19 2016 04:19
bye @wearenotgroot
good night
greg
@wearenotgroot
Aug 19 2016 04:20
@abisthecodermal :wave:
Gikuyu Nderitu
@GikuyuNderitu
Aug 19 2016 04:20
goodnight @wearenotgroot
Abis Mal
@abisthecodermal
Aug 19 2016 04:20
:wave:
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:21
@abisthecodermal str is the variable for titleCase(str). When I set it to return the value of arrayStr, I get the array with each word split.
Abis Mal
@abisthecodermal
Aug 19 2016 04:21

Where?

When I set it to return the value of arrayStr

@mayhawstudios. You have declared an empty array
var arrayStr = [];
nowhere has the value of str copied into it
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:22
@abisthecodermal posting the full code and not just the function:
function titleCase(str) {
  var arrayStr = [];
  var arraySent = [];
  var arrayWord = [];

  arrayStr = str.split(" ");
  return arrayStr;
  str = "";

  for (var i = 0; i < arrayStr.length; i++){
    arraySent = arrayStr[i].split("");

    for (var j = 0; j < arraySent.length; j++){
      arrayWord.push(arraySent[j].toLowerCase()); 
    }

    arrayWord[0] = arrayWord[0].toUpperCase();
    str += arrayWord.join("") + " ";
    arrayWord = [];


  }
  return str;
}

titleCase("sHoRt AnD sToUt");
Abis Mal
@abisthecodermal
Aug 19 2016 04:22
ok
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:24
I think I may know the problem. Adding a space after every word might add a space at the end of the string so it doesn't match perfectly with the final result.
Abis Mal
@abisthecodermal
Aug 19 2016 04:24
function titleCase(str) {
  var arrayStr = [];
  var arraySent = [];
  var arrayWord = [];

  arrayStr = str.split(" ");
  return arrayStr;
  str = "";
Look at it. I don't see the value copying to arrayStr. brb
Aditya
@ezioda004
Aug 19 2016 04:24
@mayhawstudios Right, its adding a space at the end
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 04:27
any reason why we're returning something and then trying to do stuff after that?
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:27
@Chovin Oh, sorry, that was just to test arrayStr.
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 04:28
ah
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:29
I guess I just need to remove the extra space at the end. Either there's a better way of putting the words together in the string or removing the space at the end.
Joseph
@revisualize
Aug 19 2016 04:30
Funny faces!
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 04:30
trim?
join?
confused
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:31
@Chovin YES! That worked! Thank you!
CamperBot
@camperbot
Aug 19 2016 04:31
mayhawstudios sends brownie points to @chovin :sparkles: :thumbsup: :sparkles:
:cookie: 214 | @chovin |http://www.freecodecamp.com/chovin
Patrick Lippert
@mayhawstudios
Aug 19 2016 04:32
@Chovin To clarify, trim() did the trick.
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 04:32
:thumbsup:
Joseph
@revisualize
Aug 19 2016 04:33
ACK! 8% battery left.
Chris Cullen
@123xylem
Aug 19 2016 04:34
$("#action").click(function (){
setInterval(countdown,1000);  
  var countdownID = setInterval(countdown,1000);

}); //COuntdown Button

function countdown(){
   $("#face").text(getTime(time)); //show time 
    $("#set1").text(getTime(time));

  if (time<=0){//if time gets to 0
  clearInterval(countdownID);
  } //stop that function with variable
  time -=1;
};//Countdown Button Function


$("#break").click(function (){
  clearInterval(countdownID);
  var countdownID2 = setInterval(countdown2,1000);
  setInterval(countdown2,1000);
});


function countdown2(){
   $("#face").text(getTime(time2)); //show BREAK time 
    $("#set2").text(getTime(time2));

  if (time2<=0){
    clearInterval(countdownID2);
    setInterval(countdown,1000);}
  time2 -=1;
};
My action works fine now (well apart from it counts double time) BUT the Problem im trying to figure out here is why my BREAK function doesnt Do ANYTHING??
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 04:35
I see no getTime() function
lazy_bunny
@lazyCoder036
Aug 19 2016 04:36
hi all, need some help with jquery
help help help
CamperBot
@camperbot
Aug 19 2016 04:37
no wiki entry for: help help
Pogg
@fogkio
Aug 19 2016 04:39
@lazyCoder036 come on your question
lazy_bunny
@lazyCoder036
Aug 19 2016 04:39
need some book reference for jquery
Michael Noronha
@mtn
Aug 19 2016 04:39
about michaeltnoronha
CamperBot
@camperbot
Aug 19 2016 04:39
you need to ask about @someone!
Michael Noronha
@mtn
Aug 19 2016 04:39
about @michaeltnoronha
CamperBot
@camperbot
Aug 19 2016 04:39
:cookie: 331 | @michaeltnoronha |http://www.freecodecamp.com/michaeltnoronha
Michael Noronha
@mtn
Aug 19 2016 04:39
So I updated my gh username
lazy_bunny
@lazyCoder036
Aug 19 2016 04:39
@fogkio just finish the algorithm challenge
Michael Noronha
@mtn
Aug 19 2016 04:40
@lazyCoder036 jquery algorithm challenge?
lazy_bunny
@lazyCoder036
Aug 19 2016 04:40
@michaeltnoronha nah
@michaeltnoronha js algorithm challenge.
Michael Noronha
@mtn
Aug 19 2016 04:40
@lazyCoder036 gotcha. I think I had the same problem
@lazyCoder036 do you feel like you know no jquery?
lazy_bunny
@lazyCoder036
Aug 19 2016 04:41
@michaeltnoronha no
that is the probelm
need to learn basic synax
Joseph
@revisualize
Aug 19 2016 04:41
Hi. (I am mobile.)
lazy_bunny
@lazyCoder036
Aug 19 2016 04:41
syntax *
Michael Noronha
@mtn
Aug 19 2016 04:41
@lazyCoder036 right, I had the same problem!
lazy_bunny
@lazyCoder036
Aug 19 2016 04:41
hi @revisualize
Michael Noronha
@mtn
Aug 19 2016 04:41
@lazyCoder036 and still have :D. but i'm more cocerned with algorithms at the moment
lazy_bunny
@lazyCoder036
Aug 19 2016 04:42
@michaeltnoronha are you re visiting those challenge again ?
@revisualize can you help me with jquery
Michael Noronha
@mtn
Aug 19 2016 04:43
I will be. at the moment I've also been having to learn/work in some other languages, so focusing on theory a bit
Joseph
@revisualize
Aug 19 2016 04:43
Nope.
I am buzzed. And mobile.
But, buzzed.
lazy_bunny
@lazyCoder036
Aug 19 2016 04:43
@revisualize haha
Michael Noronha
@mtn
Aug 19 2016 04:43
Anyone know if there's a cli for gitter?
This slows my computer pretty significantly
lazy_bunny
@lazyCoder036
Aug 19 2016 04:43
@revisualize need some suggestion
Joseph
@revisualize
Aug 19 2016 04:43
There is an IRC.
I need bed.
Michael Noronha
@mtn
Aug 19 2016 04:44
@revisualize Thanks, I'll look into it!
CamperBot
@camperbot
Aug 19 2016 04:44
:star2: 1682 | @revisualize |http://www.freecodecamp.com/revisualize
michaeltnoronha sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
lazy_bunny
@lazyCoder036
Aug 19 2016 04:44
@revisualize can you suggest me some good book name
@revisualize jquery book
Chris Cullen
@123xylem
Aug 19 2016 04:44
$("#action").click(function (){
setInterval(countdown,1000);  
  var countdownID = setInterval(countdown,1000);

}); //COuntdown Button

function countdown(){
   $("#face").text(getTime(time)); //show time 
    $("#set1").text(getTime(time));

  if (time<=0){//if time gets to 0
  clearInterval(countdownID);
  } //stop that function with variable
  time -=1;
}//Countdown Button Function


$("#break").click(function (){
  clearInterval(countdownID);
  var countdownID2 = setInterval(countdown2,1000);
  setInterval(countdown2,1000);
});


function countdown2(){
   $("#face").text(getTime(time2)); //show BREAK time 
    $("#set2").text(getTime(time2));

  if (time2<=0){
    clearInterval(countdownID2);
    setInterval(countdown,1000);}
  time2 -=1;
}
Quick Q: WHy is my Break Click Not Clearing INterval of Action???
Joseph
@revisualize
Aug 19 2016 04:45
@lazyCoder036 nope. But google: learn shay howe
lazy_bunny
@lazyCoder036
Aug 19 2016 04:45
@revisualize there are so many suggestion
i got lost :(
@michaeltnoronha did you finish the js algo yet ?
Michael Noronha
@mtn
Aug 19 2016 04:47
@lazyCoder036 I've completed basic and worked on but not finished either intermediate or advanced
@revisualize I knew a guy who knows shaw howe!
lazy_bunny
@lazyCoder036
Aug 19 2016 04:47
@michaeltnoronha me too
@michaeltnoronha just like you
Joseph
@revisualize
Aug 19 2016 04:47
Hehe
lazy_bunny
@lazyCoder036
Aug 19 2016 04:47
wondering, what should I do about jquery now
don't understand a single line syntax :/
Ghost
@ghost~56e6574085d51f252ab8a59d
Aug 19 2016 05:01
what is getTime() ?
Joseph
@revisualize
Aug 19 2016 05:09
OKAY!
I need an assist.
Joseph
@revisualize
Aug 19 2016 05:15
Why isn't anything working?
cbot
CamperBot
@camperbot
Aug 19 2016 05:15
you called?
Hi everyone
this challenge does not allow my code
although my output is right
DJ
@qualitymanifest
Aug 19 2016 05:20
@KhanhNB paste your code
Khanh Nguyen
@KhanhNB
Aug 19 2016 05:20

var result = [];

function pull(arr){
for(var i=0; i<arr.length; i++){
if(!Array.isArray(arr[i])) result.push(arr[i]);
else pull(arr[i]);
}
}
function steamrollArray(arr) {
// I'm a steamroller, baby
pull(arr);
return result;
}

steamrollArray([1, {}, [3, [[4]]]]);

Markus Kiili
@Masd925
Aug 19 2016 05:21
@KhanhNB Global variables mess up FCC tests.
Khanh Nguyen
@KhanhNB
Aug 19 2016 05:22
ok :)
I will try to change it
Markus Kiili
@Masd925
Aug 19 2016 05:22
@KhanhNB Some copy-pasting will do.
lazy_bunny
@lazyCoder036
Aug 19 2016 05:23
@Masd925 can you please suggest me some good jquery book
Khanh Nguyen
@KhanhNB
Aug 19 2016 05:23
everything is fine now
thank you :)
lazy_bunny
@lazyCoder036
Aug 19 2016 05:23
@Masd925 I just don't understand a single line of jquery
@Masd925 need to learn the basic syntax first
Markus Kiili
@Masd925
Aug 19 2016 05:26
@lazyCoder036 Sorry, don't know any books on that. I think I used jquery homepage and W3Schools/Tutorialspoint when I learned jQuery. And some random book.
@KhanhNB Now do it without recursion ;)
lazy_bunny
@lazyCoder036
Aug 19 2016 05:42
@Masd925 thanks :D
CamperBot
@camperbot
Aug 19 2016 05:42
lazycoder036 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2321 | @masd925 |http://www.freecodecamp.com/masd925
arif hussain
@arifhussain0
Aug 19 2016 05:50
hello.. just wanted to know that how to flatten the array in steamroller exercise??
Markus Kiili
@Masd925
Aug 19 2016 05:52
@arifhussain0 Because the depth of subarraying is not known, the most used way is to use recursion.
@arifhussain0 Concat method is very helpful too.
arif hussain
@arifhussain0
Aug 19 2016 05:52
well i thought of these two as well
looks like i am on the right track
Markus Kiili
@Masd925
Aug 19 2016 05:54
@arifhussain0 On the recursion part, you can use an inner function or not.
arif hussain
@arifhussain0
Aug 19 2016 06:03

function inn(num)
{
if(Array.isArray(num))
{
return inn(num);
}
else
{
return num;
}
}

function steamrollArray(arr) {
// I'm a steamroller, baby
var x=[];
for (var i=0;i<arr.length;i++)
{
x.push(inn(arr[i]));
}

return x;
}

@Masd925 it says max stack size exceded
Markus Kiili
@Masd925
Aug 19 2016 06:04
@arifhussain0 Infinite loop or recursion most probably.
arif hussain
@arifhussain0
Aug 19 2016 06:05
but the logic looks fine to me.. do u see any problem?
Markus Kiili
@Masd925
Aug 19 2016 06:05
@arifhussain0 Try to format the code for easier reading.
explain format
CamperBot
@camperbot
Aug 19 2016 06:05

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Markus Kiili
@Masd925
Aug 19 2016 06:07
@arifhussain0 If an array is passed to inn it will call itself infinitely.
arif hussain
@arifhussain0
Aug 19 2016 06:08
why so?? because if num is an array only then it will call itself otherwise it return a number
Markus Kiili
@Masd925
Aug 19 2016 06:10
If num is an array inn(num) will call inn(num) that will call inn(num)...
arif hussain
@arifhussain0
Aug 19 2016 06:11
oo yes.. but now i have called inn(num[0]) if num is array
it is still not passing all tests
Markus Kiili
@Masd925
Aug 19 2016 06:12
The problem is that you cannot pass an array to inn.
arif hussain
@arifhussain0
Aug 19 2016 06:12
ok got it
Hon Weng Chong
@hwchong
Aug 19 2016 06:16
hey guys, is it possible to pass a variables from outside a function into a callback and have it be returned?
Markus Kiili
@Masd925
Aug 19 2016 06:19
@hwchong If you are talking about JS array methods, some of them have a special thisArg that sets the value of this when the callback is invoked. That way you can pass a value to the callback.
The value is coerced to an object, so remember that if you pass a primitive.
Hon Weng Chong
@hwchong
Aug 19 2016 06:20
Thanks! Does that also with async callback functions?
Markus Kiili
@Masd925
Aug 19 2016 06:21
@hwchong The callback can access variables on the outer scope, so maybe you can do it that way.
Patrick S
@thinktwice84
Aug 19 2016 06:47
Quick question. I'm trying to remove all non-alphanumeric characters from a string with this code: str.replace(/[^A-Za-z0-9_]/gi, '') but it's not working. Any ideas?
Markus Kiili
@Masd925
Aug 19 2016 06:51
@thinktwice84 Are you storing the new string it returns?
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 06:51
@thinktwice84 ```
Patrick S
@thinktwice84
Aug 19 2016 06:51
I'm just returning it immediately
return str.replace(/[^A-Za-z0-9_]/gi, '').toLowerCase(); <-- that's my code
Markus Kiili
@Masd925
Aug 19 2016 06:53
@thinktwice84 I think it does remove them.
ANACLETO SANTIAGO A. OBLEA
@anacletosantiago
Aug 19 2016 06:55
hi to all
Markus Kiili
@Masd925
Aug 19 2016 06:55
var str = "sgee  436g)/&";

console.log(str.replace(/[^A-Za-z0-9_]/gi, '')); // "sgee436g"
SaltyAir
@SaltyAir
Aug 19 2016 06:56
@thinktwice84 _ does not work but the rest is fine.
Patrick S
@thinktwice84
Aug 19 2016 06:57
Awesome, thanks @Masd925
CamperBot
@camperbot
Aug 19 2016 06:57
thinktwice84 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2322 | @masd925 |http://www.freecodecamp.com/masd925
ANACLETO SANTIAGO A. OBLEA
@anacletosantiago
Aug 19 2016 06:58

guys pls help me pls check whats wrong to my task ```js
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";

// Your code below this line
}
var myNoun = " Dog ";
var myAdjective ="big";
var myVerb ="ran";
var myAdverb ="quickly";

myStr += "My pretty "+ myNoun +", is "+ myAdjective +", "+ myVerb +", very "+ myAdverb +".";{

// Your code above this line
return result;
}
{

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

Mostafa Syam
@pro-mos
Aug 19 2016 06:58
help format
CamperBot
@camperbot
Aug 19 2016 06:58

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

abelrafaa
@abelrafaa
Aug 19 2016 06:59

function factorialize(num) {
var d=1,i=1;
for(i=1;i<=num.length-1;i++)
{
d=d*i;
}
return d;
}

factorialize(5);

I need some help!
Markus Kiili
@Masd925
Aug 19 2016 07:01
@abelrafaa num is a number. Doesn't have .length property.
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 07:01

num.length-1
here our problem
abelrafaa
@abelrafaa
Aug 19 2016 07:01
ohhh
thanks
be blessed!
CyrahFH
@CyrahFH
Aug 19 2016 07:10
Escape Sequences in Strings cannot complete this task..
some help please
Mostafa Syam
@pro-mos
Aug 19 2016 07:13
@CyrahFH post your code wrapped in "```"
Josh A
@ai3gtmc
Aug 19 2016 07:13
Hello
Mostafa Syam
@pro-mos
Aug 19 2016 07:13
Hi ^
CyrahFH
@CyrahFH
Aug 19 2016 07:14
var myStr = 'I hate laggy \n \ mornings \ \raloha'; // Change this line
Josh A
@ai3gtmc
Aug 19 2016 07:14
I need some Javascript help. :/ something about a loop not working correctly
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 07:15
@ai3gtmc show your code
Josh A
@ai3gtmc
Aug 19 2016 07:16

```var locator = 0;
while (locator < Object.keys(store).length) {
if (locator < store[locator]){
locator++;
} else {
var playList = "<li>" + (locator + 1) + ". " + store[locator]["Song"] + " - " + store[locator]["Artist"] + " - " + store[locator]["Genre"] + " - " + '<audio controls id="audio"><source src="' + store[locator]["Link"] + '" type="audio/mp3">' + '</audio>';

  playList += '<button type="button" name="update" class="editButton" id="' +  store[locator]["id"] + '">Edit</button>';
  playList += '<button type="button" name="delete" class="delButton" id="' + store[locator]["id"] + '">Delete</button>';
  playList += '</li>';
  $("#showSongs").append(playList);
}

}```

whoops
sorry
let me post that again
var locator = 0;
  while (locator < Object.keys(store).length) {
    if (locator < store[locator]){
      locator++;
    } else {
      var playList = "<li>" + (locator + 1) + ". " + store[locator]["Song"] + " - " + store[locator]["Artist"] + " - " + store[locator]["Genre"] + " - " + '<audio controls id="audio"><source src="' + store[locator]["Link"] + '" type="audio/mp3">' + '</audio>';

      playList += '<button type="button" name="update" class="editButton" id="' +  store[locator]["id"] + '">Edit</button>';
      playList += '<button type="button" name="delete" class="delButton" id="' + store[locator]["id"] + '">Delete</button>';
      playList += '</li>';
      $("#showSongs").append(playList);
    }

  }
I get an "Uncaught TypeError: Cannot read property 'Song' of undefined" error when it gets to "store[locator]["Song"]"
typing "store[number]["Song"]" in the console works fine though. and at first it shows, but once I delete an object inside it breaks
Mark Todd
@Knochenmark
Aug 19 2016 07:21
@ai3gtmc well guess its undefined then, since we dont know more about the object you access
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 07:21
@ai3gtmc Are you sure that store[locator] is exist?
Josh A
@ai3gtmc
Aug 19 2016 07:21
it does work when I type it in the console
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 07:21
console.log(store[locator]);
try add this console
@ai3gtmc you say that you type "store[number]["Song"]" but in your code "store[locator]["Song"]"
Mark Todd
@Knochenmark
Aug 19 2016 07:23
@ai3gtmc why you loop it by locator? you could just use the keys from Object.keys instead
@ai3gtmc that while loop in general is pretty strange
Josh A
@ai3gtmc
Aug 19 2016 07:23
@Knochenmark tell me more about it
@ArtemOnischenko I used the locator to iterate. crap I'm just lost right now
Mark Todd
@Knochenmark
Aug 19 2016 07:25
@ai3gtmc what you want to do is
for(var key in store) {
// do somthing with store[key]
}
Josh A
@ai3gtmc
Aug 19 2016 07:26
I did that earlier
same error.
here's the code
  for (var i = 0; i<Object.keys(store).length;i++) {
      var playList = "<li>" + (i + 1) + ". " + store[i]["Song"] + " - " + store[i]["Artist"] + " - " + store[i]["Genre"] + " - " + '<audio controls id="audio"><source src="' + store[i]["Link"] + '" type="audio/mp3">' + '</audio>';

      playList += '<button type="button" name="update" class="editButton" id="' +  store[i]["id"] + '">Edit</button>';
      playList += '<button type="button" name="delete" class="delButton" id="' + store[i]["id"] + '">Delete</button>';
      playList += '</li>';
      $("#showSongs").append(playList);
  }
Mark Todd
@Knochenmark
Aug 19 2016 07:26
then your object property is undefined obviously...
Josh A
@ai3gtmc
Aug 19 2016 07:27
wait wrong one
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 07:27
@ai3gtmc its not the same
Mark Todd
@Knochenmark
Aug 19 2016 07:27
yeah, not the same
CyrahFH
@CyrahFH
Aug 19 2016 07:28
var myStr = "Laggy \n \mornings \ \r Aloha"; // Change this line
myStr should have encoded text with the proper escape sequences and no spacing. This error still exists.. T_T
Mark Todd
@Knochenmark
Aug 19 2016 07:28
@CyrahFH well, theres spacing?
CyrahFH
@CyrahFH
Aug 19 2016 07:28
var myStr = "Laggy \n \mornings \ \r Aloha"; // Change this line
sorry this is my code
Mark Todd
@Knochenmark
Aug 19 2016 07:29
you need to escape
CyrahFH
@CyrahFH
Aug 19 2016 07:29
the error is still there
Mark Todd
@Knochenmark
Aug 19 2016 07:30
@CyrahFH format your code, so we can see it
CyrahFH
@CyrahFH
Aug 19 2016 07:46
issue resolved.. i changed the line..
Alexander Kyle Workman
@akw2796
Aug 19 2016 07:55
I'm currently working on the "Return Early Pattern for Functions" lesson and I cannot for the life of me figure out how to get this thing to return undefined when the variable is less than zero, because the variable has a value of less that zero, which means it's defined. I am so stuck here and I've been working on it for like an entire hour, if not more, trying to figure it out. Sorry if I'm not being clear but I can't figure this out...
Alexios Pantavos
@AlexiosP
Aug 19 2016 07:56
@akw2796 I haven't checked the challenge yet, but, have you tried return undefined;?
Darth Skywalker
@adityaparab
Aug 19 2016 07:57
@AlexiosP : You don't need to explicitly say return undefined; If you just say only return; it does the same thing :)
Alexios Pantavos
@AlexiosP
Aug 19 2016 07:58
@adityaparab Good to know, thanks :)
CamperBot
@camperbot
Aug 19 2016 07:58
alexiosp sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 599 | @adityaparab |http://www.freecodecamp.com/adityaparab
Alexander Kyle Workman
@akw2796
Aug 19 2016 08:00
@AlexiosP @adityaparab i can try that. i was doing completely unncessarily complicated things lmao. tried doing the square root of a negative but that just gave null, not undefined. looked up the definition of undefined and still could not for the life of me figure out how to make it return undefined
Darth Skywalker
@adityaparab
Aug 19 2016 08:01
@akw2796 Can you post your code here?
Feliciano
@gman-man
Aug 19 2016 08:05
Good morning!!!
How can i export my code to the chat?
Alexander Kyle Workman
@akw2796
Aug 19 2016 08:05
I actually just tried what you said and it worked; i've moved on to the next lesson now. i used an if statement so that if one of the variables was less than zero, it would return undefined. i was trying to make it way more complicated than it had to be. i tend to overthink everything. but basically the function i was working with had paramaters a and b, and i needed to make it return undefined if either were negative. so i used an if statement and specified if either of the paramaters were below zero it would return undefined.
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 08:06
@gman-man use ```
Anthony Drane
@Antiaccess
Aug 19 2016 08:06
Hey can anyone tell me if there are SYNTAX errors in my code here, not LOGIC errors (I want to figure that out on my own). The following code is for project: Profile Lookup & is trying look up attributes about people in a contact list:
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i=0; i < contacts.length; i++){
    if (firstName === contacts[i].firstName){
      for (j=0; j < contacts[i].firstName.length; j++)
        if (contacts[i].firstName[prop]){
          if (contacts[i].firstName[prop] == "likes") {
            var likes = "";
            for (k=0; k < contacts[i].firstName[prop].length; k++){
              likes += contacts[i].firstName[prop[k]] + " ";
            }
            console.log(likes);
          } else {
            console.log(contacts.firstName[prop[k]]);
          }
        } else if (j == contacts[i].firstName.length) {
          console.log("No such property");
        }
    } else if (i == (contacts.length - 1)){
      console.log("no such contact");
    }
  }
// Only change code above this line
}
Feliciano
@gman-man
Aug 19 2016 08:06
Thank you!
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
  var result;
  var check = myObj.hasOwnProperty(checkProp);

  if (check) { 
    result = myObj.checkProp;
  } else if (!check) {
    result = "Not found";
  }

  return result;
}

// Test your code by modifying these values
checkObj("gift");
Got stuck!
Can someone please help me!
ArtemOnischenko
@ArtemOnischenko
Aug 19 2016 08:08
@gman-man
myObj[checkProp];
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:08
@Antiaccess I think there are not any syntax errors. Didn't check for logic ones though :P
Feliciano
@gman-man
Aug 19 2016 08:09
Thank you @ArtemOnischenko
CamperBot
@camperbot
Aug 19 2016 08:09
gman-man sends brownie points to @artemonischenko :sparkles: :thumbsup: :sparkles:
:cookie: 63 | @artemonischenko |http://www.freecodecamp.com/artemonischenko
KhanhNB @KhanhNB
Anthony Drane
@Antiaccess
Aug 19 2016 08:10
@AlexiosP thanks!
CamperBot
@camperbot
Aug 19 2016 08:10
antiaccess sends brownie points to @alexiosp :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @alexiosp |http://www.freecodecamp.com/alexiosp
John Alcher
@alchermd
Aug 19 2016 08:11
Hey fellas. in Jquery, how do I highlight an element's border for a specific amount of time? Like, when a button is clicked, another element's border gets changed to white for half a second then returns to its original color.
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:12
@Antiaccess Oh, just a note. I assume that the variables you use are all declared already. E.g. i, j, k, contacts
Anthony Drane
@Antiaccess
Aug 19 2016 08:13
they arent!!
thanks
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:13
cheers ^^
@alchermd You may want to use delay method: https://api.jquery.com/delay/
or setTimeout method of JS: https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout
I'm not sure if there are any better ways to do this though.
Amandeep Saxena
@AmandeepSaxena
Aug 19 2016 08:18
var myStr="FirstLine\n SecondLine\r ThirdLine"; // Change this line
how to complete this challenge?
Assign the following three lines of text into the single variable myStr using escape sequences.
FirstLine
\SecondLine\
ThirdLine
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:22

@AmandeepSaxena Check the instructions on the left, special characters like \,line breaks, etc have to be "escaped" using the character \. So if you want to print on the console

hello\!

you would write

console.log("hello\\!");
Picshulo
@Picshulo
Aug 19 2016 08:26

@AmandeepSaxena
\n - newline
\\ - backslash
\r - carriage-return

Now you have to do

FirstLine newline backslash SecondLine backslash carriage-return ThirdLine .. without spaces

Paul Ballardin
@outsmart
Aug 19 2016 08:30
hey everyone, I am really stuck on Smallest Common Multiple
Anthony Drane
@Antiaccess
Aug 19 2016 08:31
okay @AlexiosP & anyone else, now I need some help on where my logic/coding is failing. The following is for the 'Profile Lookup' challenge (accessing information from a contact list & details (as objects):
Paul Ballardin
@outsmart
Aug 19 2016 08:31
was hoping that someone would look at my code...
Anthony Drane
@Antiaccess
Aug 19 2016 08:31
okay @AlexiosP & anyone else, now I need some help on where my logic/coding is failing. The following is for the 'Profile Lookup' challenge (accessing information from a contact list & details (as objects):
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++){
    if (firstName == contacts[i].firstName){
      for (var j=0; j < contacts[i].length; j++)
        if (contacts[i][prop]){
          if (contacts[i][prop] == "likes") {
            var likes = "";
            for (var k=0; k < contacts[i][prop].length; k++){
              likes += contacts[i][prop[k]] + " ";
            }
            return likes;
          } else {
            return contacts[prop];
          }
        } else if (j == contacts[i].length) {
          return "No such property";
        }
    } else if (i == (contacts.length - 1)){
      return "no such contact";
    }
  }
// Only change code above this line
}
Khanh Nguyen
@KhanhNB
Aug 19 2016 08:31
var test = {"obj": NaN};
test["obj"].toString() === 'NaN';
\\ I have to convert test.obj to String to check if it's NaN or not
\\ Is there any other way?
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:32
@outsmart Sure, just post it here -formatted if possible, and we'll take a look
Paul Ballardin
@outsmart
Aug 19 2016 08:33
@Antiaccess where is contacts defined?
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:33
@KhanhNB There is a method isNaN(youVariablehere) which returns if your variable is NaN or not
Anthony Drane
@Antiaccess
Aug 19 2016 08:33
@outsmart earlier on, it's an array list of objects
Paul Ballardin
@outsmart
Aug 19 2016 08:33
thanks @AlexiosP I'll just see if I can assist @Antiaccess first
CamperBot
@camperbot
Aug 19 2016 08:33
outsmart sends brownie points to @alexiosp and @antiaccess :sparkles: :thumbsup: :sparkles:
:cookie: 218 | @antiaccess |http://www.freecodecamp.com/antiaccess
:cookie: 373 | @alexiosp |http://www.freecodecamp.com/alexiosp
Paul Ballardin
@outsmart
Aug 19 2016 08:34
@Antiaccess can you paste the full code
Anthony Drane
@Antiaccess
Aug 19 2016 08:34
Sure,

//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++){
    if (firstName == contacts[i].firstName){
      for (var j=0; j < contacts[i].length; j++)
        if (contacts[i][prop]){
          if (contacts[i][prop] == "likes") {
            var likes = "";
            for (var k=0; k < contacts[i][prop].length; k++){
              likes += contacts[i][prop[k]] + " ";
            }
            return likes;
          } else {
            return contacts[prop];
          }
        } else if (j == contacts[i].length) {
          return "No such property";
        }
    } else if (i == (contacts.length - 1)){
      return "no such contact";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "lastName");
lookUpProfile("Harry", "number");
lookUpProfile("Akira", "likes");
the only output I'm getting is "no such contact"
(showing it's just getting to the end of the loop)
Paul Ballardin
@outsmart
Aug 19 2016 08:35
@Antiaccess shouldn't == be === when you are comparing 2 strings?
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:36
@outsmart No need I believe.
Khanh Nguyen
@KhanhNB
Aug 19 2016 08:36
@AlexiosP how to check exactly It's NaN value or not? I want a somefunction(NaN) = true and somefunction("abcdef") = false;
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:37
Anthony Drane
@Antiaccess
Aug 19 2016 08:38
I think i may be on to figuring it out
I didn't use 'j' as my counter, instead used prop
let me see if I can fix it
John Alcher
@alchermd
Aug 19 2016 08:39
@AlexiosP setTimeout got the job done. Thankyou!
CamperBot
@camperbot
Aug 19 2016 08:39
alchermd sends brownie points to @alexiosp :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @alexiosp |http://www.freecodecamp.com/alexiosp
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:39
@alchermd Glad I could help :)
I'm also learning things while helping out ^^
Anthony Drane
@Antiaccess
Aug 19 2016 08:40
okay, didn't work :(
Paul Ballardin
@outsmart
Aug 19 2016 08:42
@Antiaccess so, in your second loop, is contacts[i] and object or an array?
I think that may help you...
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:42
@Antiaccess Just to make sure is if (contacts[i][prop]) === if (contacts[i].hasOwnProperty(prop))?
Anthony Drane
@Antiaccess
Aug 19 2016 08:43
Let's see @outsmart @AlexiosP be back soon
Khanh Nguyen
@KhanhNB
Aug 19 2016 08:43

@AlexiosP I know isNaN function but that's not my point

[{
    "user": NaN,
    "sex": "male",
    "age": 0
}, {
    "user": "Dipsy",
    "sex": "male",
    "age": 3
}, {
    "user": 123,
    "sex": "female",
    "age": 5
}]

How can you detect first object with "user" = NaN

Paul Ballardin
@outsmart
Aug 19 2016 08:44
This message was deleted
@Antiaccess what I find helpful, is the console.log each step of the function to ensure that it is doing what I expect, so in your case, after we have checked first name against the first name property, I ran this: console.log(contacts[i].length);
Ricardo Araújo
@ricardomga
Aug 19 2016 08:46
[0].user === type of NaN
@KhanhNB some like that i think
@KhanhNB its just pseudo code
Paul Ballardin
@outsmart
Aug 19 2016 08:47
ok, @AlexiosP can we give this a shot now?
Anthony Drane
@Antiaccess
Aug 19 2016 08:47
@outsmart I'll add some of those in to check
Paul Ballardin
@outsmart
Aug 19 2016 08:47
@Antiaccess just do one air a time at each step, test it then move to the next step...
luis4flames
@luis4flames
Aug 19 2016 08:47

function titleCase(str) {

  var lowerCase = str.toLowerCase();
  var newArray = lowerCase.split();
  var i;

  while (i <= str.length){
    var cap = newArray[i][0].toUpperCase();
    newArray[i][0] = cap;
    i++;

  }

  return newArray;



  //return final;
}

titleCase("i'm a lITtle Tea pot");
what am i doing wrong? im trying to capitalize the first letter of each word
Dylan Satelle
@DylanSatelle
Aug 19 2016 08:48

Morning... Whats the benefits to using a constructor over just normal objects.. ? e.g :
```js

var Car = function() {

Alexios Pantavos
@AlexiosP
Aug 19 2016 08:48
@KhanhNB Okay, this should do the trick: If you have var a = NaN; you can check if var a is NaN with a !== a: http://stackoverflow.com/questions/2652319/how-do-you-check-that-a-number-is-nan-in-javascript/16988441#16988441
Dylan Satelle
@DylanSatelle
Aug 19 2016 08:48
Will retype, 1 min
Anthony Drane
@Antiaccess
Aug 19 2016 08:48
@outsmart I think freecodecamp doesn't output the console.log's is there another online service I can use?
Ken Aguilar
@piq9117
Aug 19 2016 08:48
@luis4flames
str.split() // no effect
str.split('')// will split every character
str.split(' ') // will split with each space
Paul Ballardin
@outsmart
Aug 19 2016 08:49
@Antiaccess you are flying blind off you don't use the console...
Anthony Drane
@Antiaccess
Aug 19 2016 08:49
@outsmart what do you mean (sorry, im new)
Paul Ballardin
@outsmart
Aug 19 2016 08:49
@Antiaccess use your browser inspector and use the console view
Ken Aguilar
@piq9117
Aug 19 2016 08:49
@Antiaccess you have to open the dev tool
Khanh Nguyen
@KhanhNB
Aug 19 2016 08:49
@AlexiosP : haha nice trick. Thank you!
CamperBot
@camperbot
Aug 19 2016 08:49
khanhnb sends brownie points to @alexiosp :sparkles: :thumbsup: :sparkles:
:cookie: 375 | @alexiosp |http://www.freecodecamp.com/alexiosp
luis4flames
@luis4flames
Aug 19 2016 08:50
how would i reassign a new value to the array in the loop
Dylan Satelle
@DylanSatelle
Aug 19 2016 08:50

Whats the benefits to using contrcutors over normal objects?


var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var MotorBike = function() {


};

over



var car = {
  "wheels":4,
  "engines":1,
  "seats":5
};
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:50
@outsmart Sure, whenever you want ^^
@Antiaccess Personally I use https://repl.it/languages/javascript to see the output of the console.log
@KhanhNB Cheers :)
Paul Ballardin
@outsmart
Aug 19 2016 08:50
@Antiaccess see this in the FreeCodeCamp console window:
llamatarianism
@llamatarianism
Aug 19 2016 08:50
@DylanSatelle constructors have this property called a prototype
which lets objects inherit from other objects
Paul Ballardin
@outsmart
Aug 19 2016 08:51
@Antiaccess Any Console.log() - type statements will appear in your browser dev tools
llamatarianism
@llamatarianism
Aug 19 2016 08:51
as an example, I could do:
Anthony Drane
@Antiaccess
Aug 19 2016 08:51
@outsmart is that supposed to be the box under 'run tests' because that's where I've been looking?
llamatarianism
@llamatarianism
Aug 19 2016 08:52
function Tractor() {
  this.isATractor = true; // idk what else tractors do
}

Tractor.prototype = new Car();
and then all Tractors would also be Cars
Paul Ballardin
@outsmart
Aug 19 2016 08:52
//
how do I paste code here
Picshulo
@Picshulo
Aug 19 2016 08:53
help format
CamperBot
@camperbot
Aug 19 2016 08:53

:point_right: code formatting [wiki]

Multi line Code

```js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css)

<paste your code here>,
then press [shift + enter ⏎]

``` ⇦ Type 3 backticks, then press [enter ⏎]

Single line Code

This an inline `<paste code here>` code formatting with a single backtick() at _start_ and _end_ around thecode`.

See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics

:pencil: read more about code formatting on the FCC Wiki

Dylan Satelle
@DylanSatelle
Aug 19 2016 08:53
ah right, ok @llamatarianism .. Literally as I type it I moved on 3 challenges and its started to explain it my bad for jumping the gun. Thanks though @llamatarianism
CamperBot
@camperbot
Aug 19 2016 08:53
dylansatelle sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1229 | @llamatarianism |http://www.freecodecamp.com/llamatarianism

\\

function smallestCommons(arr) {

//1. Work out the maximum and min arguments of the array
var max = Math.max(arr[0],arr[1] );
var min = Math.min(arr[0],arr[1] );
var minMax = [min,max];
var myarr = [];

for(i=min; i<=max; i++){
myarr.push(i);
}

//2. Work out the greatest value the multiple can be = sum of the max and min and each value in between
var product = myarr.reduce(
function(total, num){ return total * num; } );

//3. For each of the vales we are testing, build the array of multiples up to the greatest value
var multiples = [];
//iterate over each value in the myarr array
for (i=0;i<minMax.length;i++) {
var tmp= [];

for (j=1; j<product/minMax[i]; j++){
    tmp.push(j*minMax[i]);      
}
multiples.push(tmp);

}

var commonValues = function(a,b){
var vals=[];
for (var i in a) {
if (b.indexOf(a[i]) > 0){
vals.push(a[i]);
}
}
return vals;
};

var common = multiples.reduce(function(a, b) {
return commonValues(a,b);
});

// Now for each value in the multiples array, see if its divisble by all the inbetween numbers;
for (i=0; i< common.length; i++) {
var divisibleByAll = true;
for (j=0; j<myarr.length-1; j++ ){
if(common[i] % myarr[j] != 0 ) {
//console.log(common[i] + ' % ' + myarr[j] + ' false');
divisibleByAll = false;
}
}
if(divisibleByAll == true){
return common[i];
break;
}
}

}

smallestCommons([1, 13]);

///

Khanh Nguyen
@KhanhNB
Aug 19 2016 08:54
what is the benefit of brownie points :smile:
Abis Mal
@abisthecodermal
Aug 19 2016 08:55
to show off @KhanhNB :laughing:
Picshulo
@Picshulo
Aug 19 2016 08:55

@outsmart
Multi line Code
``` ⇦ Type 3 backticks and then press [shift + enter ⏎]

<paste your code here>,
then press [shift + enter ⏎]
``` ⇦ Type 3 backticks, then press [enter ⏎]

Paul Ballardin
@outsmart
Aug 19 2016 08:55
How do I do a backtick
Abis Mal
@abisthecodermal
Aug 19 2016 08:55
beside 1, above tab
@outsmart
Picshulo
@Picshulo
Aug 19 2016 08:56
i have it above my tab
Abis Mal
@abisthecodermal
Aug 19 2016 08:56
below ~
Anthony Drane
@Antiaccess
Aug 19 2016 08:56
@outsmart awesome! thanks, got the console
CamperBot
@camperbot
Aug 19 2016 08:56
antiaccess sends brownie points to @outsmart :sparkles: :thumbsup: :sparkles:
:cookie: 347 | @outsmart |http://www.freecodecamp.com/outsmart
Alexios Pantavos
@AlexiosP
Aug 19 2016 08:56
It depends on your keyboard :P Worse case scenario, just copy paste it x.x
Khanh Nguyen
@KhanhNB
Aug 19 2016 08:57
@abisthecodermal 😂
abelrafaa
@abelrafaa
Aug 19 2016 08:57

function palindrome(str) {
// Good luck!
var s =str.toLowerCase();
var d= str.split("");
d.reverse();
d.join('');
if(s===d)
return true;
else
return false;
}

palindrome("eyes");

somebody.
Abis Mal
@abisthecodermal
Aug 19 2016 08:58
lemme repl.it it
Paul Ballardin
@outsmart
Aug 19 2016 08:59
This message was deleted
Abis Mal
@abisthecodermal
Aug 19 2016 08:59
ok... @abelrafaa
var s =str.toLowerCase();
var d= str.split("");
see the problem? @abelrafaa
Paul Ballardin
@outsmart
Aug 19 2016 09:00
ok @AlexiosP Dont laugh: `
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:01
@outsmart I won't, I already like the logic and the methods you use. Haven't read the whole code yet
Abis Mal
@abisthecodermal
Aug 19 2016 09:01
for palindrome("eYe") your function does not work
@abelrafaa
Paul Ballardin
@outsmart
Aug 19 2016 09:02
@AlexiosP I just can't paste it here grrrr...
function smallestCommons(arr) {

  //1. Work out the maximum and min arguments of the array
  var max = Math.max(arr[0],arr[1] );
  var min = Math.min(arr[0],arr[1] );
  var minMax = [min,max];
  var myarr = [];


  for(i=min; i<=max; i++){
    myarr.push(i);
  }


  //2. Work out the greatest value the multiple can be = sum of the max and min and each value in between
  var product = myarr.reduce(
  function(total, num){ return total * num; } );

  //3. For each of the vales we are testing, build the array of multiples up to the greatest value
  var multiples = [];
  //iterate over each value in the myarr array
  for (i=0;i<minMax.length;i++) {
    var tmp= [];

    for (j=1; j<product/minMax[i]; j++){
        tmp.push(j*minMax[i]);      
    }
    multiples.push(tmp);
  }


 var commonValues = function(a,b){
  var vals=[];
  for (var i in a) {
    if (b.indexOf(a[i]) > 0){
      vals.push(a[i]);
    }
  }
 return vals;
};

var common = multiples.reduce(function(a, b) {
  return commonValues(a,b);
});

  // Now for each value in the multiples array, see if its divisble by all the inbetween numbers; 
  for (i=0; i< common.length; i++) {
    var divisibleByAll = true;
    for (j=0; j<myarr.length-1; j++  ){
      if(common[i] % myarr[j] !== 0 ) {
        //console.log(common[i] + ' % ' + myarr[j] + ' false');
        divisibleByAll = false;
      }
    }
    if(divisibleByAll === true){
      return common[i];
    }
  }

}
Abis Mal
@abisthecodermal
Aug 19 2016 09:02
nice work!! @outsmart
abelrafaa
@abelrafaa
Aug 19 2016 09:02
var s =str.toLowerCase();
var d= s.split("");
d.reverse();
d.join('');
return d;
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:02
@outsmart I was already looking the non-formatted code, but that'll help :D
Paul Ballardin
@outsmart
Aug 19 2016 09:03
@AlexiosP I am close, just the last step has be screwed...
Abis Mal
@abisthecodermal
Aug 19 2016 09:03
@abelrafaa now its better.
you can club the functions as well
var d= s.split('').reverse().join('');
fixed?
@outsmart. May I suggest something?
Paul Ballardin
@outsmart
Aug 19 2016 09:05
of course @abelrafaa
Abis Mal
@abisthecodermal
Aug 19 2016 09:05
lcm(a,b)=(a*b)/gcd(a,b)
it'll make your life easier
Paul Ballardin
@outsmart
Aug 19 2016 09:06
ah... theres an algorithm...
Abis Mal
@abisthecodermal
Aug 19 2016 09:06
mathematical formula?
and check euclid's theorem for GCD
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:07

@outsmart Hmm, shouldn't the for here

for (j=0; j<myarr.length-1; j++  ){
      if(common[i] % myarr[j] !== 0 ) {
        //console.log(common[i] + ' % ' + myarr[j] + ' false');
        divisibleByAll = false;
      }
    }

be

for (j=0; j<myarr.length; j++  ){

?

Paul Ballardin
@outsmart
Aug 19 2016 09:07
does that work for all the sequential values between the pair?
Abis Mal
@abisthecodermal
Aug 19 2016 09:07
I created two functions. One for sorting and filling the array. Another for calculating GCD
Tobias Gerhardsson
@tobiasger
Aug 19 2016 09:07
Does anyone know any good horizontal accordion that works in full screen?
Abis Mal
@abisthecodermal
Aug 19 2016 09:07
the formula I wrote was for two numbers
any two
Paul Ballardin
@outsmart
Aug 19 2016 09:08
@AlexiosP that gets us one step closer to the solution....
abelrafaa
@abelrafaa
Aug 19 2016 09:08
2016-08-19 (1).png
Khanh Nguyen
@KhanhNB
Aug 19 2016 09:08
also, lcm(a,b,c) = lcm(lcm(a,b),c) :D
Abis Mal
@abisthecodermal
Aug 19 2016 09:09
lcm(6,9)=(6*9)/gcd(6,9)
= 54/3
=18
@outsmart
@abelrafaa You have to remove the special characters as well Like _
abelrafaa
@abelrafaa
Aug 19 2016 09:09
I didn't put replace.
but how?
Paul Ballardin
@outsmart
Aug 19 2016 09:10
This message was deleted
Abis Mal
@abisthecodermal
Aug 19 2016 09:11
split the original string at '_' and other characters
Paul Ballardin
@outsmart
Aug 19 2016 09:11
@abisthecodermal but the challenge also calls for the number to be divisible by the sequence of number between the 6 and 9, so 7 and 8 also,,
so 54 doesn't work
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:11
@outsmart Just by looking at it, I can't seem to find any other error. Give me a moment to test it out :D
Paul Ballardin
@outsmart
Aug 19 2016 09:12
@AlexiosP is passes the test for all values except the last -- it may just be hitting a timeout limit...
Abis Mal
@abisthecodermal
Aug 19 2016 09:12
right. so consider this
lcm(5,10)=lcm(5,6,7,8,9,10)=lcm(lcm(5,6),7) and so on @outsmart
am I making sense?
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:13
@outsmart Oh, yea. It crashes my tab in the browser :P
The algorithm is fine ^^
Abis Mal
@abisthecodermal
Aug 19 2016 09:14
@abelrafaa
Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
Anthony Drane
@Antiaccess
Aug 19 2016 09:14
@AlexiosP @outsmart Hey guys, I'm making progress, my code has simplified a bunch due to being able to test it with the console. There's somethin wrong with my code and outputting the property of the item in the object, yet it works if the item in the object is an array
function lookUpProfile(firstName, prop){ // Only change code below this line for (var i=0; i < contacts.length; i++){ if (firstName == contacts[i].firstName){ console.log("found contact"); if (contacts[i].hasOwnProperty(prop)){ console.log("found prop"); return contacts[i][prop]; } else { return "No such property"; } } else if (i == (contacts.length - 1)){ return "no such contact"; } } // Only change code above this line }
Paul Ballardin
@outsmart
Aug 19 2016 09:15
@AlexiosP so it works, but perhaps I got there the long way and break FCC so can't close out the challenge...
Abis Mal
@abisthecodermal
Aug 19 2016 09:15
@outsmart
tip: Run your code in repl.it
Copy the entire code (including function call) into repl.it
Markus Kiili
@Masd925
Aug 19 2016 09:15
@outsmart It would be much more efficient if you just generated multiples with an infinite while loop and checked if the multiple was divisible by the numbers in the range. Without making an array of multiples.
Abis Mal
@abisthecodermal
Aug 19 2016 09:15
helps you find the error
hey @Masd925 wassup?
Paul Ballardin
@outsmart
Aug 19 2016 09:16
@Masd925 well I figured the max value would be the product of the entire sequence of values...
Markus Kiili
@Masd925
Aug 19 2016 09:16
@abisthecodermal Hi.
Abis Mal
@abisthecodermal
Aug 19 2016 09:17
@outsmart mostly yes. I cannot think of a string of numbers whose LCM is something else than their products
Anthony Drane
@Antiaccess
Aug 19 2016 09:17
formatting may help
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++){
    if (firstName == contacts[i].firstName){
      console.log("found contact");
      if (contacts[i].hasOwnProperty(prop)){
          console.log("found prop");
        return contacts[i][prop];
      } else {
        return "No such property";
      }
    } else if (i == (contacts.length - 1)){
        return "no such contact";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "lastName");
lookUpProfile("Harry", "number");
lookUpProfile("Akira", "likes");
sorry for the wall
Markus Kiili
@Masd925
Aug 19 2016 09:18
This message was deleted
abelrafaa
@abelrafaa
Aug 19 2016 09:18
@abisthecodermal
And how i remowe them?
Anthony Drane
@Antiaccess
Aug 19 2016 09:19
it works for the arrays ("likes") but not for standard properties e.g. lastName
Abis Mal
@abisthecodermal
Aug 19 2016 09:19
read up on regex @abelrafaa
abelrafaa
@abelrafaa
Aug 19 2016 09:19
remove
Anthony Drane
@Antiaccess
Aug 19 2016 09:19
so lookUpProfile("Akira", "likes"); works, but the other two tests dont
Markus Kiili
@Masd925
Aug 19 2016 09:20
@Antiaccess Is it no such contact or No such contact
Abis Mal
@abisthecodermal
Aug 19 2016 09:20

I absolutely despise them though.... @abelrafaa

read up on regex

Anthony Drane
@Antiaccess
Aug 19 2016 09:20
Upper case @Masd925 , I'll change that
Gaurav Tolani
@Gauravtolani
Aug 19 2016 09:22
how do i get the users location in local weather?
Anthony Drane
@Antiaccess
Aug 19 2016 09:23
@Masd925 that passed the test, but I'm getting this output when running in repl.it:

found contact
found prop
found contact
found prop
found contact
found prop
=> [ 'Pizza', 'Coding', 'Brownie Points' ]
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:23
@outsmart I had to take a phonecall. Did you resolve the issue?
zpmh
@zpmh
Aug 19 2016 09:23
< var Car = function() {
  // this is a private variable
  var speed = 10;

  // these are public methods
  this.accelerate = function(change) {
    speed += change;
  };

  this.decelerate = function() {
    speed -= 5;
  };

  this.getSpeed = function() {
    return speed;
  };
};

var Bike = function() {

  // Only change code below this line.

  var gear = 0;

  this.setGear = function(input){
    gear += input;
  };

  this.getGear = function(){
    return gear;
  };
};

var myCar = new Car();

var myBike = new Bike(); >
Hey! Can anyone explain why this.getGear doesn't return the correct number of gear after setGear(1) or setGear(3) is called? (should return 1 or 3 respectively)
Anthony Drane
@Antiaccess
Aug 19 2016 09:24
@Masd925 that suggests to me its only working for the array items, but more basic properties aren't
Manish Giri
@Manish-Giri
Aug 19 2016 09:24
@Gauravtolani you can use an API like ipinfo
Markus Kiili
@Masd925
Aug 19 2016 09:24
@Antiaccess I think it is working.
Ricardo Araújo
@ricardomga
Aug 19 2016 09:25
@Antiaccess do you wanna see my way?
Anthony Drane
@Antiaccess
Aug 19 2016 09:25
@Masd925 but it won't return the properties for firstName, lastName, number
@ricardomga sure, i'd like that
Markus Kiili
@Masd925
Aug 19 2016 09:25
@Antiaccess You are not console.logging them or the function call return values.
Anthony Drane
@Antiaccess
Aug 19 2016 09:26
@Masd925 The return works for the last one in the list (the array) but I'll try console.logging them before return
Ricardo Araújo
@ricardomga
Aug 19 2016 09:27
@Antiaccess
function lookUpProfile(firstName, prop){
// Only change code below this line
  var answer = "No such contact";
  for(var i = 0; i < contacts.length; i++){
    if(contacts[i].firstName === firstName){
      if(contacts[i].hasOwnProperty(prop)){
        answer = contacts[i][prop];
        break;
      }
      answer = "No such property";
    }
  }
  return answer;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@Antiaccess I am givin it a default value of "No such property"
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:28
@Antiaccess Your code is fine. Just change the return statement: return "no such contact"; to return "No such contact";
Anthony Drane
@Antiaccess
Aug 19 2016 09:28
@Masd925 okay you're right, it is working - but it's weird they aren't returning each time
@ricardomga that looks so much more streamlined!
Markus Kiili
@Masd925
Aug 19 2016 09:28
@Antiaccess Each function call makes a return value.
Paul Ballardin
@outsmart
Aug 19 2016 09:29
@AlexiosP no I created repel.it also - the code works but too clunky so I am going to see if I can optimise...
Anthony Drane
@Antiaccess
Aug 19 2016 09:29
@Masd925 okay, just discovered that repl.it will only show the last return item
thanks @Masd925 @AlexiosP @outsmart
CamperBot
@camperbot
Aug 19 2016 09:30
antiaccess sends brownie points to @masd925 and @alexiosp and @outsmart :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @alexiosp |http://www.freecodecamp.com/alexiosp
:warning: antiaccess already gave outsmart points
:star2: 2323 | @masd925 |http://www.freecodecamp.com/masd925
Anthony Drane
@Antiaccess
Aug 19 2016 09:31
oh and thanks @ricardomga
CamperBot
@camperbot
Aug 19 2016 09:31
antiaccess sends brownie points to @ricardomga :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @ricardomga |http://www.freecodecamp.com/ricardomga
Gaurav Tolani
@Gauravtolani
Aug 19 2016 09:31
thanks @Manish-Giri
CamperBot
@camperbot
Aug 19 2016 09:31
gauravtolani sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 1642 | @manish-giri |http://www.freecodecamp.com/manish-giri
Ricardo Araújo
@ricardomga
Aug 19 2016 09:31
@Antiaccess it simplifies a bit because that way i dont need the extra else if that you have in the bottom, if you undurstand my way feel free to modify and improve your code. I am always doing that
Anthony Drane
@Antiaccess
Aug 19 2016 09:31
@ricardomga I do understand it, just new to this and therefore inefficient
@ricardomga I'll do some modding for practice
Ricardo Araújo
@ricardomga
Aug 19 2016 09:32
@Antiaccess you welcome
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:32

@zpmh

  this.setGear = function(input){
    gear += input;
  };

You should assign the input to the gear variable, e.g. gear = input;, not increase it

Markus Kiili
@Masd925
Aug 19 2016 09:33
@Antiaccess To my eye, it is even simpler without the result variable (but that depends on who reads):
Manish Giri
@Manish-Giri
Aug 19 2016 09:33
@Gauravtolani welcome!
Markus Kiili
@Masd925
Aug 19 2016 09:33
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i=0; i<contacts.length; i++) {
    var contact = contacts[i];
    if (contact.firstName===firstName) {
      if (contact.hasOwnProperty(prop)) {
        return contact[prop];
      }
      return "No such property";
    }
  }
  return "No such contact";
// Only change code above this line
}
Ricardo Araújo
@ricardomga
Aug 19 2016 09:33
@Masd925 even better, cheers
@Masd925 @Antiaccess i will improve mine to that way
Ken Aguilar
@piq9117
Aug 19 2016 09:35
I did mine like this
Array.prototype.flatMap = function (fn) {
  return Array.prototype.concat.apply([], this.map(fn))
}

function looUpProfile (firstName, prop) {
  let returnVal
  const matchFirstName = n => n.firstName === firstName

  contacts.map(c => {
    if (c.firstName !== firstName) returnVal = 'No such contact'
  })

  contacts.filter(matchFirstName)
    .map(c => c[prop])
    .flatMap(p => returnVal = p)

  if (returnVal === undefined) returnVal = 'No such property'
  return returnVal
}
Anthony Drane
@Antiaccess
Aug 19 2016 09:37

okay thanks everyone!

How long does it take to really become proficient?

when, say, coding near-daily
Ricardo Araújo
@ricardomga
Aug 19 2016 09:38
@piq9117 its an intresting aproach
llamatarianism
@llamatarianism
Aug 19 2016 09:38
function lookUpProfile(firstName, prop) {
  const matchedObj = contacts.filter(obj => obj.firstName === firstName)[0];
  if (matchedObj) {
    return matchedObj[prop] || "No such property";
  } else {
    return "No such contact";
  }
}
kinda inefficient since it's filtering the entire array
Donatas
@Lieutenant4
Aug 19 2016 09:38

function testLogicalOr(val) {
  // Only change code below this line

  if (val > 20 || val < 10); {
    return "Outside";

  }

  // Only change code above this line
  return "Inside";
}

// Change this value to test
testLogicalOr(15);
wheres the mistake? in doesnt return "Inside"
llamatarianism
@llamatarianism
Aug 19 2016 09:39
but I'm just gonna blame JS not being lazy for that one
@Lieutenant4 you have a semicolon after your condition
so your code is actually this:
Ken Aguilar
@piq9117
Aug 19 2016 09:39
@ricardomga lol.. its pretty easy to test
llamatarianism
@llamatarianism
Aug 19 2016 09:39
function testLogicalOr(val) {
  // Only change code below this line

  if (val > 20 || val < 10); // do nothing.

  {
    return "Outside";
  }

  // Only change code above this line
  return "Inside";
}
so it always returns "Outside"
Darth Skywalker
@adityaparab
Aug 19 2016 09:40

@Lieutenant4 : Your condition is also wrong.

Shouldn't it be

if (val > 10 || val < 20)
anyway.. scratch that. I misread it
Donatas
@Lieutenant4
Aug 19 2016 09:41
@adityaparab got it, thanks
CamperBot
@camperbot
Aug 19 2016 09:41
lieutenant4 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 600 | @adityaparab |http://www.freecodecamp.com/adityaparab
Ricardo Araújo
@ricardomga
Aug 19 2016 09:42
@piq9117 i belive you, its just to advanced for me
llamatarianism
@llamatarianism
Aug 19 2016 09:42
@Lieutenant4 your condition's not wrong
Ricardo Araújo
@ricardomga
Aug 19 2016 09:42
@piq9117 is that es6?
llamatarianism
@llamatarianism
Aug 19 2016 09:42
val > 10 || val < 20 is true for literally any number
@piq9117 you should use forEach instead of map if you don't care about the result
map creates a new array, whereas forEach doesn't
Ken Aguilar
@piq9117
Aug 19 2016 09:43
@ricardomga yess. yeah it took me sometime to code like that.. Simpler solution is actually difficult to understand at first.. i almost cried.. lol
@llamatarianism yeah.. thats what I want.. to create a new array.. I try to lessen mutation as much as possible
abelrafaa
@abelrafaa
Aug 19 2016 09:44

function palindrome(str) {
// Good luck!
var s,d;
s=str.replace(/"_"/g, '');
s =str.toLowerCase();
d= s.split('').reverse().join('');

if(s==d)
   return d;
else
   return d;}

palindrome("_eYe");

llamatarianism
@llamatarianism
Aug 19 2016 09:44
@piq9117 no you don't
  contacts.map(c => {
    if (c.firstName !== firstName) returnVal = 'No such contact'
  })

  contacts.filter(matchFirstName)
    .map(c => c[prop])
    .flatMap(p => returnVal = p)
^ you're not doing anything with the result
all you're doing is mutating returnVal
abelrafaa
@abelrafaa
Aug 19 2016 09:45
i dont know how to delete "_"/
llamatarianism
@llamatarianism
Aug 19 2016 09:45
@abelrafaa str.replace(/"_"/g, '');
Daniel1997Eze
@Daniel1997Eze
Aug 19 2016 09:45
can anyone using freecodecamp.com share their 144 solution please
llamatarianism
@llamatarianism
Aug 19 2016 09:45
that regex only matches "_"
it doesn't match _
so it'll replace this:
Daniel1997Eze
@Daniel1997Eze
Aug 19 2016 09:45
can't seem to get it
llamatarianism
@llamatarianism
Aug 19 2016 09:45
'foo bar "_" baz'
but not this:
Ken Aguilar
@piq9117
Aug 19 2016 09:45
@llamatarianism in that case thats true.. but I dont use forEach
llamatarianism
@llamatarianism
Aug 19 2016 09:45
'foo bar _ baz'
@piq9117 except you're using map as if it's forEach
so really, yeah, you are using forEach.
abelrafaa
@abelrafaa
Aug 19 2016 09:46
is not working.
llamatarianism
@llamatarianism
Aug 19 2016 09:46
except a slower version
abelrafaa
@abelrafaa
Aug 19 2016 09:46
@llamatarianism
Ricardo Araújo
@ricardomga
Aug 19 2016 09:46
some feed back please, i think theres is a simpler way
function chunkArrayInGroups(arr, size) {
  var resArr = [];  
  var slice = 0;
  var index = 0;
  for(var i = 0; i < arr.length; i += size){
    console.log(size + " slices: " ,arr.slice(slice, slice + size));
    resArr[index] = arr.slice(slice, slice + size);
    slice += size;
    index ++;
  }
  console.log("resArr: " ,resArr);
  return resArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Daniel1997Eze
@Daniel1997Eze
Aug 19 2016 09:46
can anyone using freecodecamp.com share their 144 solution please
Markus Kiili
@Masd925
Aug 19 2016 09:47
@ricardomga This is one fine way:
function chunkArrayInGroups(arr, size) {
  var result = [], i=0;
  while (i<arr.length) result.push(arr.slice(i,i+=size));
  return result;
}
Ricardo Araújo
@ricardomga
Aug 19 2016 09:48
@Masd925 thanks
CamperBot
@camperbot
Aug 19 2016 09:48
ricardomga sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2324 | @masd925 |http://www.freecodecamp.com/masd925
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:48
@Daniel1997Eze What's the challenge name?
Markus Kiili
@Masd925
Aug 19 2016 09:48
@ricardomga For loop solution can be simplified too:
Ken Aguilar
@piq9117
Aug 19 2016 09:48
@llamatarianism ur making valid points.. thanks.. but i'm sticking with my solution.. :)
CamperBot
@camperbot
Aug 19 2016 09:48
piq9117 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1231 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Markus Kiili
@Masd925
Aug 19 2016 09:48
function chunkArrayInGroups(arr, size) {
  var result = [];
  for (var i=0; i<arr.length; i+=size) {
    result.push(arr.slice(i,i+size));
  }
  return result;
}
Daniel1997Eze
@Daniel1997Eze
Aug 19 2016 09:49
Escape Sequence In Strings
Milos
@Milos2709
Aug 19 2016 09:49
Can anyone help me out with Local Weather app? I don't know what's the problem with my icon retrieval.
(change the url to https:// and location and temperature will show)
Please help
https://codepen.io/Milos2709/pen/WxmdaA?editors=0010
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:49
help Escape Sequence In Strings
CamperBot
@camperbot
Aug 19 2016 09:49
no wiki entry for: escape sequence in strings
Alexios Pantavos
@AlexiosP
Aug 19 2016 09:50
help help
CamperBot
@camperbot
Aug 19 2016 09:50

:point_right: coding help [wiki]

Coding Help

I started this list while doing Algorithms, noticing a few things that were common issues / questions but I think most of them are going to be useful to people coding in general. If you've got some tips to help people code I'd love to hear them.

:pencil: read more about coding help on the FCC Wiki

Alexios Pantavos
@AlexiosP
Aug 19 2016 09:50
Rofl, anyways
@Daniel1997Eze What have you tried so far?
Tobias Gerhardsson
@tobiasger
Aug 19 2016 09:50
Is there any way to change jquery options for specific device widths, like media queries in CSS?
'$("#example14").zAccordion({
tabWidth: "15%",
width: "100%",
height: "100%"
});'
Daniel1997Eze
@Daniel1997Eze
Aug 19 2016 09:51
Tried encoding the backslashes in quotes but its not working
Tobias Gerhardsson
@tobiasger
Aug 19 2016 09:51
’code’
$("#example14").zAccordion({
tabWidth: "15%",
width: "100%",
height: "100%"
});
’code'