These are chat archives for FreeCodeCamp/HelpJavaScript

30th
Mar 2017
HeebieGeeBee
@HeebieGeeBee
Mar 30 2017 00:00
@JohnLRI show your code
John Lawson
@JohnLRI
Mar 30 2017 00:01

function updateRecords(id, prop, value) {
var tempArr=[];
if (value==="") {
delete collection[id][prop];
}
else {
if (prop=="tracks") {
if (collection[id][prop]) {
collection[id][prop].push(value);
}else{
tempArr.push(value);
collection[id][prop]=tempArr;
}
} else {collection[id][prop]=value;}
}

return collection;
}

// Alter values below to test your code

updateRecords(2468, "tracks", "Free");

After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element. It is but test fails

john94
@lpy1994
Mar 30 2017 00:02
@JohnLRI you need a loop.
@JohnLRI collection is undefined here
HeebieGeeBee
@HeebieGeeBee
Mar 30 2017 00:04
@JohnLRI also remember to use == or === in conditional comparisons = just assigns a value to a variabl
Seth52
@Seth52
Mar 30 2017 00:05
Any help available with falsy bouncer here's code
john94
@lpy1994
Mar 30 2017 00:05
@JohnLRI also you need a better text editor
Seth52
@Seth52
Mar 30 2017 00:05

function bouncer(arr) {
// Don't show a false ID to this bouncer.
function falsy(arr){

var c= arr!==undefined && !isNaN(arr) && arr!==null && arr!==false && arr!==0 && arr!=="";
return c;
}
// false,null,0,"",undefined,NaN
// need a function that tests for falsy, but keeps the rest

var bar = arr.filter(falsy);

return bar;
}

bouncer([1, null,3, NaN, 2, undefined,"yes"]);

John Lawson
@JohnLRI
Mar 30 2017 00:05
collection was pre written in before

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

// Only change code below this line
function updateRecords(id, prop, value) {
var tempArr=[];
if (value==="") {
delete collection[id][prop];
}
else {
if (prop=="tracks") {
if (collection[id][prop]) {
collection[id][prop].push(value);
}else{
tempArr.push(value);
collection[id][prop]=tempArr;
}
} else {collection[id][prop]=value;}
}

return collection;
}

// Alter values below to test your code

updateRecords(2468, "tracks", "Free");

silver537
@silver537
Mar 30 2017 00:06
@Seth52 why don't you just let the Boolean object do the job for you?
apha009
@apha009
Mar 30 2017 00:07
is there a way to run the code for the challenges without running the tests?
silver537
@silver537
Mar 30 2017 00:08
@apha009 na. the test's will always run
you can open the console to debug your code
apha009
@apha009
Mar 30 2017 00:08
@silver537 Hi, how can I open the console?
john94
@lpy1994
Mar 30 2017 00:08
@JohnLRI I see, you might need a hasOwnProperty
Seth52
@Seth52
Mar 30 2017 00:08
@silver537 hmm im not 100% sure how to do that, I see I might be able to do something with a false boolean value, I'll look into it and see if I can get it to work
silver537
@silver537
Mar 30 2017 00:08
@apha009 hit F12
@Seth52 filter(Boolean) done
john94
@lpy1994
Mar 30 2017 00:09
@JohnLRI no loop needed, that was my bad
Seth52
@Seth52
Mar 30 2017 00:09
@silver537 seriously!! i've been trying to figure this out for days kms!!! thanks for your help!
CamperBot
@camperbot
Mar 30 2017 00:09
seth52 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 909 | @silver537 |http://www.freecodecamp.com/silver537
apha009
@apha009
Mar 30 2017 00:09
for sure thank you!
Abdullah Anis
@Abdullah996
Mar 30 2017 00:10
Plz help where i am going wrong

function sumAll(arr) {
var max = Math.max(...arr);
var min = Math.min(...arr);
var new1= [];
var new2;
for(var i=0;i<max;i++)
{
var a = min++;
new1.push(a);
}
var new2 = new1.reduce(function (a, b) {
return a + b;
});
return new2;
}

sumAll([5,10]);

it should give 45 but it's givin 95
john94
@lpy1994
Mar 30 2017 00:10
@Abdullah996 set var i = min
silver537
@silver537
Mar 30 2017 00:11
@Seth52 well it's a boolean function. so the proper way of doing it is Boolean([whatever you want to check in here])
but since it's a function, you can also pass it in as an argument. and since filter does the loop AND the filtering; all the better
john94
@lpy1994
Mar 30 2017 00:11
@Abdullah996 var a = min++ ??
Abdullah Anis
@Abdullah996
Mar 30 2017 00:11
@lpy1994 Love you ipy thank you so much bro
CamperBot
@camperbot
Mar 30 2017 00:11
abdullah996 sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 297 | @lpy1994 |http://www.freecodecamp.com/lpy1994
Abdullah Anis
@Abdullah996
Mar 30 2017 00:11
its done :D
john94
@lpy1994
Mar 30 2017 00:12
@Abdullah996 :+1:
lit
@JohnLRI any progress ??
Taraqul-Khan
@Taraqul-Khan
Mar 30 2017 00:15

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

// Only change code below this line.

var MotorBike = function() {
constructor.wheels=4;
constructor.engines=3;
constructor.seats=9;
};

not running :(
john94
@lpy1994
Mar 30 2017 00:16
@Taraqul-Khan this, not constructor lol
silver537
@silver537
Mar 30 2017 00:16
this
this.wheels
Seth52
@Seth52
Mar 30 2017 00:16
@silver537 well definitely filter(boolean) worked, I'll play around with the Boolean([]) a little bit first try didnt do much but I'm curious to figure it out, thanks again!
CamperBot
@camperbot
Mar 30 2017 00:16
seth52 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:warning: seth52 already gave silver537 points
Ardigi
@Ardigi
Mar 30 2017 00:16
@roxroy thanks for your help! I got it!
john94
@lpy1994
Mar 30 2017 00:17
@Taraqul-Khan thats how I did it for the first time, :smile:
silver537
@silver537
Mar 30 2017 00:17
@Seth52 it's just Boolean() i put in the square brackets to represent values, not an array.
Roxroy
@roxroy
Mar 30 2017 00:18
@Ardigi , np. Good to hear. Well done.
John Lawson
@JohnLRI
Mar 30 2017 00:20
@lpy1994 thanks that worked
CamperBot
@camperbot
Mar 30 2017 00:20
johnlri sends brownie points to @lpy1994 :sparkles: :thumbsup: :sparkles:
:cookie: 298 | @lpy1994 |http://www.freecodecamp.com/lpy1994
john94
@lpy1994
Mar 30 2017 00:20
@JohnLRI lit
silver537
@silver537
Mar 30 2017 00:22
what's lit?
David Amanze
@GodKingShogun
Mar 30 2017 00:22
@silver537 i think he means when you turn a light bulb on
or a candle
silver537
@silver537
Mar 30 2017 00:23
that makes no sense tho
lexleahey
@lexleahey
Mar 30 2017 00:23
is this not how i append += var someAdjective = "What a very ";
var myStr = "nice day";
someAdjective += myStr;
Seth52
@Seth52
Mar 30 2017 00:23
@silver537 ok, when I went ahead and put in Boolean(arr) for the array within the function it worked too, I was trying to put the other values within the () like NaN and Null and was like why isn't this working lol
john94
@lpy1994
Mar 30 2017 00:24
It means awesome lol
lexleahey
@lexleahey
Mar 30 2017 00:24
im not sure what im doing wrong when i append my var SA with var MS by using += on the 3rd line
David Amanze
@GodKingShogun
Mar 30 2017 00:26
@lexleahey just use +
lexleahey
@lexleahey
Mar 30 2017 00:27
but then myStr goes red on the second half of the line after the +
silver537
@silver537
Mar 30 2017 00:27
@Seth52 boolean only works for one value. and if you did something like Boolean(arr)
it will return true, because an array is a true value.
@lexleahey are you really worried about the color? 0.o
lexleahey
@lexleahey
Mar 30 2017 00:29
its the error line that says im doing somethign wrong and the code wont run...
Uday Patil
@Uday-Patil
Mar 30 2017 00:33

Hello, I am stuck in the WordBlanks task, can someone please explain me, what was expected in this task ?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb, myArticle) {
var result = myArticle + myAdjective + myNoun + myVerb + myAdverb;
// Your code below this line

// Your code above this line
return result;
}

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

Moisés Man
@moigithub
Mar 30 2017 00:34
if u execute ur code. it will return "thedogbigranquickly" @Uday-Patil
Uday Patil
@Uday-Patil
Mar 30 2017 00:35
yes, but what was expected to complete this task ?
Moisés Man
@moigithub
Mar 30 2017 00:35
sothisishowyouusuallywritewords ??
silver537
@silver537
Mar 30 2017 00:36
causeitwoulbebereallyconfusingtoreadthesetypesofsentences
youwithoutspacesandstuffs
Alex
@alexlo0319
Mar 30 2017 00:36
Hello does anybody know what does this really do?
Uday Patil
@Uday-Patil
Mar 30 2017 00:36
Ok, I believe blanks is the problem!
Thanks
silver537
@silver537
Mar 30 2017 00:36
@Uday-Patil no. you need spaces
like literally add those spaces in
like math
using +
Uday Patil
@Uday-Patil
Mar 30 2017 00:36
@silver537 Got it
Thanks
silver537
@silver537
Mar 30 2017 00:37
varialbe + " " + variable
Alex
@alexlo0319
Mar 30 2017 00:37
String.prototype.split()
silver537
@silver537
Mar 30 2017 00:37
the split() or the prototype?
Moisés Man
@moigithub
Mar 30 2017 00:38
Alex
@alexlo0319
Mar 30 2017 00:38
does the name prototype serves as a typo?
silver537
@silver537
Mar 30 2017 00:38
no
Alex
@alexlo0319
Mar 30 2017 00:38
like an example type I mean
silver537
@silver537
Mar 30 2017 00:39
just a way to input customized methods to a pre made object
Alex
@alexlo0319
Mar 30 2017 00:39
Cool
I see long names and I think everything has a meaning.
silver537
@silver537
Mar 30 2017 00:40
essentially they should mean what it's called. split does what it sounds.
David Amanze
@GodKingShogun
Mar 30 2017 00:50

function sym(args) {
  var arg= Array.prototype.slice.call(arguments);
  arg.filter(function (element,index) {

  });

  var secArg=arg.reduce(function(acc,item){
    return acc.concat(item);

  },[]);

  var allocates=secArg.filter(function(element,index,array){
    if (element!==array[index+1]){
      return element;
    }
  });
 var allocate=allocates.reduce(function(acc,item){
  if (item in acc) {
    acc[item]++;
  } else {
    acc[item]=1;
  }
  return acc;

},{});
  for(var prop in allocate){
    if (allocate[prop]%2===0) {
      delete allocate[prop];
    }else {

    }
  }

var result=[];
  for (var i in allocate){
    result.push(i);

  }
for (var j=0; j<result.length; j++){
     result[j] = parseInt(result[j],10);
     }
  return result;
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3,4,5,5]);
im the official goat lol
i simultaneously want to continue and end my life everytime i complete a challenge lol
Moisés Man
@moigithub
Mar 30 2017 00:56
another way to remove duplicates.. is using Set (es6)
new Set([1,1,2,5])
// {1,2,5}
then use Array.from to convert back to an array
Array.from(new Set([1,1,2,5]))
//[1,2,5]
David Amanze
@GodKingShogun
Mar 30 2017 00:58
@moigithub oh wow so just having set will remove all the duplicates
@moigithub that is pretty handy
Moisés Man
@moigithub
Mar 30 2017 00:59
yep.. Set only have uniques values
[1,1,2,5].filter((e,i,a)=>a.indexOf(e)===a.lastIndexOf(e))
filter duplicates
David Amanze
@GodKingShogun
Mar 30 2017 01:00
@moigithub actually now that i think about it, it would not have worked with my code because i had one array and i only wanted to filter out if the element next to it was the same
@moigithub but what if i had a multi dimensional array. would set have gotten rid of the multiples within each nested array
such as [[1,1,2],[2,2,]]
so i would end up with [[1,2],[2]]
silver537
@silver537
Mar 30 2017 01:03
@GodKingShogun unless you need those nested arrays as they come i.e [[1,1,2],[2,2]] => [[1,2],[2]]
you could just flatten the array with append and then filter out the duplicates.
[[1,1,2],[2,2]] => [1,2]
David Amanze
@GodKingShogun
Mar 30 2017 01:05
@silver537 not what i wanted. i just want the nested array to filter out duplicates
silver537
@silver537
Mar 30 2017 01:05
then you could map each nested array by filtering them.
arr.map(function(x){return x.filter(Set(x))}) somethin like that
David Amanze
@GodKingShogun
Mar 30 2017 01:06
@silver537 someone else suggested that but i didn't know how to write it. can you show me
@silver537 i dont understand that way of writing code
@silver537 can you use the normal way
Moisés Man
@moigithub
Mar 30 2017 01:07

const sym=function(args){
  return [...arguments].reduce((a,b)=>{

    return [...Array.from(new Set(a)), ...Array.from(new Set(b))].filter((e,i,a)=>a.indexOf(e)===a.lastIndexOf(e));
  });
}

sym([1, 1, 2, 5], [2, 2, 3, 5], [3,4,5,5]);
David Amanze
@GodKingShogun
Mar 30 2017 01:08
@moigithub do you know where i can go to learn the transition to es6
@moigithub is that how it is referred
silver537
@silver537
Mar 30 2017 01:08
any youtube videos
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:08

function rot13(str) { // LBH QVQ VG!
  var split = str.split("");
  var array =[];
  var join;

  for (i = 0; i < split.length; i++){
    array.push(String.fromCharCode(split[i].charCodeAt() - 13));
  }


  join = array.join("");
  return join;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Moisés Man
@moigithub
Mar 30 2017 01:08
plenty tutorials on google
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:08
i feel like im so close...
Jai Mitch
@jaimitch
Mar 30 2017 01:08
does this line need a "=" when doing an escape sequence (var myStr; // Change this line)
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:08
do i need an if then statement?
David Amanze
@GodKingShogun
Mar 30 2017 01:09
@moigithub but i want your recommendation :smile:
Moisés Man
@moigithub
Mar 30 2017 01:09
i only learned from what ppl post in here
only know very few stuff.. too lazy to read /search myself :P
spread operator, let, const, arrow function
and destructuring
silver537
@silver537
Mar 30 2017 01:10
rest
David Amanze
@GodKingShogun
Mar 30 2017 01:10
@moigithub your pretty good for being lazy :smile:
you are*
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:11
i need help on Replacing If Else Chains with Switch
i did this:
switch(val){
case "bob":
answer = "Marley";
break;
case 42:
answer = "The Answer";
break;
case 1:
answer = "There is no #1";
break;
case 99:
answer = "Missed me by this much!";
break;
case 7:
answer = "Ate Nine";
break;
case "John":
answer = "";
break;
case 156:
answer = "";
break;
}
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:11

function rot13(str) { // LBH QVQ VG!
  var split = str.split("");
  var array =[];
  var join;

  for (i = 0; i < split.length; i++){
    array.push(String.fromCharCode(split[i].charCodeAt() - 13));
  }


  join = array.join("");
  return join;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
any suggestions on how to finish?
David Amanze
@GodKingShogun
Mar 30 2017 01:12
@moigithub teach me your ways sensei :satisfied:
Moisés Man
@moigithub
Mar 30 2017 01:12
how long u been on fcc ? :) (me 1.5 years almost) @GodKingShogun
David Amanze
@GodKingShogun
Mar 30 2017 01:13
@moigithub are you asking me
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:13
help me
David Amanze
@GodKingShogun
Mar 30 2017 01:13
ive been on here since september
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:13
hhhhhhhheeeeeeeeeelllllllllllllllpppppppppppp meeeeeeeeeeeeeee plzzzzzzzzzzzzzzzzzzzzzz
:)
silver537
@silver537
Mar 30 2017 01:14
@ShaimaTheBlueberry just for that, you're not getting help
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:14
:(
silver537
@silver537
Mar 30 2017 01:14
no mercy for the impatient
David Amanze
@GodKingShogun
Mar 30 2017 01:14
@ShaimaTheBlueberry look at the example and follow the documentation
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:14
someone?
im so close...
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:14
i did and i tested it and it said i was wrong
it
silver537
@silver537
Mar 30 2017 01:14
@AbradolfLinclr what does your code do
Moisés Man
@moigithub
Mar 30 2017 01:14
@ShaimaTheBlueberry forgot the instructions.. whats the challenge NAME ?
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:15
its the Replacing If Else Chains with Switch
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:15
@silver537 im doing caesars cypher
silver537
@silver537
Mar 30 2017 01:15
@AbradolfLinclr but what does it do
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:15
@silver537 it prints out F8EEC5DECAM6
so i think i need an if then statement
silver537
@silver537
Mar 30 2017 01:15
line by line! >.<
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:16
oh alright
this is kind of hard to explain its one of my first one liners lol
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:17
:D
silver537
@silver537
Mar 30 2017 01:17
which is why i asked you to explain it to me
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:17
:\
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:17
alright so it splits the string into an array
after i get the charcodeat of each individual array object i minus 13
and than i convert in into a string using the string.fromcharat
and i push that string into an array
and than i join that array into a string
silver537
@silver537
Mar 30 2017 01:18
@AbradolfLinclr wooooooah
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:18
? wow
Moisés Man
@moigithub
Mar 30 2017 01:18
@ShaimaTheBlueberry seems u added extra cases...
silver537
@silver537
Mar 30 2017 01:18
minus 13?
zippy
@ShaimaTheBlueberry
Mar 30 2017 01:18
what did i add?
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:19
because that is rot13
silver537
@silver537
Mar 30 2017 01:19
are you sure ALL the characters need to be -13?
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:19
no i know they need to be +
i just dont know where to throw that if then statement
silver537
@silver537
Mar 30 2017 01:19
so there's your if
at that spot
Moisés Man
@moigithub
Mar 30 2017 01:19
  if (val === "bob") {
    answer = "Marley";
  } else if (val === 42) {
    answer = "The Answer";
  } else if (val === 1) {
    answer = "There is no #1";
  } else if (val === 99) {
    answer = "Missed me by this much!";
  } else if (val === 7) {
    answer = "Ate Nine";
  }
thats the original code @ShaimaTheBlueberry
it only have 5 cases/ conditions
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:19
@silver537 i understand that, the only problem is its a one liner so i dont really know where to put it lol
silver537
@silver537
Mar 30 2017 01:19
to check if the character need to be -13 OR +13
look up ternary
it's a one liner if statement
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:20
@silver537 ok
c0d0er
@c0d0er
Mar 30 2017 01:20
does anybody know why my code cannot fire the x axis? and in my local machine the y axis has no problem, why in codepen has the problem? http://codepen.io/c0d0er/full/dvQRGy/
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:20
@silver537 im looking it up, thank you for guidance to next step!
CamperBot
@camperbot
Mar 30 2017 01:20
abradolflinclr sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 910 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Mar 30 2017 01:21
@c0d0er it's been awhile. i see you have progressed so much
c0d0er
@c0d0er
Mar 30 2017 01:22
@silver537 thanks, still appreciate your help! just keep moving, now its not so easy as earlier even at that time feels harder lol
CamperBot
@camperbot
Mar 30 2017 01:22
:cookie: 911 | @silver537 |http://www.freecodecamp.com/silver537
c0d0er sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
Nicholas
@nicholasao
Mar 30 2017 01:23
x_x.PNG
can someone please tell me what I'm supposed to do.. I'm suddenly so backwards
silver537
@silver537
Mar 30 2017 01:24
@c0d0er yea i don't have time to help people with projects anymore. only small code blocks and stuff like the challenges. but with work gettin in the way, its hard. :(
Manish Giri
@Manish-Giri
Mar 30 2017 01:25
@nicholasao there are two steps in that challenge -
  1. add the number item to the end of the array arr
  2. remove the first element from the array arr and return it.
    The two functions - .push() and .shift() would be helfpul.
Moisés Man
@moigithub
Mar 30 2017 01:26
@c0d0er u need babel to transpile ur code
silver537
@silver537
Mar 30 2017 01:26
@Manish-Giri do you have that saved somewhere? or do you write it out everytime?
Manish Giri
@Manish-Giri
Mar 30 2017 01:27
@silver537 got it saved :stuck_out_tongue:
silver537
@silver537
Mar 30 2017 01:27
must be a FAQ then huh
Manish Giri
@Manish-Giri
Mar 30 2017 01:27
if I learnt one thing at FCC
it's to save these things
lol
c0d0er
@c0d0er
Mar 30 2017 01:27
@moigithub thanks! got confused with this xAxis, could you please check my xAxis to see what is the problem, it should be fine, but the console shows some problems
CamperBot
@camperbot
Mar 30 2017 01:27
c0d0er sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2928 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Mar 30 2017 01:28
@c0d0er .attr('transform', 'translate('+0+',0)')
that +0+ looks weird :)
that 0 is a placeholder (like u still working on it.. gonna replace) ? a 0 value ? or a variable ?
Nicholas
@nicholasao
Mar 30 2017 01:28
@Manish-Giri thank you ^^
CamperBot
@camperbot
Mar 30 2017 01:28
nicholasao sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 4997 | @manish-giri |http://www.freecodecamp.com/manish-giri
c0d0er
@c0d0er
Mar 30 2017 01:29
@moigithub i know, that part is fine, the o is just a 0 value, i should change to normal writing
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:29
@silver537
silver537
@silver537
Mar 30 2017 01:30
you called?
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:30
function rot13(str) { // LBH QVQ VG!
  var split = str.split("");
  var array =[];
  var join;

  for (i = 0; i < split.length; i++){
    if(split[i].charCodeAt() >= 78){
    array.push(String.fromCharCode(split[i].charCodeAt() - 13));
    }
    else
      {
      array.push(String.fromCharCode(split[i].charCodeAt() + 13));
      }
  }


  join = array.join("");
  return join;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
so i got the write text... now do i just do a replacement of all special characters?
right text* not write lol
i might need a break after this lmao
c0d0er
@c0d0er
Mar 30 2017 01:31
@moigithub the code issue should be at lines 18-20 and 50-54
silver537
@silver537
Mar 30 2017 01:32
@AbradolfLinclr they want your code to ONLY focus on capitalized letters range. from A-Z. and in the ASCII chart what are the number ranges for those Specific letters?
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:33
@silver537 i might of guessed and find out the break even was 78
so prob between 65 and 91
im going back in thank you again
eeflores
@eeflores
Mar 30 2017 01:34
I think it's best to use "A".charCodeAt(0) so you don't have unknown numbers
Ruta Stasytyte
@Ruta8
Mar 30 2017 01:35
The code works, for every possible number but not zero, so I put it an if statement. Is that considered a properly working code or should I start over?
OuRyoShin
@DJQTDJ
Mar 30 2017 01:35
if there anyone who goot at apache
silver537
@silver537
Mar 30 2017 01:35
65 and 90. so if the character code lies between the two, if the character lies inside 65 and 65+ 13 then add 13, otherwise subtract 13, otherwise don't do anything to the character. AND THAT MY GOOD SIR, is literally the one liner version of your if statement
@AbradolfLinclr
Moustapha
@moustaflo
Mar 30 2017 01:36
Uncaught TypeError: Cannot read property 'name' of undefined
not sure what is causing this. id of p1 exists.
document.getElementById("p1").innerHTML = x;
Stephen James
@sjames1958gm
Mar 30 2017 01:36
@moustaflo Must be a different line than that - there is no name there
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:36
@silver537 i got it to work
silver537
@silver537
Mar 30 2017 01:37
cool!
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:37
@silver537 can you show me how you would of wrote the if then

function rot13(str) { // LBH QVQ VG!
  var split = str.split("");
  var array =[];
  var join;

  for (i = 0; i < split.length; i++){
    if(split[i].charCodeAt() >= 78 && split[i].charCodeAt() <= 91){
    array.push(String.fromCharCode(split[i].charCodeAt() - 13));
    }
    else if(split[i].charCodeAt() <= 78 && split[i].charCodeAt() >= 65)
      {
      array.push(String.fromCharCode(split[i].charCodeAt() + 13));
      }
    else
      {
        array.push(String.fromCharCode(split[i].charCodeAt()));
      }
  }


  join = array.join("");
  return join;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
mine was a little longer than a one liner now
Stephen James
@sjames1958gm
Mar 30 2017 01:39
@AbradolfLinclr
This can be replaced by return array.join(" "); and is probably better form
  join = array.join("");
  return join;
Thom
@klondikepanther
Mar 30 2017 01:39
I am also having some issues with Caesars cipher.
My logic is to split the input string into an array using .split("") then compare that array to another array which contains the alphabet, using nested for loops.
once the function matches the character of the input string array to a character in the alphabet array
it will either add or subtract 13 from the integer value of the alphabet array element, which matches the character from the string array . I feel like there is an issue with how I put together my if and else statement as it quite work code below and thanks for any help.

function rot13(str) { // LBH QVQ VG!      

  var string ="";
  var alpha = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
  var arr =[];
  arr = str.split("");
  for(var i=0;i<=arr.length;i++){  
    for(var j=0;j<alpha.length;j++){
      if(arr[i] == alpha[j] && j<12){
           arr[i]=alpha[j+13]; 
                             }
           else if (arr[i] == alpha[j] && j>12) {
             arr[i] = alpha[j-13]; 
           }  
    }
  }  
for(i=0;i<arr.length;i++){
string = string.concat(arr[i]);
  }
  return string;}
// Change the inputs below to test
rot13("SERR PBQR PNZC!");
silver537
@silver537
Mar 30 2017 01:39
@AbradolfLinclr
(c<65||c>90)? String.fromCharCode(c): (c< 78)? String.fromCharCode(c+ 13): String.fromCharCode(c- 13);
Ruta Stasytyte
@Ruta8
Mar 30 2017 01:40

code works with all numbers but I needed to put in an if statement function factorialize(num) {
var array = [];
for (var i = 1; i <= num; i++) {
array.push(i);
}
if (num === 0) {
return 1;
}
return array.reduce (function(a, b) {
return a * b;
});
}

factorialize(1);

is this ok?
AbradolfLinclr
@AbradolfLinclr
Mar 30 2017 01:40
@silver537 oh that does seem like a nice little shortcut
Stephen James
@sjames1958gm
Mar 30 2017 01:41
@Ruta8 If you supply an additional parameter to reduce, then it will return that value for an empty array.
return array.reduce(function() {}, 1); that one becomes the first a value and the return value for an empty array
Then you don't need the if
silver537
@silver537
Mar 30 2017 01:41
@AbradolfLinclr yea and just put all of that inside the push()
Stephen James
@sjames1958gm
Mar 30 2017 01:42
@klondikepanther 1) you can use join("") to put the array back together.
@klondikepanther You need to stop the inner loop once you match the letter or you will add 13 and then subtract 13 when you match later in the array
@klondikepanther
if(arr[i] == alpha[j]) {
   if (j<=12){
     arr[i]=alpha[j+13]; 
   } else  {
     arr[i] = alpha[j-13]; 
   }
   break;
  }
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:47
hey Im on this challenge called "Repeat a string"
There is a .repeat method and Can I use it?
silver537
@silver537
Mar 30 2017 01:48
nope
they want you to learn how to concatenate to a certain interval
Manish Giri
@Manish-Giri
Mar 30 2017 01:49
There is a .repeat method and Can I use it?
no
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:49
But..

function repeatStringNumTimes(str, num) {
  // repeat after me
 return str.repeat(num);
}

repeatStringNumTimes("abc", 3);
Im close...
silver537
@silver537
Mar 30 2017 01:49
just no
that's too easy
don't be lazy
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:50
What am I supposed to do?
Manish Giri
@Manish-Giri
Mar 30 2017 01:50
hackreactor has a challenge that asks you to find length of a string without using .length
silver537
@silver537
Mar 30 2017 01:50
do the challenge with out repeat

hackreactor has a challenge that asks you to find length of a string without using .length()

which is why we have .length because that method is a b**ch

Manish Giri
@Manish-Giri
Mar 30 2017 01:51
it's about being able to write all kinds of algos
Thom
@klondikepanther
Mar 30 2017 01:51
@sjames1958gm thanks man! I will work on that
CamperBot
@camperbot
Mar 30 2017 01:51
klondikepanther sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6424 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Moisés Man
@moigithub
Mar 30 2017 01:51
@c0d0er let xScale=d3.scaleLinear()
.domain([1753,2015])
.range([0,w]); <--- missing square brackets
Manish Giri
@Manish-Giri
Mar 30 2017 01:51
oops sorry I meant .length @silver537
Ruta Stasytyte
@Ruta8
Mar 30 2017 01:54
@sjames1958gm thanks
CamperBot
@camperbot
Mar 30 2017 01:54
ruta8 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6425 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:56
Ok I managed to pass this challenge but I will still try to write a code without .repeat method
Here's my code just want to show it

function repeatStringNumTimes(str, num) {
  // repeat after me
  if (num<0) {
    return "";
  }
 var a = str;
  var b = num;
  return a.repeat(b);
}

repeatStringNumTimes("abc", 3);
Moustapha
@moustaflo
Mar 30 2017 01:56
@sjames1958gm document.write prints x with no issues though. Could it be the relationship between the html and the js maybe
Manish Giri
@Manish-Giri
Mar 30 2017 01:56
why did you use repeat()?
@MathematicsCoding
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:56
Im just testing...
Manish Giri
@Manish-Giri
Mar 30 2017 01:57
why
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:57
Im trying to figure out how to do it without repeat
Manish Giri
@Manish-Giri
Mar 30 2017 01:57
by using repeat?
lol
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:57
Im just testing...
Im thinking what to replace .repeat
Stephen James
@sjames1958gm
Mar 30 2017 01:57
@moustaflo With that error I would have expected to see .name
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:57
I dont know if there is other way
Mike Echlin
@mechlin69
Mar 30 2017 01:57
stumped on challenge 198. if else or switch?
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:57
I tried a*(b)
Manish Giri
@Manish-Giri
Mar 30 2017 01:58
there are at least 2 other ways
Stephen James
@sjames1958gm
Mar 30 2017 01:58
@mechlin69 What is the name of that one? The number is your progress number
Mike Echlin
@mechlin69
Mar 30 2017 01:58
Return Early Pattern for Functions
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:58
@Manish-Giri By using the (*) sign?
multiply sign
Manish Giri
@Manish-Giri
Mar 30 2017 01:58
nope
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:58
Oh
Stephen James
@sjames1958gm
Mar 30 2017 01:59
@mechlin69 An if statement is probably the most straightforward
Saboor Malik
@MathematicsCoding
Mar 30 2017 01:59
So no method?
look here
you'll find the method
Stephen James
@sjames1958gm
Mar 30 2017 02:00
@MathematicsCoding Also, look for challenges Concatenating Strings . . .
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:00
String(thing)
Is string an agruement?
parameter
MR-Em
@MR-Em
Mar 30 2017 02:01
Finished javascript. What a puzzle
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:01
@sjames1958gm I know how concatenating works
MR-Em
@MR-Em
Mar 30 2017 02:01
Not up to scratch at all. Dont even know what to do
And the algorithm challenges. Messed up things
David Amanze
@GodKingShogun
Mar 30 2017 02:01
@Manish-Giri did you ever get to watch any of the animes i suggested
Stephen James
@sjames1958gm
Mar 30 2017 02:01
@MathematicsCoding Hmm
Mike Echlin
@mechlin69
Mar 30 2017 02:02
function abTest(a, b) {
// Only change code below this line
if (a <0);
else if (b<0);
return;
Stephen James
@sjames1958gm
Mar 30 2017 02:02
Manish Giri
@Manish-Giri
Mar 30 2017 02:02
@GodKingShogun i have it on the list, planning to start this weekend
:stuck_out_tongue:
David Amanze
@GodKingShogun
Mar 30 2017 02:02
@Manish-Giri im exited for you :smile:
@Manish-Giri welcome to the brotherhood lol
Manish Giri
@Manish-Giri
Mar 30 2017 02:03
lol
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:03
@sjames1958gm I can write a simple code for concatenting...
Manish Giri
@Manish-Giri
Mar 30 2017 02:03
ty @GodKingShogun
CamperBot
@camperbot
Mar 30 2017 02:03
manish-giri sends brownie points to @godkingshogun :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @godkingshogun |http://www.freecodecamp.com/godkingshogun
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:03
strings
Manish Giri
@Manish-Giri
Mar 30 2017 02:03
@MathematicsCoding then use that here
Mike Echlin
@mechlin69
Mar 30 2017 02:03
@sjames1958gm cool thx!
CamperBot
@camperbot
Mar 30 2017 02:03
mechlin69 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6426 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Moustapha
@moustaflo
Mar 30 2017 02:04
@sjames1958gm i'm sorry i meant
Uncaught TypeError: Cannot set property 'innerHTML' of null
David Amanze
@GodKingShogun
Mar 30 2017 02:04
im getting off for now. Learned something new today. can't ask for more. be back next day :wave: @everyone
Manish Giri
@Manish-Giri
Mar 30 2017 02:04
@GodKingShogun :wave:
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:05
@Manish-Giri A mystery method from that page and use concatenating strings?
Manish Giri
@Manish-Giri
Mar 30 2017 02:05
@MathematicsCoding you can use either
of those 2
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:05
Ok I will try using concatenating strings
juni
@junipberry
Mar 30 2017 02:09
Hi all~~ I’m in the condensing arrays with reduce section and I’m wondering how to set an accumulator? Do I set a function for a summation of val, if I want all the numbers in the array to be added?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:11
I found something called "Concatenation Operator"
c0d0er
@c0d0er
Mar 30 2017 02:11
@moigithub thank you! really low mistake! thanks!
CamperBot
@camperbot
Mar 30 2017 02:11
c0d0er sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: c0d0er already gave moigithub points
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:11
I believe that could be another way
Never mind that...

function repeatStringNumTimes(str, num) {
  // repeat after me
  if (num<0) {
    return "";
  }
var a = str;
  var b = num;
  var c = ...;
}

repeatStringNumTimes("abc", 3);
Thom
@klondikepanther
Mar 30 2017 02:13
@sjames1958gm thanks again! I just needed some break statments!
CamperBot
@camperbot
Mar 30 2017 02:13
klondikepanther sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: klondikepanther already gave sjames1958gm points
Stephen James
@sjames1958gm
Mar 30 2017 02:17
@klondikepanther :) - yes your e was changed to r then back to e
Danny Welstad
@GoonTwo
Mar 30 2017 02:18
bonfire challenge "Seek and Destroy": Any ideas on why thise code isn't working? It's returning the array that is put in with no changes.
function destroyer(arr) {
  // Remove all the values
  return arr.filter(function(val){
    var tester = true;
   for (var i = 1; i < arguments.length; i++) {
      if (arguments[i] === val) {
        tester = false;
      }
    }
     return tester;
  });

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Stephen James
@sjames1958gm
Mar 30 2017 02:18
@GoonTwo arguments inside of the filtered function is not the same as destroyer function
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:19
Sorry I couldn't figure it out...
I will come back to it later
Stephen James
@sjames1958gm
Mar 30 2017 02:19
@MathematicsCoding Consider looping?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:19
I thought so
Wait..
Stephen James
@sjames1958gm
Mar 30 2017 02:20
@junipberry You can set the initial accumulator value with a second parameter to reduce.
If that is not there the first array element is the first accumulator value
Ken Haduch
@khaduch
Mar 30 2017 02:20
@junipberry - If I get what you're trying to do, you should have a function that does accumulator += val depending on the name of your variables, and return the accumulator
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:21
@sjames1958gm for loop?
Stephen James
@sjames1958gm
Mar 30 2017 02:21
@MathematicsCoding I would
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:22
I dont know how to do it with two parameter inside...
Danny Welstad
@GoonTwo
Mar 30 2017 02:22
@sjames1958gm so your saying I can't use "arguments" to reference the additional arguemtns from the original function?
Stephen James
@sjames1958gm
Mar 30 2017 02:23
@GoonTwo Not using that name you can assign arguments to another variable ouside the filter function
Danny Welstad
@GoonTwo
Mar 30 2017 02:23
@sjames1958gm ok ill give that a shot
@sjames1958gm thanks
CamperBot
@camperbot
Mar 30 2017 02:23
goontwo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6427 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Danny Welstad
@GoonTwo
Mar 30 2017 02:24
@sjames1958gm is there a quick way to quickly push additional arguments to another variable?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:24
@sjames1958gm You know there is i++
Can I do it with i**
Danny Welstad
@GoonTwo
Mar 30 2017 02:25
yeah nvm i got it
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:25
@revisualize Is that your?
Joseph
@revisualize
Mar 30 2017 02:26
Hello.
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:26
Hi
@revisualize Im on this challenge repeat a string
Joseph
@revisualize
Mar 30 2017 02:26
@MathematicsCoding That is.. Sorry. That was supposed to go to the main chat.
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:27
I managed to pass this challenge using repeat method but Im trying to do something else without that method
@revisualize lol Its okay
Nice office
Austin White
@Aeolionx
Mar 30 2017 02:27
Challenge - Everything Be True. Any know why this is returning false?
function truthCheck(collection, pre) {
  // Is everyone being true?
  var truthy = true;
  for(var i=0; i<collection.length; i++){
    if(collection[i][pre] !== true)
      truthy = false;
  }
  return truthy;
}

truthCheck([{"user": "Tinky-Winky", "sex": "male"}, {"user": "Dipsy", "sex": "male"}, {"user": "Laa-Laa", "sex": "female"}, {"user": "Po", "sex": "female"}], "sex");
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:29
@revisualize I have a question
Joseph
@revisualize
Mar 30 2017 02:29
@MathematicsCoding What are you trying to do with the .repeat() method?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:29
I passed with it
Joseph
@revisualize
Mar 30 2017 02:29
Are you trying to do something besides repeat stuff?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:29
Im trying to do something else without it
Yeah
How do you multiply by first parameter and second parameter inside for loop?
Joseph
@revisualize
Mar 30 2017 02:30
param1 * param2
@MathematicsCoding What are you talking about?
Austin White
@Aeolionx
Mar 30 2017 02:31
@revisualize so why does a nonempty string equal false though?
Stephen James
@sjames1958gm
Mar 30 2017 02:32
@Aeolionx !== is a strict comparison no coercion.
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:32
@revisualize well Im trying to multiply first parameter and second one
Like repeat it

function repeatStringNumTimes(str, num) {
  // repeat after me
  if (num<0) {
    return "";
  }
for (var i = 0; i < str.length; str*num) {
     return str;
     }
}

repeatStringNumTimes("abc", 3);
Stephen James
@sjames1958gm
Mar 30 2017 02:32
@Aeolionx if (!collection[i][pre]) would test for falsy
Austin White
@Aeolionx
Mar 30 2017 02:32
@sjames1958gm it also fails if I use !=
@sjames1958gm I tried that and it failed also
Joseph
@revisualize
Mar 30 2017 02:33
@MathematicsCoding Okay. Your problem is that you're trying to loop based upon the string length.
@MathematicsCoding You should be looping on the num.
Austin White
@Aeolionx
Mar 30 2017 02:33
@sjames1958gm thank you, I dont know why it worked this time but it did
CamperBot
@camperbot
Mar 30 2017 02:33
aeolionx sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6428 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Austin White
@Aeolionx
Mar 30 2017 02:33
@revisualize thank you
CamperBot
@camperbot
Mar 30 2017 02:33
aeolionx sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3625 | @revisualize |http://www.freecodecamp.com/revisualize
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:34
@MathematicsCoding You should be looping on the num.
I dont understand
Am I supposed to change str to num?
Joseph
@revisualize
Mar 30 2017 02:34
@MathematicsCoding
for (var i = 0; i < num; i++) {
     return str; // Do not return here. You have to think logically about when you want to return.
 }
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:35
So just leave it at return;?
or no return
Joseph
@revisualize
Mar 30 2017 02:35
@MathematicsCoding What does return do to your function?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:35
call the parameter?
Joseph
@revisualize
Mar 30 2017 02:35
No
@MathematicsCoding
The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
@MathematicsCoding How many times do you think your loop runs if you're telling it to return right away?
Anavel
@arivera165
Mar 30 2017 02:37
hey guys, i am clueless when it comes to javascript. i've got this var a = 7; var b = 7; but its telling me a should be assigned to b with an = but i dont understand how i'm supposed to do this
Joseph
@revisualize
Mar 30 2017 02:37
@arivera165 How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
Cory Bowles
@cbconsulting
Mar 30 2017 02:38

var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = 4;
this.seats = 1;
this.engines = 1;
};

//Try it out here
var myCar = new Car();
myCar.crazy(6,3,1);

Anavel
@arivera165
Mar 30 2017 02:38
cool. i hate math
Cory Bowles
@cbconsulting
Mar 30 2017 02:38
cant get it to pass
Joseph
@revisualize
Mar 30 2017 02:39
@arivera165 It isn't about math. It is about understanding logic.
Anavel
@arivera165
Mar 30 2017 02:40
which.. is what math is. good with logic, bad with numbers.
Joseph
@revisualize
Mar 30 2017 02:40
@arivera165 Variables hold values.
a variable can be a string.
A variable can be an object.
A variable can be an array.
A variable can also hold numbers.
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:41
Sigh I will change it back to my old code and will come back to it later
Cory Bowles
@cbconsulting
Mar 30 2017 02:41
any takers
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:41

function repeatStringNumTimes(str, num) {
  // repeat after me
  if (num<0) {
    return "";
  }
  return str.repeat(num);
}

repeatStringNumTimes("abc", 3);
So simple...
jacob
@bjh2012
Mar 30 2017 02:41
@truepalyer6 look at the example in red that goes along with the challenge closely
Cory Bowles
@cbconsulting
Mar 30 2017 02:43
@bjh2012 i am looking and can tell if it wants me to set whole new properties as i have tryed that
jacob
@bjh2012
Mar 30 2017 02:44
@truepalyer6 should the properties be numbers?
Anavel
@arivera165
Mar 30 2017 02:44
i stil; dont get this
Joel
@MMK123
Mar 30 2017 02:46
hello. im lost AF
Antwone McDuffie
@vatwon1308
Mar 30 2017 02:46
I've been working on the "Find the longest word in a string" challenge for the last two days. For some reason my for loop only returns the value for the first word. What am I missing? Any help will be greatly appreciated. Here is my code:
Joel
@MMK123
Mar 30 2017 02:46
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

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

return item; // Change this line
}

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

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

Rudy Hernandez
@rudolphh
Mar 30 2017 02:47
@MathematicsCoding on beta it says not to use repeat lol.
Joel
@MMK123
Mar 30 2017 02:47
i understand that i need to use the push/pull stuff but i dont know when or how to use those fns
Manish Giri
@Manish-Giri
Mar 30 2017 02:47
@MMK123 there are two steps in that challenge -
  1. add the number item to the end of the array arr
  2. remove the first element from the array arr and return it.
    The two functions - .push() and .shift() would be helfpul.
Antwone McDuffie
@vatwon1308
Mar 30 2017 02:48

I've been working on the "Find the longest word in a string" challenge for the last two days. For some reason my for loop only returns the value for the first word. What am I missing? Any help will be greatly appreciated. Here is my code:

function findLongestWord(str) {
//split the string into an array and declare the long variable
  var arr = str.split(" ");
  var long = 0;
//loop through the array to compare word lengths to the long variable
  for (i = 0; i < arr.length; i++);{
        if (long < arr[i].length){
          long = arr[i].length;

        }   
     return long;
    }   

}



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

I am super stuck.

Manish Giri
@Manish-Giri
Mar 30 2017 02:48
@vatwon1308 you have a return inside the loop.
Cory Bowles
@cbconsulting
Mar 30 2017 02:48
@bjh2012 yea not sure on this on e
@bjh2012 its says change this constructor and then call the function
jacob
@bjh2012
Mar 30 2017 02:50
@truepalyer6 the box in red on the left pretty much has the answer you need.
Joel
@MMK123
Mar 30 2017 02:51
@Manish-Giri can you explain that again?
add the number item?
Cory Bowles
@cbconsulting
Mar 30 2017 02:51

@bjh2012 var Car = function(wheels, seats, engines) {
//Change this constructor
this.wheels = (wheels);
this.seats = (seats);
this.engines = (engines);

};

//Try it out here
var myCar = new Car(6, 3, 1);
Feel pretty ignorant right now

Joel
@MMK123
Mar 30 2017 02:51
i dont see an array called arr
Joseph
@revisualize
Mar 30 2017 02:51
@vatwon1308 Your loop isn't looping.
Manish Giri
@Manish-Giri
Mar 30 2017 02:51
@MMK123 function nextInLine(arr, item)
Antwone McDuffie
@vatwon1308
Mar 30 2017 02:51
@Manish-Giri thank you!
CamperBot
@camperbot
Mar 30 2017 02:51
vatwon1308 sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5002 | @manish-giri |http://www.freecodecamp.com/manish-giri
Cory Bowles
@cbconsulting
Mar 30 2017 02:51
cant use parameters with out setting them
Manish Giri
@Manish-Giri
Mar 30 2017 02:51
@vatwon1308 :+1:
Joel
@MMK123
Mar 30 2017 02:51
so i need to define arr?
Cory Bowles
@cbconsulting
Mar 30 2017 02:52
@bjh2012 thank you
CamperBot
@camperbot
Mar 30 2017 02:52
truepalyer6 sends brownie points to @bjh2012 :sparkles: :thumbsup: :sparkles:
:cookie: 230 | @bjh2012 |http://www.freecodecamp.com/bjh2012
Manish Giri
@Manish-Giri
Mar 30 2017 02:52
its already setup as a parameter
you need to use it
Joel
@MMK123
Mar 30 2017 02:52
how do i use it?
jacob
@bjh2012
Mar 30 2017 02:52
@truepalyer6 did you get it?
Joel
@MMK123
Mar 30 2017 02:52
i dont even know where to begin on this exercise
also what is it defined as? i dont see
Manish Giri
@Manish-Giri
Mar 30 2017 02:53
[1,2,3] - given this array, how would you add the number 4 to it's end?
@MMK123
Cory Bowles
@cbconsulting
Mar 30 2017 02:53
@bjh2012 yea i did. Like i said you have to set your arguments and taret them. I wasnt even calling the arguments
Joel
@MMK123
Mar 30 2017 02:53
.push(4);
Manish Giri
@Manish-Giri
Mar 30 2017 02:53
there's your answer.
jacob
@bjh2012
Mar 30 2017 02:54
@truepalyer6 yeah. it took me a minute too. i'm still trying to wrap my head around some of this
Cory Bowles
@cbconsulting
Mar 30 2017 02:54
@bjh2012 this.wheels = (); it was set to just a number. The function can not be perfromed as i treat the function as a stand alone program
Joel
@MMK123
Mar 30 2017 02:54
gotcha
what is item defined as?
Antwone McDuffie
@vatwon1308
Mar 30 2017 02:55
@revisualize I tried to return the value inside of the loop. The most simple things will have me stomped for days
jacob
@bjh2012
Mar 30 2017 02:55
@truepalyer6 right
Manish Giri
@Manish-Giri
Mar 30 2017 02:55

@MMK123 if you're still confused, look at these lines -

var testArr = [1,2,3,4,5]; //creates an array
console.log(nextInLine(testArr, 6)); //calls your function passing in testArr and 6

here, your function is being called, and your function was defined as -
function nextInLine(arr, item) {
so, when the function gets called, arr becomes the array [1,2,3,4,5] and item becomes 6.

Cory Bowles
@cbconsulting
Mar 30 2017 02:55
@bjh2012 It can only perfrom as well as you tell it to. I learning the art of being a code Whisper
jacob
@bjh2012
Mar 30 2017 02:56
@truepalyer6 haha. it is a fine art
Joseph
@revisualize
Mar 30 2017 02:56
@vatwon1308 When a return statement is triggered it will halt that function and return back to the function caller.
@vatwon1308 If your function returns too early. you could be causing serious issues within your code.
Joel
@MMK123
Mar 30 2017 02:57
i guess what's confusing me is that the variable is named two different things
i dont see how var testArr and arr are used interchangeably
Joseph
@revisualize
Mar 30 2017 02:57
@MMK123 They aren't.
Joel
@MMK123
Mar 30 2017 02:57
they need to be named the exact same, was my understanding
Joseph
@revisualize
Mar 30 2017 02:57
No they don't.
Manish Giri
@Manish-Giri
Mar 30 2017 02:57
why
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:58
about @revisualize
CamperBot
@camperbot
Mar 30 2017 02:58
:star2: 3625 | @revisualize |http://www.freecodecamp.com/revisualize
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:58
about @Manish-Giri
CamperBot
@camperbot
Mar 30 2017 02:58
:star2: 5002 | @manish-giri |http://www.freecodecamp.com/manish-giri
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:58
Hm
Joel
@MMK123
Mar 30 2017 02:58
so i could replace var testArry with varMyAss and when i call arr it will use var MyAss?
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:58
Congrats on 5k @Manish-Giri
@MMK123 Sure
Manish Giri
@Manish-Giri
Mar 30 2017 02:59
tx @MathematicsCoding
CamperBot
@camperbot
Mar 30 2017 02:59
manish-giri sends brownie points to @mathematicscoding :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @mathematicscoding |http://www.freecodecamp.com/mathematicscoding
Manish Giri
@Manish-Giri
Mar 30 2017 02:59
:+1:
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:59
:thumbsup:
Joel
@MMK123
Mar 30 2017 02:59
interesting
Joseph
@revisualize
Mar 30 2017 02:59
@MMK123 No.
Saboor Malik
@MathematicsCoding
Mar 30 2017 02:59
Naming a variable doesnt matter
Oh sorry I didnt see "when i call arr it will use var MyAss?"
Jordan
@PronetoPonder
Mar 30 2017 03:00
@MMK123 arr is a parameter of the function nextInLine(). testArr is defined later and then passed into the function via the arr parameter in the 2nd console.log() statement.
Joseph
@revisualize
Mar 30 2017 03:00
@MMK123 Look.. It is all about scope and context.

@MMK123 If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

Saboor Malik
@MathematicsCoding
Mar 30 2017 03:00
var myAss = 'hello';
return myAss;

Output will say 'hello'
Joseph
@revisualize
Mar 30 2017 03:01
@MMK123 I could do this:
var x = 39;
addThree(x);
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:01
Alright cya guys
Gotta do something else
Joseph
@revisualize
Mar 30 2017 03:02
The num variable in addThree doesn't need to be the same as the x variable in my global scope.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:02
Gtg
Manish Giri
@Manish-Giri
Mar 30 2017 03:02
:wave:
Joel
@MMK123
Mar 30 2017 03:02
fuck
i have an english degree... not mathematics...
Joseph
@revisualize
Mar 30 2017 03:02
@MMK123 So. This isn't mathematics
I have NO degree
In fact, I dropped out of high school 5 times
Joel
@MMK123
Mar 30 2017 03:03
damn dude
ok let me try again brb
Manish Giri
@Manish-Giri
Mar 30 2017 03:03
@MMK123 think of it this way - when you go to apple store to buy an iPhone, you'll probably look at the model on display first. Which is gonna be the same as the one you'll buy.
When you actually buy it, they're gonna break out a sealed box with the new phone, but the phone is essentially the same as the one you looked at.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:04
@revisualize Seriously?
How did you drop out HS 5 Times??
Joseph
@revisualize
Mar 30 2017 03:04
@MathematicsCoding I dropped out of High School 5 times and I have been homeless about the same number of times.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:04
Oh
Sorry to hear that
I wonder how you got to have that nice office by now..
Joseph
@revisualize
Mar 30 2017 03:05
@MathematicsCoding You drop out.. Then you go back. Then you drop out again. Then you go back . Then at the age of 23 you get your high school diploma.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:05
Yeah
Mostafa Hesham
@mhesham32
Mar 30 2017 03:05
help with that pls

// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}

// Change values below to test your code
abTest(2,2);
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:05
So you got high school diploma? or GED
Joseph
@revisualize
Mar 30 2017 03:05
Both.
I got my GED before I got the HSD
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:06
Nice
@MMK123 You dont need a mathematics degree to be better at programming...
You probably need to know like algebra/geometry but if the language is more advanced maybe a little higher than that?
Joel
@MMK123
Mar 30 2017 03:07

function nextInLine(arr, item) {
// Your code here
arr.push(6);
var nextInLine = arr.shift();

return item; // Change this line
}

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

Antwone McDuffie
@vatwon1308
Mar 30 2017 03:07
@revisualize Thanks. This was a very hard learned lesson
CamperBot
@camperbot
Mar 30 2017 03:07
vatwon1308 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3626 | @revisualize |http://www.freecodecamp.com/revisualize
Joel
@MMK123
Mar 30 2017 03:07
still no luck
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:08
@MMK123 did you change that line?
Joel
@MMK123
Mar 30 2017 03:08
i added push and shift
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:08
oooh
Joel
@MMK123
Mar 30 2017 03:08
idk what to change in the return item line
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:08
That challenge I remember....
Use .shift to remove first element itself then .push
I think to return the element that was removed
@MMK123 What is challenge name?
Tiffany
@tiffanymakes
Mar 30 2017 03:09
@MMK123 why are you pushing 6 into arr?
Joel
@MMK123
Mar 30 2017 03:09
stand in line
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:10
Let me check it out @MMK123
Joel
@MMK123
Mar 30 2017 03:10
@tiffanymakes bc idk how to tell it to add numbers infinitely
Domnomnomification
@Domnomnomification
Mar 30 2017 03:10
http://puu.sh/v2XLs/75b2a4a173.png
picture of the stand in line question
im currently on it as wel
Tiffany
@tiffanymakes
Mar 30 2017 03:10
@MMK123 the function already gives you the number, it's the item parameter, isn't it?
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:10
@MMK123 I will give you a hint
Joseph
@revisualize
Mar 30 2017 03:11
@Domnomnomification What doesn't help.. What is your code?
Domnomnomification
@Domnomnomification
Mar 30 2017 03:11
im listening in on @MathematicsCoding and @MMK123
Joel
@MMK123
Mar 30 2017 03:11
idk what item is = to
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:11
Never mind not a hint
Joseph
@revisualize
Mar 30 2017 03:11

Gist by revisualize / FreeCodeCamp - Stand in Line.js

// How do you add a number (item) to the end of an array (arr)? What does this method return?
// How do you remove the first element from an array (arr)? What does this method return?

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

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

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

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.

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

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

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

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

@MMK123 Let's do this.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:11
@MMK123 Just use .shift and .push
That is all you need
Joseph
@revisualize
Mar 30 2017 03:11
@MMK123 Can you work with me for a second?
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:12
Then how you return the element that was removed?
Joseph
@revisualize
Mar 30 2017 03:12
@MMK123 Ignore the lesson for a few minutes and work with me on something.
Joel
@MMK123
Mar 30 2017 03:12
@revisualize go ahead
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:12
@revisualize Ok I will give @MMK123 to you...
Bye...
Joseph
@revisualize
Mar 30 2017 03:12

@MMK123 If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

@MMK123 Let me know when you've read that.
@MMK123 I'm going to ask you a few questions.. Then I'm going to give you a second example.
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:13
function addThree (num) {
    var result;
    result = num + 3;
    return result;
}
addThree(10);

Result: 13 because 10+3
Just an easy code....
Joseph
@revisualize
Mar 30 2017 03:14
This message was deleted
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:14
Sorry I will go for real this time..
Joel
@MMK123
Mar 30 2017 03:14
ok go on
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:14
Bye guys...
Joel
@MMK123
Mar 30 2017 03:14
bye saboor
thanks for your help bud
Saboor Malik
@MathematicsCoding
Mar 30 2017 03:14
No problem
Joseph
@revisualize
Mar 30 2017 03:15
@MMK123 Okay. From that code above.. If I do addThree(30); what is the value of the parameter num?
Cory Bowles
@cbconsulting
Mar 30 2017 03:15

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 = 10;

myBike.getGear = function(change){
gear += change;
};
myBike.setGear = function() {
gear -= 5;

};

myBike.gearSet = function() {

return gear;

};

};

var myCar = new Car();

var myBike = new Bike();

Saboor Malik
@MathematicsCoding
Mar 30 2017 03:15
:runner:
Cory Bowles
@cbconsulting
Mar 30 2017 03:15
looking for help on this one
Joel
@MMK123
Mar 30 2017 03:16
it would be 30
Joseph
@revisualize
Mar 30 2017 03:16
@MMK123 Okay.. Again.. If I do addThree(55); what is the value of the parameter num?
Joel
@MMK123
Mar 30 2017 03:16
55
Tiffany
@tiffanymakes
Mar 30 2017 03:16
@truepalyer6 you don't need to accumulate the gear. Just make gear equal to change. Which challenge was this again? I don't remember the instructions.
Joseph
@revisualize
Mar 30 2017 03:16
@MMK123 Great. Let's make another function.
@MMK123 Let's try this one.
var myFunc (x, y) {}
Matthew
@IMDBLM
Mar 30 2017 03:17
Evening folks
Joseph
@revisualize
Mar 30 2017 03:18
@MMK123 If I do myFunc("b" , "e"); ... What is the value of the parameter x? And what is the value of the parameter y?
Cory Bowles
@cbconsulting
Mar 30 2017 03:18
@tiffanymakes its the bottom half that the required information be changed
Joel
@MMK123
Mar 30 2017 03:18
b = x
e = y
Joseph
@revisualize
Mar 30 2017 03:18
@MMK123 Backwards but, sure.
Cory Bowles
@cbconsulting
Mar 30 2017 03:18
@tiffanymakes The method getGear of myBike should be accessible outside the object.
The method setGear of myBike should be accessible outside the object.
myBike.gear should remain undefined.
myBike.getGear() should return 4 after calling myBike.setGear(4).
myBike.getGear() should return 3 after calling myBike.setGear(3).
myBike.getGear() should return 1 after calling myBike.setGear(1).
Joel
@MMK123
Mar 30 2017 03:19
whoops, but yes
Joseph
@revisualize
Mar 30 2017 03:19
@MMK123 Let's try with another function.
Joel
@MMK123
Mar 30 2017 03:19
ok
Joseph
@revisualize
Mar 30 2017 03:20

@MMK123 Let's try with this function:

function nextInLine(arr, item) { }

If I do nextInLine( ["a","b","c"] , "d");
What is the value of arr? And What is the value of item?

drinkwaterman
@drinkwaterman
Mar 30 2017 03:20
Hello people,
Do you think it is possible to be a data scientist using the tools learned on FCC after completing all the courses and challenges?
Cory Bowles
@cbconsulting
Mar 30 2017 03:21
@drinkwaterman it is a start
Joel
@MMK123
Mar 30 2017 03:21
arr = ["a", "b", "c"]
item = "d"
Tiffany
@tiffanymakes
Mar 30 2017 03:21
@truepalyer6 ah, I see. To getGear, just return the gear. To set it, you have to have a change parameter, and set the gear to the change, then return it.
Joseph
@revisualize
Mar 30 2017 03:22
@MMK123 Okay. Let's ask another question.
drinkwaterman
@drinkwaterman
Mar 30 2017 03:22
@truepalyer6 Mongo DB, JSON, javascript, visualization courses... I think this is a complete suit for a starter ? and I think statistics should be added as well.
Joseph
@revisualize
Mar 30 2017 03:22

@MMK123 If I do

var x = [7,6,5];
nextInLine( x , 3);

What is the value of arr?
What is the value of item?

Joel
@MMK123
Mar 30 2017 03:23
arr = [7,6,5]
item = 3
Joseph
@revisualize
Mar 30 2017 03:23
@MMK123 Do you see how all of this is stepping together?
Joel
@MMK123
Mar 30 2017 03:23
i think so
Cory Bowles
@cbconsulting
Mar 30 2017 03:24

@tiffanymakes To getGear, just return the gear. To set it, you have to have a change parameter, and set the gear to the change, then return it.
var Bike = function() {

// Only change code below this line.
var gear = 10;

myBike.getGear = function(change){
gear += change;
};
myBike.setGear = function() {
gear -= 5;

};

myBike.gearSet = function() {

return gear;

};

};

Joseph
@revisualize
Mar 30 2017 03:24
@MMK123 So, when you have a parameter like num way above. Or even arr and item ... You can use them just like any other variable inside of your function.
Cory Bowles
@cbconsulting
Mar 30 2017 03:24
@tiffanymakes when you say set . do you mean just a = sign
@tiffanymakes Also, i had this. before i changed it to myBike
Tiffany
@tiffanymakes
Mar 30 2017 03:25
@truepalyer6 I meant setGear.
Joel
@MMK123
Mar 30 2017 03:25
ok im going to go back and take a crack at it
Tiffany
@tiffanymakes
Mar 30 2017 03:26
@truepalyer6 you can use the this keyword in place of myBike.
Joseph
@revisualize
Mar 30 2017 03:26

@MMK123 You could even expand that as well.

function myFunc ( a , b , c , d , e , f ) { }

And you could do some crazy function call with a ton of parameters.

@MMK123
Gist by revisualize / FreeCodeCamp - Stand in Line.js

// How do you add a number (item) to the end of an array (arr)? What does this method return?
// How do you remove the first element from an array (arr)? What does this method return?

You're supposed to:
Write a function nextInLine which has two parameters
an array (arr) and a number (item).
That part has been done for you here:

function nextInLine(arr, item) { }

Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

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

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

You just need to add a number (item) to the end of an array (arr).
You also need to remove the first element from an array (arr).
But, there is another part of this challenge. You need to know What the methods that do those two things return.

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

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

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

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

Tiffany
@tiffanymakes
Mar 30 2017 03:27
@truepalyer6 like I said, you don't need to accumulate the gear change. Right now, for getGear, you are continuously adding the change to gear. You don't want that. You just want to return the gear variable.
Joseph
@revisualize
Mar 30 2017 03:27
I need to go.
Matthew
@IMDBLM
Mar 30 2017 03:28
Can anyone think of an example (or direct me somewhere) where it makes better sense to create an object with a constructor function vs. making just making an object?
Tiffany
@tiffanymakes
Mar 30 2017 03:28
@truepalyer6 you don't need the change parameter in your getGear since you already have the gear. You need the change parameter when you setGear. You're going to set the gear with change.
Manish Giri
@Manish-Giri
Mar 30 2017 03:29
@IMDBLM when you've got to setup a prototype to create 100 other objects from, each having a bunch of pre-defined properties.
Matthew
@IMDBLM
Mar 30 2017 03:29
Night @revisualize
@Manish-Giri Ok that makes sense. Thanks.
CamperBot
@camperbot
Mar 30 2017 03:30
imdblm sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 5003 | @manish-giri |http://www.freecodecamp.com/manish-giri
Cory Bowles
@cbconsulting
Mar 30 2017 03:31

@tiffanymakes
var Bike = function() {

// Only change code below this line.
var gear = 4;

this.getGear = function(){
gear -= 4;
};
this.setGear = function(change) {
gear += change;

};

this.gearSet = function() {

return gear;

};

};

so far
Joel
@MMK123
Mar 30 2017 03:32
@revisualize you're the man
@revisualize thanks for your help
CamperBot
@camperbot
Mar 30 2017 03:32
mmk123 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3627 | @revisualize |http://www.freecodecamp.com/revisualize
Tiffany
@tiffanymakes
Mar 30 2017 03:32
@truepalyer6 to getGear, you return the gear. Would you be okay with resetting your code?
Cory Bowles
@cbconsulting
Mar 30 2017 03:33
@tiffanymakes ok i finally got a number 4 to appear
KiingRex
@KiingRex
Mar 30 2017 03:34
Hello everyone, i'm on the return early pattern for functions challenge, i'd like to know how can i set up the abTest to input different numbers? the instructions does not say much about it
Tiffany
@tiffanymakes
Mar 30 2017 03:35
@truepalyer6 yes, but it's probably coincidental.
@truepalyer6 keep this.getGear and this.setGear. Don't create a new function.
Cory Bowles
@cbconsulting
Mar 30 2017 03:36

@tiffanymakes var Bike = function() {

// Only change code below this line.
var gear = 4;

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

};

};

@tiffanymakes believe me i truly appreciate your time.
Tiffany
@tiffanymakes
Mar 30 2017 03:38
@truepalyer6 Close! To set the gear, you don't need to compound the change. Just set the gear equal to the change.
Cory Bowles
@cbconsulting
Mar 30 2017 03:38
@tiffanymakes thank you!
CamperBot
@camperbot
Mar 30 2017 03:38
truepalyer6 sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
Tiffany
@tiffanymakes
Mar 30 2017 03:38
@truepalyer6 did it pass?
Cory Bowles
@cbconsulting
Mar 30 2017 03:39
@tiffanymakes yes
Tiffany
@tiffanymakes
Mar 30 2017 03:39
@truepalyer6 great, and do you understand the code?
Cory Bowles
@cbconsulting
Mar 30 2017 03:39
@tiffanymakes next time ill bring the crayons and kiddie table for our coding pop up book.
Tiffany
@tiffanymakes
Mar 30 2017 03:40
@truepalyer6 lol. But seriously, I want to make sure you actually understand the code.
Cory Bowles
@cbconsulting
Mar 30 2017 03:41
@tiffanymakes i see how by just setting var gear = 4; when return gives you back the variable
@tiffanymakes When i made the first function i thought the return once in place nothing below would been read
@tiffanymakes but because of our private and public scenario was going on was my confusion of basic concepts
Tiffany
@tiffanymakes
Mar 30 2017 03:46
@truepalyer6 the function you created would have been fine if it were the function name given by FCC. But for this challenge, it wasn't, so that's why it didn't work. FCC used myBike.getGear(). If it were your own code for another application, you can name the function whatever you want.
Cory Bowles
@cbconsulting
Mar 30 2017 03:47
@tiffanymakes yep, tight constraints. Thus, makes it alot more fun when you can go rogue and do what you want in your own compiler.
@tiffanymakes thanks a million
CamperBot
@camperbot
Mar 30 2017 03:47
:warning: truepalyer6 already gave tiffanymakes points
truepalyer6 sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
Tiffany
@tiffanymakes
Mar 30 2017 03:48
@truepalyer6 :thumbsup:
Cory Bowles
@cbconsulting
Mar 30 2017 03:48
@tiffanymakes look forward to asking future question as algorithm section is pending yours truly in near future.
Tiffany
@tiffanymakes
Mar 30 2017 03:50
@truepalyer6 I'd be more than happy to help! I enjoy the algorithm section.
Joseph
@revisualize
Mar 30 2017 03:50
@MMK123 Do things actually make sense now?\
Joel
@MMK123
Mar 30 2017 03:51
nope still stuck
Joseph
@revisualize
Mar 30 2017 03:51
@MMK123 What is the current state of your function?
Joel
@MMK123
Mar 30 2017 03:51

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

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

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

Joseph
@revisualize
Mar 30 2017 03:51
@MMK123 Okay. Not bad.
Joel
@MMK123
Mar 30 2017 03:51
im closer but no cigar
Joseph
@revisualize
Mar 30 2017 03:51
@MMK123 Let's cover a new topic.
Joel
@MMK123
Mar 30 2017 03:51
not sure what im missing
Joseph
@revisualize
Mar 30 2017 03:51
@MMK123 Ready?
Joel
@MMK123
Mar 30 2017 03:51
ok
Joseph
@revisualize
Mar 30 2017 03:52

@MMK123 Question:

function getName() { return "Happy Feet"; }
var name = getName();
console.log(name);

What do you think is output to the console when you log the variable name?
Why do you think that is? <-- this is actually the important question that needs to be answered.

Joel
@MMK123
Mar 30 2017 03:53
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var deleted = arr[0];
arr.shift();
return deleted; // Change this line
}
this one worked
Joseph
@revisualize
Mar 30 2017 03:53
@MMK123 That's fine. We'll fix it.
@MMK123 Let's look at the question I asked above.
TanukiTom
@TanukiTom
Mar 30 2017 03:54
Joseph
@revisualize
Mar 30 2017 03:54
@TanukiTom I can try. What is the current state of your function?
Joel
@MMK123
Mar 30 2017 03:55
ok go on
Joseph
@revisualize
Mar 30 2017 03:55
@MMK123 It was a question for you. I'm waiting for your answers.
Joel
@MMK123
Mar 30 2017 03:55
output is happy feet
Joseph
@revisualize
Mar 30 2017 03:55
@MMK123 Why?
Matthew
@IMDBLM
Mar 30 2017 03:55
I'm hung up on the 2nd go through of Make Object Properties Private. I can't figure out how to go about getting the gear.
var Bike = function() {

  // Only change code below this line.
var gear;

  this.getGear = function(){
    return myBike.setGear;

  };

  this.setGear = function(){


  };
};

var myCar = new Car();

var myBike = new Bike();
TanukiTom
@TanukiTom
Mar 30 2017 03:56
@revisualize I'll try to post what I have. Basically, I'm trying to figure out how to nest and if/else statement in a for statement where the "if" part will run multiple times before the "else"
Joel
@MMK123
Mar 30 2017 03:56
it's bc you gave the command to return "happy feet"
Joseph
@revisualize
Mar 30 2017 03:57
@MMK123 Okay. So, all functions return something.
Joel
@MMK123
Mar 30 2017 03:57
understood
Joseph
@revisualize
Mar 30 2017 03:57
@MMK123 It can return a value that you define
Or it will return the key word undefined
@MMK123 Methods are functions.
@MMK123 The shift() method removes the first element from an array and returns that element.
TanukiTom
@TanukiTom
Mar 30 2017 03:58
'''
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i < contacts.length; i++) {
if (firstName == contacts[i].firstName) {
for (p = 0; p < contacts[i].length; p++) {
if (prop == contacts[i][prop]) {
return contacts[i][prop];
} else {
return "No such property"; //I know this doesn't work
}
}
} else {
return "No such contact"; //This also doesn't work, but I think you see what I'm going for
}
}
}
'''
CamperBot
@camperbot
Mar 30 2017 03:58
:bulb: to format code use backticks! ``` more info
Joseph
@revisualize
Mar 30 2017 03:58
@MMK123 So, you could just have your function return what is returned from .shift()
Vamp
@the-vampiire
Mar 30 2017 03:58
Intermediate Algorithms: Wherefore Art Thou
Passing test cases 1 and 2. It appears to be passing the others (when I run it in my IDE) but it is saying the answer is wrong…? Any help?
function whatIsInAName(collection, source) {
    // What's in a name?
    var arr = [];
    // Only change code below this line

    for(var i = 0; i < collection.length; i++){
        if(collection[i][Object.keys(source)] === source[Object.keys(source)]){
            arr.push(collection[i]);
        }
    }

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

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

// returns: [ { a: 1, b: 2 }, { a: 1 }, { a: 1, b: 2, c: 2 } ]
// expected: [{ "a": 1, "b": 2 }, { "a": 1, "b": 2, "c": 2 }]
// ???
TanukiTom
@TanukiTom
Mar 30 2017 03:58
Sorry, can never get that formating to work in chat
Tiffany
@tiffanymakes
Mar 30 2017 03:58
@IMDBLM to get the gear, you would just return the gear variable in your getGear() function. But first, make the gear variable any value you want it to be.
Joel
@MMK123
Mar 30 2017 03:59
im with you
Joseph
@revisualize
Mar 30 2017 03:59
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName) {
      for (p = 0; p < contacts[i].length; p++) {
        if (prop == contacts[i][prop]) {
         return contacts[i][prop];
       } else {
         return "No such property"; //I know this doesn't work
       }
     }
   } else {
     return "No such contact"; //This also doesn't work, but I think you see what I'm going for
   }
  }
 }
@TanukiTom So, your loops will never loop.
TanukiTom
@TanukiTom
Mar 30 2017 03:59
@revisualize Yeah...basically I want to run the if statement on everything, then run the "else" statement if the statements didn't find anything on their loops
@revisualize I've been messing around with "return" statements, but I haven't really found how to do this.
Joseph
@revisualize
Mar 30 2017 04:00
@TanukiTom One problem that i see.. if (prop == contacts[i][prop]) { that logic isn't correct.
Joel
@MMK123
Mar 30 2017 04:00
@revisualize thanks again
CamperBot
@camperbot
Mar 30 2017 04:00
mmk123 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: mmk123 already gave revisualize points
Joel
@MMK123
Mar 30 2017 04:01
I will review this tomorrow. I need a lot of practive
practice*
TanukiTom
@TanukiTom
Mar 30 2017 04:01
@revisualize How do I use a argument (prop) to reference a javascript object?
Joseph
@revisualize
Mar 30 2017 04:02
@TanukiTom The instructions don't want you to compare prop to the object prop value.
@TanukiTom The instructions want you to see if the object HAS the PROPERTY with the key value of prop
tinla94
@tinla94
Mar 30 2017 04:03
hello
can someone pls help me with js?
hello
Joseph
@revisualize
Mar 30 2017 04:03
Hi.
tinla94
@tinla94
Mar 30 2017 04:03
hi jospeh
i am having some problem with this js
can u help me pls?
Joseph
@revisualize
Mar 30 2017 04:04
Hello @tinla94
TanukiTom
@TanukiTom
Mar 30 2017 04:04
@revisualize Oh. So maybe ".hasOwnProperty()"?
Joseph
@revisualize
Mar 30 2017 04:04
@tinla94 I don't know..
Matthew
@IMDBLM
Mar 30 2017 04:04
@tiffanymakes Sure but doesn't the gear need to be undefined so .setGear will set it first?
Joseph
@revisualize
Mar 30 2017 04:04
@TanukiTom :+1:
@TanukiTom I kind of did give a clue with some all capital letters.
tinla94
@tinla94
Mar 30 2017 04:04
how can send my problem for u guys to red
read*
Vamp
@the-vampiire
Mar 30 2017 04:04
‘''
Joseph
@revisualize
Mar 30 2017 04:04

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

TanukiTom
@TanukiTom
Mar 30 2017 04:05
@revisualize Yeah, that helped :smile:
Tiffany
@tiffanymakes
Mar 30 2017 04:05
@IMDBLM I guess it doesn't matter. What does your code look like now?
tinla94
@tinla94
Mar 30 2017 04:05
some problem from freecodecamp
Joseph
@revisualize
Mar 30 2017 04:05
@tinla94 You just tell us the name of the lesson and then we will ask you questions about how you're trying to solve the problem.
@tinla94 Part of asking questions may be asking you to show us your code bits.
TanukiTom
@TanukiTom
Mar 30 2017 04:06
@revisualize Don't I still have the problem with wanted to run something multiple times through an "if" statement before it gets pushed to the "else" statement?
Joseph
@revisualize
Mar 30 2017 04:06
@TanukiTom Fix that issue first.
@TanukiTom Show me what you got. Then we'll walk through the rest.
TanukiTom
@TanukiTom
Mar 30 2017 04:06
@revisualize Fix the .hasOwnProperty thing first?
Joseph
@revisualize
Mar 30 2017 04:06
Yes.
@TanukiTom And delete that p for loop thing.
tinla94
@tinla94
Mar 30 2017 04:07

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

result = myAdjective + myNoun + myVerb + myAdverb;
// Your code above this line
return result;
}

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

Joseph
@revisualize
Mar 30 2017 04:07
@tinla94 OH!
tinla94
@tinla94
Mar 30 2017 04:07
so bascially this is the code
Joseph
@revisualize
Mar 30 2017 04:07

@tinla94 Gist by revisualize / FreeCodeCamp - Word_Blanks.js
The function declaration was set up as... function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) giving the function name as wordBlanks and with four parameter of myNoun, myAdjective, myVerb and myAdverb.
There is more that I could go into (if you want I can) but, I'll sum it up with:
Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments).

Here's an example of this:

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

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

@tinla94 SeePeopleDon'tWriteLikeThis ... People tend to write like this with spaces between words.
You need spaces between your words
Traek Wells
@TraekWells
Mar 30 2017 04:08

Can anyone help me with Mutations: https://www.freecodecamp.com/challenges/mutations#?solution=%0Afunction%20mutation(arr)%20%7B%0A%20%20if%20(arr%5B0%5D.indexOf(arr%5B1%5D)%20%3D%3D%3D%20-1)%20%7B%0A%20%20%20%20return%20true%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20return%20false%3B%0A%20%20%7D%0A%7D%0A%0Amutation(%5B%22hello%22%2C%20%22hey%22%5D)%3B%0A

Here’s my code and I can’t figure out what’s wrong. I’m not getting any false returns


function mutation(arr) {
  if (arr[0].indexOf(arr[1]) === -1) {
    return true;
  } else {
    return false;
  }
}

mutation(["hello", "hey"]);
tinla94
@tinla94
Mar 30 2017 04:08
ohhhh i see
thnks so much lets me try out
Joseph
@revisualize
Mar 30 2017 04:09
@TanukiTom ?
Vamp
@the-vampiire
Mar 30 2017 04:11
@TraekWells wtf man clicking that link changed my own mutations solution...
TanukiTom
@TanukiTom
Mar 30 2017 04:11
@revisualize What is "?" for?
Vamp
@the-vampiire
Mar 30 2017 04:11
I can’t see how I did it now. It shows as complete on my map but when I run it it only shows your code with 3 failing test cases..
Joseph
@revisualize
Mar 30 2017 04:12
@TanukiTom Just chillin` waiting for someone to get me some code to helps them with.
About to watch some Casey Neistat on the Youtubes
Traek Wells
@TraekWells
Mar 30 2017 04:12
@the-vampiire sorry man, no idea why that happened. I’ve pasted a link to the challenge in here before and I don’t think that’s ever happened
Vamp
@the-vampiire
Mar 30 2017 04:13
I am very confused right now
TanukiTom
@TanukiTom
Mar 30 2017 04:13
@revisualize Okay. I'm trying to fix up my code based on the suggestion you gave me.
Tiffany
@tiffanymakes
Mar 30 2017 04:14
@the-vampiire if you go to https://www.freecodecamp.com/yourusername, you should be able to view your solutions. Or click on the top right corner where your "points" are.
@TraekWells what does it mean when .indexOf is equal to -1?
Vamp
@the-vampiire
Mar 30 2017 04:14
@tiffanymakes jesus okay
Ken Haduch
@khaduch
Mar 30 2017 04:14
@the-vampiire - if you don't submit that solution and just go back to your FCC home page, you should be able to reload your saved code
Vamp
@the-vampiire
Mar 30 2017 04:15
why the hell was it showing me his stuff when I look from my map??
I knew I hadn’t done it that way, that code is way too simple for that problem
Ken Haduch
@khaduch
Mar 30 2017 04:15
Just a temporary view because his URL loads his current code
Vamp
@the-vampiire
Mar 30 2017 04:16
no but I went to my own map and found the mutations problem from there
clicked it and it loaded his code
but yes it worked when I went to my profile and viewed solution
Tiffany
@tiffanymakes
Mar 30 2017 04:16
@the-vampiire Strange, I see what you mean; don't know why that happens.
CamperBot
@camperbot
Mar 30 2017 04:17
:bulb: to format code use backticks! ``` more info
Traek Wells
@TraekWells
Mar 30 2017 04:17
@tiffanymakes doesn’t that mean the first instance of whatever is in the .indexOf wasn’t found?
Vamp
@the-vampiire
Mar 30 2017 04:17
@TraekWells back to the problem here. first off you need a way to check if there are matches regardless of upper or lower case right? so build that into the function
Tiffany
@tiffanymakes
Mar 30 2017 04:17
@TraekWells right, so it shouldn't return true.
Traek Wells
@TraekWells
Mar 30 2017 04:18
lol yeah I guess that would make sense
smh
Vamp
@the-vampiire
Mar 30 2017 04:18
and yes tiffany is correct as well
Traek Wells
@TraekWells
Mar 30 2017 04:18
thanks for the tips
i guess it did seem a little too simple
Vamp
@the-vampiire
Mar 30 2017 04:18
your condition is returning something opposite of what you are expecting
@TraekWells also think about this loop you are performing. as it standts it appears you are checking whether the entire string ‘hey’ (denoted by arr[1]) has an index in the string ‘hello’ (denoted by arr[0])
err sorry you are not looping, just the condition
Jai Mitch
@jaimitch
Mar 30 2017 04:21

I'm having a hard time figuring out the spacing part, it think. Can anyone help, please?

myStr should have encoded text with the proper escape sequences and no spacing.

'''

var myStr = '\r"insert clever\"\\n"name here\"\';

'''

CamperBot
@camperbot
Mar 30 2017 04:21
:bulb: to format code use backticks! ``` more info
Vamp
@the-vampiire
Mar 30 2017 04:21
so 2 hints. 1 use a loop. 2 find a way to check EACH character in that target string right?
Frank
@FrankMusic
Mar 30 2017 04:21
function mutation(arr) {

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

    for(var j=0;j<arr[1].length;j++){
      if(arr[0].indexOf(i)==arr[1].indexOf(j)){

      }
    }

  }
  return arr;
}

mutation(["hello", "hey"]);
i have no idea..
Vamp
@the-vampiire
Mar 30 2017 04:22
@FrankMusic you are checking if arr[0] (‘hello’) has the same indexOf(i) (an iterating value from 0 to arr.length) as arr[1] (‘hey’) indexOf(j) (an interating value from 0 to arr.length)
@FrankMusic neither of these strings contain integers so this will not ever pass. secondly you are not performing any action based on the condition found in your loops! as your code looks now you passing (arr) into your function and then returing arr
TanukiTom
@TanukiTom
Mar 30 2017 04:24
@revisualize Fixed some stuff but still not working. How about this:
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName) {
      for (p = 0; p < contacts[i].length; p++) {
        if ( contacts[i].hasOwnProperty(prop) ) {
          return contacts[i][prop];
        } 
        return "No such property"; //I know this doesn't work
    }
    return "No such contact";
    }
  }
}
Vamp
@the-vampiire
Mar 30 2017 04:25
@FrankMusic look at the hints I gave to the guy above you who is working on the same problem…maybe you two should bounce ideas off each other
Vamp
@the-vampiire
Mar 30 2017 04:26
@TanukiTom think about something for a moment. Answer this question and you will get a lot of help. What happens when a return is reached during a loop?
TanukiTom
@TanukiTom
Mar 30 2017 04:26
@the-vampiire It exits the function?
Vamp
@the-vampiire
Mar 30 2017 04:26
yep
so lets do a test case mentally here
lets suppose you perform your first loop
and you do not pass any of the conditions you have set in the loop
and you reach this return ‘No such contact’
what will happen to your loop?
Frank
@FrankMusic
Mar 30 2017 04:27
@the-vampiire ok i'll try
Vamp
@the-vampiire
Mar 30 2017 04:27
will it proceed to check the next contact? or will the loop break?
Joseph
@revisualize
Mar 30 2017 04:29
@TanukiTom Okay.
@TanukiTom Let me make some corrections.
Vamp
@the-vampiire
Mar 30 2017 04:30
let me rephrase. if the contact you are looking for is not found in the first loop, meaning you hit return ‘No such contact’, will the loop break or will it continue onto the second and so forth iterations until it finds your contact?
TanukiTom
@TanukiTom
Mar 30 2017 04:30
@the-vampiire Was kinda thinking it would loop through everything it needed to before it moved on...but I guess not???
Vamp
@the-vampiire
Mar 30 2017 04:30
well you told me when a loop hits a return statement it exits the loop to return that statement, yes?
you were correct when you said this
Joseph
@revisualize
Mar 30 2017 04:31
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (firstName == contacts[i].firstName) {
        if ( contacts[i].hasOwnProperty(prop) ) {
          return contacts[i][prop];
        }  else {
          return "No such property";
        }
    }
  }
}
@TanukiTom ---^
Vamp
@the-vampiire
Mar 30 2017 04:31
so you should consider the placement of this return statement. should it be in your loop? where in the loop? should it be outside the loop? where outside?
Joseph
@revisualize
Mar 30 2017 04:32
@TanukiTom Let's say you were at a big business event and you're quite popular (with all those skills you have) throughout the event you got handed 200 business cards (Which will remain unordered). Now, I walk up to you at the end and ask you.. Do you have a Business Card for "Jane Smith"? Now you loop look through your stack of 200 business cards. When would you tell me that you didn't have a business card for Jane?
  // code before a for loop.
for (..........) {
  // Code inside of a for loop.
}
  // code after a for loop.
Vamp
@the-vampiire
Mar 30 2017 04:32
answer and I will help you. not trying to be difficult I promise when you answer it in words you will learn
TanukiTom
@TanukiTom
Mar 30 2017 04:32
@the-vampiire No...I understand. I'm just trying to wrap my head around it.
@revisualize After I read all 200 business cards?
Joseph
@revisualize
Mar 30 2017 04:33
@TanukiTom So, you're saying that after you loop look through all of the contacts cards in your array of object stack. That you'd tell me you don't have one for the individual?
TanukiTom
@TanukiTom
Mar 30 2017 04:35
@revisualize Yes
Joseph
@revisualize
Mar 30 2017 04:35
@TanukiTom Think about that as you look at this chat.
CamperBot
@camperbot
Mar 30 2017 04:36
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
:bulb: to format code use backticks! ``` more info
TanukiTom
@TanukiTom
Mar 30 2017 04:40
@revisualize Still thinking...
CamperBot
@camperbot
Mar 30 2017 04:41
:bulb: to format code use backticks! ``` more info
Vamp
@the-vampiire
Mar 30 2017 04:43
@TanukiTom the sooner you answer my question the sooner you will have your solution
not “i understand” if you write out your answer you will see your solution.
TanukiTom
@TanukiTom
Mar 30 2017 04:44
@the-vampiire The return statement has to be outside the loop, because otherwise the return statement will break the loop and it won't complete.
Vamp
@the-vampiire
Mar 30 2017 04:45
tadah
camperbot is losing its mind lol
TanukiTom
@TanukiTom
Mar 30 2017 04:46
@revisualize Looks I like I got it. Thanks
CamperBot
@camperbot
Mar 30 2017 04:46
tanukitom sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3628 | @revisualize |http://www.freecodecamp.com/revisualize
TanukiTom
@TanukiTom
Mar 30 2017 04:46
@the-vampiire Thanks to you too
Joseph
@revisualize
Mar 30 2017 04:46
@TanukiTom Did you solve the challenge?
Alestaire
@Alestaire
Mar 30 2017 04:46
Any body know what this means. I need you to refer help me with the wording. This assignment is in basic Javascript. Heres the directions: Assign the contents of a to variable b.
Joseph
@revisualize
Mar 30 2017 04:47
@Alestaire How do you assign the value of 7 to a variable num? ... var num = 7;
Now if you want you can use a variable to store values.
Like in mathmatics. num + 3 = 10 What is the value of num?
var x = num + 3; ... That outputs 10
So, you can do several things with variables. But, you need to understand that variables hold values and variables can be used with other variables.
So, how do you assign the value of 5 to a variable x? ... x = 5; (Which is also overwriting the previous value of 10 from above.
How do you assign the value of x to a variable y?
Look at the way things are written. var y = x;
How do you assign the value of 42 to a variable answer? ... What is the answer?
Variables hold values. Just understand that.
TanukiTom
@TanukiTom
Mar 30 2017 04:47
@revisualize Yeah. I can post the code if you want. I'm still mulling it over myself. I basically needed to figure out that the return "No such contact" had to be outside the loop.
Vamp
@the-vampiire
Mar 30 2017 04:47
var a = 1;
var b = ?
Austin White
@Aeolionx
Mar 30 2017 04:47
How would I do the last 2 lines just using a reduce and no filter?
function sumFibs(num) {
  var fib = [1];
  var next = 1;

  while(next <= num){
    fib.push(next);
    next = (fib[fib.length-1] + fib[fib.length-2]);
  }

  fib = fib.filter(val => val % 2 !== 0);
  return fib.reduce((a,b) => a+b);
}

sumFibs(75025);
Vamp
@the-vampiire
Mar 30 2017 04:47
@Alestaire can you assign a variable to another variable?
var a = 1;
how can I make var b = 1?
TanukiTom
@TanukiTom
Mar 30 2017 04:50
@revisualize One thing I want to check with you on:
function lookUpProfile(firstName, prop) {
// Only change code below this line 
  for (i = 0; i < contacts.length; i++) { 
    if (firstName == contacts[i].firstName) { 
      if ( contacts[i].hasOwnProperty(prop) ) { 
        return contacts[i][prop]; 
      } else { 
        return "No such property"; 
        } 
    }
  }
  return "No such contact";
}
@revisualize One of the reasons this works is because if "firstName != contacts[i].firstName" it doesn't go to the next nested if statement, therefore it won't hit the "else" statement and exit the loop before it is supposed to. Is that correct?
kerafyrm02
@kerafyrm02
Mar 30 2017 04:56
Who needs htlp?
*help
Vamp
@the-vampiire
Mar 30 2017 04:58
I do
kerafyrm02
@kerafyrm02
Mar 30 2017 04:58
Sure whats up?
Vamp
@the-vampiire
Mar 30 2017 05:00
have you done intermediate algorithms?
kerafyrm02
@kerafyrm02
Mar 30 2017 05:00
I know javascript., i don't do the exercises on this site.
Vamp
@the-vampiire
Mar 30 2017 05:00
stuck on Wherefore Art Thou. passing half the test cases. I dont need help so much with my code but more in understanding
you mind if i pm you?
kerafyrm02
@kerafyrm02
Mar 30 2017 05:01
Send me a PM with your code Patrick
Joseph
@revisualize
Mar 30 2017 05:04
@TanukiTom
// A lookUpProfile function that takes firstName 
// and a property (prop) as arguments has been pre-written for you.
function lookUpProfile(firstName, prop){
   for (var i=0; i < contacts.length; i++){
      // The function should check if firstName 
      // is an actual contact's firstName 
      if (contacts[i]["firstName"] == firstName) {
         // and the given property (prop) is a property of that contact.
         if(contacts[i].hasOwnProperty(prop)) {
             // If both are true, 
             // then return the "value" of that property.
             return contacts[i][prop]; 
          } else {
             // If prop does not correspond to any valid properties
             // then return "No such property".
             return "No such property";
          }
       }
   }
   // If firstName does not correspond to "any" contacts (key word is any)
   // then return "No such contact"
   return "No such contact";
}
Yasser Boone
@Angelus1st
Mar 30 2017 05:10
hi
i have problem with the lesson: "Stand in Line"
Yasser Boone
@Angelus1st
Mar 30 2017 05:15
somebody can help me please
Manish Giri
@Manish-Giri
Mar 30 2017 05:15
@Angelus1st what's the problem?
Yasser Boone
@Angelus1st
Mar 30 2017 05:15
i dont understand how resolve
can u give a tips
it say: Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
harsh754
@harsh754
Mar 30 2017 05:16
hello sir
Yasser Boone
@Angelus1st
Mar 30 2017 05:16

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

return item; // Change this line
}

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

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

harsh754
@harsh754
Mar 30 2017 05:16
i m a beginner
Manish Giri
@Manish-Giri
Mar 30 2017 05:16
@Angelus1st okay, your function gets two arguments - arr and item, yes?
Yasser Boone
@Angelus1st
Mar 30 2017 05:17
yes
Manish Giri
@Manish-Giri
Mar 30 2017 05:17
the first step is to add the number itemto the end of the array arr, use .push() for this.
the second and final step is to remove and return the first element from the array arr, use .shift()for this.
Yasser Boone
@Angelus1st
Mar 30 2017 05:18
will be: arr=[];
then arr.push(arr); yes?
sorry i mean: arr.push(item);
Manish Giri
@Manish-Giri
Mar 30 2017 05:19
why arr=[];?
harsh754
@harsh754
Mar 30 2017 05:19

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

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

// Change the inputs below to test your code
convertToF(30);
help me to convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86

Yasser Boone
@Angelus1st
Mar 30 2017 05:19
'cause arr is a array
but its empty
Manish Giri
@Manish-Giri
Mar 30 2017 05:20
why would it be empty
Yasser Boone
@Angelus1st
Mar 30 2017 05:20
so, with .push i add the item to the array or not?
Joseph
@revisualize
Mar 30 2017 05:21

@harsh754 There is the function declaration of function convertToF(celsius) { .. You have a function name of convertToF and a parameter of celsius
Parameters are used just like variables. So, inside of the function you can use celsius JUST like any other variable.
If I have this code:

function addThree (num) {
    var result;
    result = num + 3;
    return result;
}

So, when we make the function call of:

addThree(10);

You're calling the function addThree You're also passing a value 10 as an argument.
In the function declaration of function addThree (num) { You see that there is a parameter defined of num
When we do addThree(10) then the value of the parameter num is passed the argument value of ... 10
Then if you follow the code through.. result = num + 3; ... and we know the value of num is 10.
Therefore, if we follow through the function we end up with ... result = 10 + 3; then result = 13; then we return the result.

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

Yasser Boone
@Angelus1st
Mar 30 2017 05:21
ok , i can do this: arr = [1,2,3,4,5];
Joseph
@revisualize
Mar 30 2017 05:23
@Angelus1st Why?
Yasser Boone
@Angelus1st
Mar 30 2017 05:25
ok, i dont know, i need help
Joseph
@revisualize
Mar 30 2017 05:26
@Angelus1st Can you read that post taht I just made to @harsh754 above?
@Angelus1st Let me know when you're done. I have a few questions.
Jai Mitch
@jaimitch
Mar 30 2017 05:30
var myStr = '\n\"hello world\"\\\"insert clever\"\r"name here\"\\';
the last part of my instructions says I need myStr should have encoded text with the proper escape sequences and no spacing. I'm doing something wrong and I can't seem to figure it out.
Joseph
@revisualize
Mar 30 2017 05:30
@jaimitch That isn't the text that you're supposed to be using.
blob
@jaimitch You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline?
How do you escape a backslash?
How do you escape a carriage-return?
Jai Mitch
@jaimitch
Mar 30 2017 05:36
@revisualize Im still so confused.
@revisualize `var myStr = '"FirstLine"\\n"SecondLine\"\\r"ThirdLine\"'
Joseph
@revisualize
Mar 30 2017 05:37
@jaimitch How do you escape a backslash?
Look, I need to go to bed.

You have to assign 'FirstLine newline backslash SecondLine backslash carriage-return ThirdLine' to the variable myStr.
But, You have to replace the escape words with the proper escape sequences. (And per the instructions: remove all spaces.)
How do you escape a newline? With: \n
How do you escape a backslash? With: \\
How do you escape a carriage-return? With \r
So, you have break the problem down.
FirstLine newline backslash SecondLine backslash carriage-return ThirdLine
FirstLine \n backslash SecondLine backslashcarriage-return ThirdLine
FirstLine \n \\ SecondLine backslash carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ carriage-return ThirdLine
FirstLine \n \\ SecondLine \\ \r ThirdLine
You have to follow the instructions and remove all of the spaces
Then assign that to myStr as a string.

This lesson is not trying to teach you how to get some green check marks to pass onto the next lesson. It is trying to teach you a really valuable skill. If you have a string in JavaScript that is instantiated with double quotes (") (Example: var myStr = "Hello World";) you can also instantiate a string with single quotes (') (Example: var myStr = 'Hello World';)

How do you add a " to that string? Let's say you instantiated the string with double quotes and you want to put in a quote that someone said. You have to use an escape character.
Example: var myQuote = "Happy Feet said, \"I really like the rhythm.\"";
Or what happens if you want to add a tab to your string? You can't really add 3 spaces and expect it to show up as a tab. You have to use the escape character for a tab (\t).

OR let's say your trying to output a bunch of text and paragraphs within your JavaScript string. You can't really just make a bunch of variables.
var myParagraph1 = "a bunch of characters";
var myParagraph2 = "a bunch more characters";
I mean you could... but, why not just:
var myStr = "A bunch of characters/sentences.\nThe second paragraph of characters and sentences.";

@jaimitch --^^
Jai Mitch
@jaimitch
Mar 30 2017 05:39
@revisualize no problem, I've probably been looking at this too long myself. Thank you for trying to help.
CamperBot
@camperbot
Mar 30 2017 05:39
jaimitch sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3629 | @revisualize |http://www.freecodecamp.com/revisualize
Aaron Bell
@awb715
Mar 30 2017 05:47
@revisualize why no show today?
Joseph
@revisualize
Mar 30 2017 05:50
@awb715 No show?
To what?
@awb715 Look, if it isn't a Meetup.com, Eventbrite or Facebook Event... I don't know about it.
Aaron Bell
@awb715
Mar 30 2017 05:53
fcc cap hill meetup bro
Joseph
@revisualize
Mar 30 2017 05:53
Is it on Meetup.com?
Aaron Bell
@awb715
Mar 30 2017 05:54
no
its in the group
Joseph
@revisualize
Mar 30 2017 05:54
What group?
Aaron Bell
@awb715
Mar 30 2017 05:54
caphillcodecamp
gitter
Joseph
@revisualize
Mar 30 2017 05:55
@awb715 Look, if it isn't a Meetup.com, Eventbrite or Facebook Event... I don't know about it.
@awb715 If there isn't an actual event created. How am I supposed to know about it?
Aaron Bell
@awb715
Mar 30 2017 05:57
idk bra
Joseph
@revisualize
Mar 30 2017 05:57
@awb715 I can't plan my day around ... Hey, there might be this thing happening one of these days... .... ... ... Oh, We're doing that thing in 7 hours.
Miguel Vasquez
@mivasquez386
Mar 30 2017 05:57
hi all
got an API question
for the temperature, its over 290.6
how do we convert this data?
Markus Kiili
@Masd925
Mar 30 2017 06:01
@mivasquez386 Into what?
celsius?
Tiffany
@tiffanymakes
Mar 30 2017 06:02
@mivasquez386 the 290.6 degrees is in Kelvin. 273.15 Kelvin is equal to 0 degrees Celsius. You just add/subtract accordingly. And you know how to convert Celsius to Fahrenheit https://www.freecodecamp.com/challenges/convert-celsius-to-fahrenheit
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:04
i know how to convert Celsius to Fahrenheit..
@tiffanymakes that's what threw me off the whole Kelvin
Tiffany
@tiffanymakes
Mar 30 2017 06:05
@mivasquez386 Yeah, not the most commonly used temperature unit.
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:06
@tiffanymakes thank you. One step closer to finishing the stupid weather app so i can move on to the next project
CamperBot
@camperbot
Mar 30 2017 06:06
mivasquez386 sends brownie points to @tiffanymakes :sparkles: :thumbsup: :sparkles:
:cookie: 338 | @tiffanymakes |http://www.freecodecamp.com/tiffanymakes
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:06
the whole API and JSON was very vague in the course.
Tiffany
@tiffanymakes
Mar 30 2017 06:07
@mivasquez386 it is, that's why it's good to do your own reading on top of what FCC provides. They give a good road map for you to learn from.
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:08
@tiffanymakes I've done plenty of reading and now i'm finally playing around with JSON data.. practice makes perfect i guess.. ;)
Tiffany
@tiffanymakes
Mar 30 2017 06:10
@mivasquez386 I agree
Jor
@joreyesl
Mar 30 2017 06:20
@mivasquez386 i'd imagine there should be a way to request the temperature in a certain unit
yura712
@yura712
Mar 30 2017 06:22
Hello everyone! I need some help.
изображение.png
Jor
@joreyesl
Mar 30 2017 06:23
@yura712 you need to keep numbers, add 0-9 to your regex
yura712
@yura712
Mar 30 2017 06:24
Thanks a lot.
harsh754
@harsh754
Mar 30 2017 06:29
@revisualize thanks
Dan Couper
@DanCouper
Mar 30 2017 06:31
@joreyesl if it's the open weather API, it uses standard units for everything, so kelvin is the only thing you get, single value means less confusion + conversion's easy.
Jor
@joreyesl
Mar 30 2017 06:37
@DanCouper i believe you can use parameter unitsto request a different unit. Unless its a different open weather API I was looking at.
Dan Couper
@DanCouper
Mar 30 2017 06:38
Ah, i might be thinking of a different one
Javier Pons
@JavierPons
Mar 30 2017 06:38
hi guys! morning
Jor
@joreyesl
Mar 30 2017 06:41
@Alestaire += does both assignment and addition at the same time. In your code you have a = a += 1 you dont need to use both = and +=.
Ex: d = d + 1 I can use the short hand += to do instead, d += 1.
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 06:49
Anyone completed the "show local weather app" challenge in front-end development projects?
So, I got this url, "http://samples.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=b1b15e88fa797225412429c1c50c122a1" and it returns a page with json like information. I need to pass this as a file to $.getJSON(url,function(json){}); as variable 'json'. How do I do it?
Markus Kiili
@Masd925
Mar 30 2017 06:52
@Himujjal Just use parameter json inside the callback function. getJSON method parses the response automatically into a JS object.
Edward John
@eddmecha
Mar 30 2017 06:52
helo guys
var array = [1,2,3,4,5,6,7];
var newArray = [];

// Only change code below this line.

newArray = array.reverse(function(a , b) {
  return b - a;
});
where did i wrote wrong in the code above?
Markus Kiili
@Masd925
Mar 30 2017 06:53
@JLOSS1 .reverse() doesn't use any arguments. Just array.reverse()
Or did you mean to use reduce() ?
or sort() ?
Jim
@JLOSS1
Mar 30 2017 06:54
Yeah @eddmecha what @massdist said
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:54
@tiffanymakes i was able to add both Celsius and Fahrenheit and added Math.floor() to them.. :D
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 06:55
@Masd925 I tried it. But it is not returning anything. Can you please demonstrate this more ?
sunil
@usunil0
Mar 30 2017 06:55
can somebody help me with "random quote machine" project
Markus Kiili
@Masd925
Mar 30 2017 06:55
@Himujjal Check if there are any errors on browser developer tools console.
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 06:55
@usunil0 Yes,dude?
Markus Kiili
@Masd925
Mar 30 2017 06:56
@Himujjal Try console.log(JSON.stringify(json)); inside the callback.
sunil
@usunil0
Mar 30 2017 06:56
@Himujjal i want to work with the api,but dont know where to start
Miguel Vasquez
@mivasquez386
Mar 30 2017 06:56
@joreyesl i didn't see a way. It looks more like a raw data format in JSON
sunil
@usunil0
Mar 30 2017 06:56
i am going through so many articles
it will help you for sure. use json apis and ajax lessons to your help
@Masd925 Are you here for sometime now?
ZaCk FroST
@zakwanahmed
Mar 30 2017 06:59
need help
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 06:59
@Masd925 Let me try it
Markus Kiili
@Masd925
Mar 30 2017 06:59
@Himujjal Only 6 hours, sorry ;)
sunil
@usunil0
Mar 30 2017 07:00
@Himujjal thank you..
CamperBot
@camperbot
Mar 30 2017 07:00
usunil0 sends brownie points to @himujjal :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @himujjal |http://www.freecodecamp.com/himujjal
Jim
@JLOSS1
Mar 30 2017 07:01
wondering why my enter button might not be working for my wiki viewer project. anyone got a second?
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:01
@Masd925 THis is the message in my console. "Mixed Content: The page at 'https://codepen.io/himujjalupadhyaya/pen/RpqGrx' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?lat=28.7041&lon=77.1025&appid=2eb013b79d54ed7228c4938c05ca94a4'. This request has been blocked; the content must be served over HTTPS."
Markus Kiili
@Masd925
Mar 30 2017 07:02
@Himujjal Someone who has used openweather might know this. Try asking on the general channel if you get no help on that error here.
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:04
did you make the weather app?
Markus Kiili
@Masd925
Mar 30 2017 07:04
No.
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:05

<code>$(function() {

$('input[name="butAssignProd"]').click(function() {
alert('Hello...!');
});

//press enter on text area..

$('#txtSearchProdAssign').keypress(function(e) {
var key = e.which;
if (key == 13) // the enter key code
{
$('input[name = butAssignProd]').click();
return false;
}
});

});
<!DOCTYPE html>

<html>

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>

<body>
<textarea id="txtSearchProdAssign"></textarea>
<input type="text" name="butAssignProd" placeholder="click here">
</body>

</html></code>

@JLOSS1 Try this one above. it uses the enter key as a javascript event
@usunil0 welcome
Jim
@JLOSS1
Mar 30 2017 07:09
thanks @Himujjal I've tried that, still not quite working though.
CamperBot
@camperbot
Mar 30 2017 07:09
jloss1 sends brownie points to @himujjal :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @himujjal |http://www.freecodecamp.com/himujjal
Markus Kiili
@Masd925
Mar 30 2017 07:15
@JLOSS1 Why async:false ?
alik472
@alik472
Mar 30 2017 07:17
Hello, I need explanation for falsy bouncer challenge. I have been working for two days to solve this, and I did all kind of looping, if statement, and everything. And I could not solve it. It turns out it has a very simple solution. you just put the Boolean word inside the filter, and it returns something and the problem is solved. Can someone explain this to me?
Jim
@JLOSS1
Mar 30 2017 07:17
so the statement I'm calling has to complete before the next is called
loudnoyzez
@loudnoyzez
Mar 30 2017 07:18
hey guys and gals. not even sure how to start on this one...
Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Markus Kiili
@Masd925
Mar 30 2017 07:20
@alik472 Filter automatically iterates the array and passes each element into the callback function you provide (built-in Boolean function here), and keeps those elements that return true. Boolean returns true for truthy values. So arr.filter(Boolean) filters out falsy values.
Boolean is a function that coerces all values to type Boolean true/false. Falsy to false and truthy to true.
imo this is slightly stupid way to solve it because filter has automatic coercion to type Boolean. Passing in function(elem){return elem;} would be more logical. Passing in Boolean is like holding tweezers holding tweezers when doing something.
alik472
@alik472
Mar 30 2017 07:23
@Masd925 thx Markus for the explanation. I just didnt know that Boolean is a function. I created an array of false values, callback function and tried to do all kind of unnecessary stuff to get the answer. I think freecodecamp should give hint for this, because there is no way, a newbie can understand that Boolean word can be a function. Thx a lot anyways.
CamperBot
@camperbot
Mar 30 2017 07:23
alik472 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 3699 | @masd925 |http://www.freecodecamp.com/masd925
Dezix
@Dezix
Mar 30 2017 07:23
cant figure out what is wrong here
{
    "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(contacts[i].hasOwnProperty(prop)){
if(firstName===contacts[i].prop){
return contacts[i][prop];
}
else {
return "no such contact";
}
}
else
{
return "no such property";
}
}

// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

Markus Kiili
@Masd925
Mar 30 2017 07:23
@alik472 Also very simple way to test for a truthy value is if(val){...}. No reason to ever list out all the falsies.
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:24
@JLOSS1 dude, you forgot to put a '#' at the end in the $("#search").click();
@JLOSS1 its working now
Jim
@JLOSS1
Mar 30 2017 07:25
within the click event?
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:26
yeah
$("#searchTerm").keypress(function(e){
if(e.which==13){
$("#search").click();
      }
@JLOSS1 you forgot the #
Jim
@JLOSS1
Mar 30 2017 07:27
omg dude. thanks.... it's the small things sometimes...
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:27
@JLOSS1 can you help me with the weather app
Jim
@JLOSS1
Mar 30 2017 07:27
Thanks a million @Himujjal
CamperBot
@camperbot
Mar 30 2017 07:27
jloss1 sends brownie points to @himujjal :sparkles: :thumbsup: :sparkles:
:warning: jloss1 already gave himujjal points
Spyrantis Theodoros
@thodorisanta
Mar 30 2017 07:28
Can anyone guide me through the twich api project please :confused:
What should i do now?
http://codepen.io/oshikurou/pen/YZrqBy?editors=1011
Jim
@JLOSS1
Mar 30 2017 07:28
yeah, I should be able to. did you post ur pen earlier?
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:28
yeah
HN
@haydennorthcott
Mar 30 2017 07:28
Hi guys, I'm a little stuck on this challenge: Stand in Line
I've got no idea where to actually start... :(
alik472
@alik472
Mar 30 2017 07:28
@Masd925 i actually tried to figure out what can be a false value, but "" or zero didnt give me a false value when i tested it.
Dan Couper
@DanCouper
Mar 30 2017 07:29
@JLOSS1 don't use async:false
Jim
@JLOSS1
Mar 30 2017 07:29
@DanCouper should I be setting it to true? I thought the ajax should be loaded before everything else
@Himujjal what are you exactly having trouble with?
Dan Couper
@DanCouper
Mar 30 2017 07:30
sorry, didn't mean to post that :\
Jim
@JLOSS1
Mar 30 2017 07:30
@DanCouper no worries man
Markus Kiili
@Masd925
Mar 30 2017 07:30
@alik472 You can test for truthy/falsy by coercing them to type Boolean with Boolean function, or by testing with if(val){...}. If will fire for truthy values (anything but 0, false, NaN, "", null, undefined).
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:31
@JLOSS1 just help me get the required json file into the $.getJSON as an argument. I can't seem to work around with the file.
Dan Couper
@DanCouper
Mar 30 2017 07:31
got confused between a Slack chat and a Gitter chat
and typed in the wrong one
Jim
@JLOSS1
Mar 30 2017 07:31
@Himujjal just a second
@DanCouper gotcha
Dan Couper
@DanCouper
Mar 30 2017 07:32
oh, haha, but also looking at that, don't use async:false
It blocks everything
Doni Yafi
@yafiwebdev
Mar 30 2017 07:32
hey guys, need help with Chunky Monkey in basic algorithms
Markus Kiili
@Masd925
Mar 30 2017 07:32
@yafiwebdev Sure.
What have you done?
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:33
@JLOSS1 Please post your pen if you have used the $.getJSON function. I just have problems parsing the jsonp file.
Jim
@JLOSS1
Mar 30 2017 07:33
@DanCouper just read about how it's generally bad practice or something to set it false
Himujjal Upadhyaya
@Himujjal
Mar 30 2017 07:34
@JLOSS1 I am leaving for lunch actually
Jim
@JLOSS1
Mar 30 2017 07:34
@Himujjal alright here it is. I was trying to figure out what I did.
Dan Couper
@DanCouper
Mar 30 2017 07:34
@JLOSS1 AJAX stands for "Asynchronous JavaScript And XML", it's not really AJAX if it's synchronous: if you make it synchronous, everthing will stop until the response comes back - you don't generally ever want to do this
@DanCouper okay, that makes sense. Just figured id want to make sure it loaded first
Doni Yafi
@yafiwebdev
Mar 30 2017 07:36

the code wouldn't send with the markdown @Masd925 I know it's not pleasant like this, but anyway.

function chunkArrayInGroups(arr, size) {
// Break it up.

var newArr = [];

for (var i = 0; i < (arr.length / size); i++) {

for (var j = 0; j < size; j++) {

  newArr[i][j].push(arr.shift());
  arr.shift();

}

}
return newArr;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

Javier Pons
@JavierPons
Mar 30 2017 07:36
some help to understand more cleary this line: return args.indexOf(element) === -1; Is it that if the element it is not there (-1) doesn't return anything? And with this one: return arr.filter(function(element) return each element that is inside filter? {return args.indexOf(element) === -1; });
Doni Yafi
@yafiwebdev
Mar 30 2017 07:37
I googled and learned that I can't push values, coz the array is one-dimensional
Markus Kiili
@Masd925
Mar 30 2017 07:37
@yafiwebdev With two loop solution, you need to create the subarray, push numbers in it and push it to the result array.
@yafiwebdev Also make sure you don't loop too far.
Doni Yafi
@yafiwebdev
Mar 30 2017 07:38
it says cannot read property of "0" undefined
Jim
@JLOSS1
Mar 30 2017 07:39
tnx @DanCouper
CamperBot
@camperbot
Mar 30 2017 07:39
:cookie: 571 | @dancouper |http://www.freecodecamp.com/dancouper
jloss1 sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
Doni Yafi
@yafiwebdev
Mar 30 2017 07:39
I saw many questions on stackoverflow, and the answers were that columns and rows need to be added to make it two dimensional
@Masd925
Dan Couper
@DanCouper
Mar 30 2017 07:39
@JLOSS1 yeah, it seems to make sense when you first encounter it, but you find that it's extremely detrimental to users - it stops anyone doing anything on the page (for example, if you had a slow connection, the request to wikipedia could take ages, and then the page would be locked during that period). Synchronous requests are being deprecated steadily (have been for the past ~5ish years), I think there possibly should be an warning about it in the console
Jim
@JLOSS1
Mar 30 2017 07:40
@DanCouper I wonder why it's even still a 'thing' then lol
Markus Kiili
@Masd925
Mar 30 2017 07:40
@yafiwebdev Inside the i loop, you first need to create the subarray newArr[i]=[] and then push numbers in it.
You cannot push into something that is not an array.
Doni Yafi
@yafiwebdev
Mar 30 2017 07:41
@Masd925 so it's like this ?
newArr[i] = [];
newArr[i][j].push(arr.shift());
arr.shift();
Jim
@JLOSS1
Mar 30 2017 07:42
@DanCouper seems to me there would be a work around? maybe not. i'm still quite new to coding...clearly...