8th
May 2017
jatinkapila
@jatinkapila
May 08 2017 00:00
concatenation
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:00
@jatinkapila why the comma and the period
jatinkapila
@jatinkapila
May 08 2017 00:00
error mystr
May 08 2017 00:00
@jatinkapila - what are the instructions - they give very specific things to concatenate - capitalization is important, too!
jatinkapila
@jatinkapila
May 08 2017 00:00
okk i did tht also strill nt workijng sir
okk
May 08 2017 00:02
@jatinkapila - you have to have one space between the two sentences - best to copy and paste the quoted strings from the instructions...
jatinkapila
@jatinkapila
May 08 2017 00:02
my code is var myStr = 'This is the start. ' + ' This is the end.';
Stephen James
@sjames1958gm
May 08 2017 00:02
@jatinkapila And the second string has an extra space to start.
Jason Luboff
@JLuboff
May 08 2017 00:02
@sjames1958gm You beat me to it
jatinkapila
@jatinkapila
May 08 2017 00:02
eror is myStr should have a value of This is the start. This is the end.
Stephen James
@sjames1958gm
May 08 2017 00:03
@jatinkapila If you copy the strings "This is the start. " "This is the end." including the quotes - then no problems
jatinkapila
@jatinkapila
May 08 2017 00:03
idid the space also sir
Stephen James
@sjames1958gm
May 08 2017 00:04
@jatinkapila You have start.<space><space>This the strings in the instructions have start.<space>This
jatinkapila
@jatinkapila
May 08 2017 00:06
again my code is myStr="This is the start. " + " This is the end.";
error is myStr should have a value of This is the start. This is the end.
May 08 2017 00:07
@jatinkapila - remove the extra space at the start of the string " This is the end." so that it is "This is the end."
Jason Luboff
@JLuboff
May 08 2017 00:07
@jatinkapila You need to remove the space in front of This of the second sentence as @sjames1958gm pointed out
nsonhouse
@nsonhouse
May 08 2017 00:07
Good evening all.
PhoenixFarhan
@PhoenixFarhan
May 08 2017 00:07
Hi, For the card counting challenge, does anyone know if you have to create your own random card generator..
Stephen James
@sjames1958gm
May 08 2017 00:07
@nsonhouse :wave:
May 08 2017 00:07
@PhoenixFarhan - no, they pass a sequence of card values to you, your code just has to deal with those. Run the tests once, and you'll see what the test patterns are.
jatinkapila
@jatinkapila
May 08 2017 00:08
okk done nw woooo sir thnx stephen james & all
thnx luboff
i have one more issues
PhoenixFarhan
@PhoenixFarhan
May 08 2017 00:09
CamperBot
@camperbot
May 08 2017 00:09
phoenixfarhan sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
nsonhouse
@nsonhouse
May 08 2017 00:09

function checkInventory( itemid, qty){
connection.query('SELECT * FROM products WHERE item_id = ' + itemid, function(err, res){

});

}

Jason Luboff
@JLuboff
May 08 2017 00:09
Looks like some SQL
nsonhouse
@nsonhouse
May 08 2017 00:09
Yes sir
jatinkapila
@jatinkapila
May 08 2017 00:10

var x= 35;

var a=prompt("enter ur age: ");
var y=a;
var z= x + y;
console.log(y);
console.log(x);
console.log(z);
my result is in console z as 3535 m nt getting the addion in age

nsonhouse
@nsonhouse
May 08 2017 00:10
Im trying to throw an error if the itemID is not in the DB
I know this is connected to res, but not sure how to handle this
jatinkapila
@jatinkapila
May 08 2017 00:10
George
@Yumri
May 08 2017 00:11

Evening everyone, I have a question about the Iterate Over Arrays with Map challenge, specifically the placement of the last parenthesis:

var newArray = oldArray.map(function(val) {
return val +3;

} ) ;

why is it after the curly brace and not at the end of the function, like this:
(function(val))?

HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:12
@Yumri the curly braces are the callback function's block
nsonhouse
@nsonhouse
May 08 2017 00:12
@JLuboff @nsonhouse
Im trying to throw an error if the itemID is not in the DB
I know this is connected to res, but not sure how to handle this
Jason Luboff
@JLuboff
May 08 2017 00:12
@nsonhouse Does it throw an error if no data is found?
Keon Samuel
@keonsam
May 08 2017 00:12
@jatinkapila prompt probably returning a string
Stephen James
@sjames1958gm
May 08 2017 00:12
@jatinkapila a is a string
35 + "35"
"3535"
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:12
the callback function is an argument of the map method
Stephen James
@sjames1958gm
May 08 2017 00:12
@jatinkapila if you do y = +a it will try to convert a to a number
@Yumri oldArray.map(function(){}); it has to be after the whole function
Manny
@Alloffices
May 08 2017 00:14
Took a break and finally got it to pass - did I get it right?
function truncateString(str, num) {
// Clear out that junk in your trunk
var trunK = str.slice(0, num);
var trunKdots = str.slice(0, num) + "...";
var trunKdotsMinus = str.slice(0, num - 3) + "...";

if (num >= str.length) {
return str;
} else if (num >= 3) {
return str.slice(0, num - 3) + "...";
} else {
return trunKdots;
}
}
//  there are 3 cases u need to handle..
// when num <= str.length
// when num > str.length AND num >3
// when num > str.length AND num <= 3

truncateString("A-tisket a-tasket A green and yellow basket", 11);
George
@Yumri
May 08 2017 00:14
@HeebieGeeBee ok i think I understand, is this setup unique to map or is it common with other methords?
nsonhouse
@nsonhouse
May 08 2017 00:14
@JLuboff On a console.log(res), my output is [] if the itemID is invalid
Stephen James
@sjames1958gm
May 08 2017 00:15
@Alloffices Yes, maybe more variables than you really need.
jatinkapila
@jatinkapila
May 08 2017 00:15
yah thnx stephen sir i forgot m getting string and javascript is dynaic typing
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:15
@Yumri its common for methods to have acallback function for an argument
jatinkapila
@jatinkapila
May 08 2017 00:15
thnx stephen sir
Stephen James
@sjames1958gm
May 08 2017 00:15
@jatinkapila :+1:
Jason Luboff
@JLuboff
May 08 2017 00:15
@nsonhouse Ok so something like
if(!res) {
} else {
console.log(res);
}
George
@Yumri
May 08 2017 00:16
@HeebieGeeBee no sorry, I meant the final parenthesis being after the curly brace, I cannot recall ever having to put it in that position up until this challenge - hence the reason why it threw me off
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:16
@Yumri all methods have an opening and closing parenthesis
@Yumri i think youre misunderstanding what youre doing with the callback
Manny
@Alloffices
May 08 2017 00:17
@sjames1958gm yea I forgot to remove them from earlier - ty
CamperBot
@camperbot
May 08 2017 00:17
alloffices sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7171 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
George
@Yumri
May 08 2017 00:17
Up until now if i am writing a function its like:
function xyc (para 1, para 2) {
return whatever;
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:17
youre just placing an anonymous fucntion inside the map's parenthesis'
nsonhouse
@nsonhouse
May 08 2017 00:18
@JLuboff It returned an empty array again. []
George
@Yumri
May 08 2017 00:18
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:18
@Yumri yes thats a function, and in the map youre giving the map method an arugment of a function
Fikry
@Fikry1
May 08 2017 00:19
var Bike = function() {

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

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

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

};
Jason Luboff
@JLuboff
May 08 2017 00:19

@nsonhouse Ah.....try

if (!res.length){ ...

If length is 0, that should than return true

Fikry
@Fikry1
May 08 2017 00:19
what's wrong ?
Jason Luboff
@JLuboff
May 08 2017 00:19
@OneOFAkinn Your set gear should be modifying gear not returning anything
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:20
arr.map(  function() {}  ) // this is giving the map method an argumetn of a function
@Yumri
nsonhouse
@nsonhouse
May 08 2017 00:20
@JLuboff The res is just going to store the data from the SQL query. How do I check whether or not the value is in the DB.TABLE?
George
@Yumri
May 08 2017 00:20
@HeebieGeeBee ahh ok, it finally clicked, i see what you mean now
thanks @HeebieGeeBee
CamperBot
@camperbot
May 08 2017 00:20
yumri sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1592 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Jason Luboff
@JLuboff
May 08 2017 00:20
@nsonhouse Well if you aren't getting any results back, wouldn't that indicate the value is not in the table?
Fikry
@Fikry1
May 08 2017 00:21
what you mean by modifying ?
nsonhouse
@nsonhouse
May 08 2017 00:21
@JLuboff That worked
Jason Luboff
@JLuboff
May 08 2017 00:21
@nsonhouse :+1:
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:22
@OneOFAkinn giving it a new value
nsonhouse
@nsonhouse
May 08 2017 00:22
@JLuboff Thank you
CamperBot
@camperbot
May 08 2017 00:22
nsonhouse sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1697 | @jluboff |http://www.freecodecamp.com/jluboff
Fikry
@Fikry1
May 08 2017 00:24
@HeebieGeeBee i don't get it
Jason Luboff
@JLuboff
May 08 2017 00:25
@OneOFAkinn Look at the example, I believe the accelerate function. Your setgear function should be similar, but instead of adding , it should be assigning
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:26
these are an example of setters and getters, you make setter functions to set values and you make getter fucntiosn to get values
inside of constructors
so in other words with a set function, you want to assign a value in some way to something, and with a get function, you want some kind of value returned to you
Fikry
@Fikry1
May 08 2017 00:29
Now try it yourself! Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.
var Bike = function() {

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

this.getGear=function(){

};

this.setGear=function(){

};

};
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:30
@OneOFAkinn so how would you make the getGear function return the gear variable?
Fikry
@Fikry1
May 08 2017 00:31
ar Bike = function() {

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

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

this.setGear=function(){

};

};
HeebieGeeBee
@HeebieGeeBee
May 08 2017 00:32
yes, now how would you make the setGear function set the value of the gear value
Niels3030
@niels3030
May 08 2017 00:32
F*&%$! JS!! HeebieGeeBee @HeebieGeeBee May 08 2017 00:32 as a hint youre going to need to give your setGear function a parameter @OneOFAkinn @niels3030 understood PhoenixFarhan @PhoenixFarhan May 08 2017 00:33 Hi again, this is my counting card program, it works.. but i cant figure out how to get the output to the specifications of the challenge var count = 0; function cc(card) { // Only change code below this line switch (card) { case 2: case 3: case 4: case 5: case 6: count++; break; case 7: case 8: case 9: count = count; break; case 10: case 'J': case 'Q': case 'K': case 'A': count--; } if (count > 0) { count, " Bet"; } else if (count <=0) { count, " Hold"; } return; // Only change code above this line } Fikry @Fikry1 May 08 2017 00:33 @HeebieGeeBee and that pramaeter should = gear ?? HeebieGeeBee @HeebieGeeBee May 08 2017 00:33 @OneOFAkinn no it shouldnt @PhoenixFarhan count + .... Niels3030 @niels3030 May 08 2017 00:34 Right? One space " Hold"; was holding me up.... got it though @HeebieGeeBee Nahuel Ovejero @NahuelOvejero May 08 2017 00:34 @PhoenixFarhan look what you have to return Fikry @Fikry1 May 08 2017 00:34 @HeebieGeeBee what you mean by set value to gear ?? Nahuel Ovejero @NahuelOvejero May 08 2017 00:34 @PhoenixFarhan you need to return the counter also Fikry @Fikry1 May 08 2017 00:34 @OneOFAkinn give i a vlaue ? HeebieGeeBee @HeebieGeeBee May 08 2017 00:34 @OneOFAkinn assign gear a value Fikry @Fikry1 May 08 2017 00:34 @HeebieGeeBee any value i want ?? PhoenixFarhan @PhoenixFarhan May 08 2017 00:35 @NahuelOvejero I did but i just dont know how embed the if and else if in to the return statement HeebieGeeBee @HeebieGeeBee May 08 2017 00:35 @OneOFAkinn you should be assigning it the parameter of the function PhoenixFarhan @PhoenixFarhan May 08 2017 00:36 Thanks @NahuelOvejero .. haha good advice.. i just declared the count and the concatenation a new variable and returned that variable CamperBot @camperbot May 08 2017 00:36 phoenixfarhan sends brownie points to @nahuelovejero :sparkles: :thumbsup: :sparkles: :cookie: 351 | @nahuelovejero |http://www.freecodecamp.com/nahuelovejero Fikry @Fikry1 May 08 2017 00:36 ar Bike = function() { // Only change code below this line. var gear; this.getGear=function(){ return gear; }; this.setGear=function(gear){ }; }; HeebieGeeBee @HeebieGeeBee May 08 2017 00:37 @PhoenixFarhan if (something) {return this} else {return this} Nahuel Ovejero @NahuelOvejero May 08 2017 00:37 @PhoenixFarhan you also saying count , "hold" HeebieGeeBee @HeebieGeeBee May 08 2017 00:37 @OneOFAkinn gear should not be the parameter gear is a variable you want to assign the parameter Nahuel Ovejero @NahuelOvejero May 08 2017 00:37 @PhoenixFarhan no idea what are you doing there, need to assign it if you are seeking that. But I would preffer to use return count + " Hold" ... for example Nick Forlivio @whackdev May 08 2017 00:38 @OneOFAkinn and you need your setgear method to set the gear Fikry @Fikry1 May 08 2017 00:38 @HeebieGeeBee i don't understand what this cod should do ?? HeebieGeeBee @HeebieGeeBee May 08 2017 00:39 @OneOFAkinn if you had a variable of newGear who would you assign that to the gear variable Fikry @Fikry1 May 08 2017 00:39 gear = newGear; HeebieGeeBee @HeebieGeeBee May 08 2017 00:40 yes thats what your setter should do but newGear isnt a variable you need to declare it as a parameter for the function DistinctWolf @DistinctWolf May 08 2017 00:40 how do you refer to true and false value and true and false with quotes Fikry @Fikry1 May 08 2017 00:41 var Bike = function() { // Only change code below this line. var gear; this.getGear=function(){ return gear; }; this.setGear=function(myGear){ gear = myGear; }; }; @HeebieGeeBee thanks CamperBot @camperbot May 08 2017 00:41 oneofakinn sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles: :star2: 1593 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee HeebieGeeBee @HeebieGeeBee May 08 2017 00:41 @OneOFAkinn well done @FlashHero whats the meant to mean? Nick Forlivio @whackdev May 08 2017 00:42 @FlashHero are you trying to differeniate between the defined vales of true and false and the strings 'true' and 'false'? DistinctWolf @DistinctWolf May 08 2017 00:42 yes Nick Forlivio @whackdev May 08 2017 00:42 @FlashHero what are you trying to do? DistinctWolf @DistinctWolf May 08 2017 00:43 true and false without quotes return false for some reason Nick Forlivio @whackdev May 08 2017 00:43 can you show me the code you are using? DistinctWolf @DistinctWolf May 08 2017 00:45  function booWho(bool) { if(bool !== null || bool!==undefined){ return true; } } booWho(null); Nick Forlivio @whackdev May 08 2017 00:46 @FlashHero that should return false Jason Luboff @JLuboff May 08 2017 00:46 @FlashHero Why not use typeof? Nick Forlivio @whackdev May 08 2017 00:46 @JLuboff what markdown did you use for typeOf? DistinctWolf @DistinctWolf May 08 2017 00:46 oh yeah i meant false Stephen James @sjames1958gm May 08 2017 00:47 @FlashHero You should compare to true or false - if you don't use typeof Jason Luboff @JLuboff May 08 2017 00:47 @whackdev Just  text  Nick Forlivio @whackdev May 08 2017 00:47 @JLuboff thanks! CamperBot @camperbot May 08 2017 00:47 whackdev sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles: :star2: 1698 | @jluboff |http://www.freecodecamp.com/jluboff Stephen James @sjames1958gm May 08 2017 00:50 @FlashHero true and false are the two boolean primitives. So booWho should return true if bool is equal to one of these Nick Forlivio @whackdev May 08 2017 00:50 @FlashHero you should use === when comparing bools too Stephen James @sjames1958gm May 08 2017 00:52 @whackdev :+1: DistinctWolf @DistinctWolf May 08 2017 00:54 so no matter what bool equals true or false the result should be true Cybercyrill @cybercyrill May 08 2017 00:54 function translatePigLatin(str) { var v = ['a','e','i','o','u']; for (var i=0; i < str.length; i++){ for (var j=0; j < v.length;j++){ if (str[i]==v[j]) if (v[j] == str[0]) return str + "way"; else return str.substr(str.indexOf(v[j]), str.length) + str.substr(0, str.indexOf(v[j])) + "ay"; } } } translatePigLatin("consonant"); Hello guys, do u have any tips to make it shorter\better? Nick Forlivio @whackdev May 08 2017 00:55 @FlashHero if you want it to equal the value of the bool you are passing to it it should change, if you are testing that it is one or the other both will return true. Which are you trying? DistinctWolf @DistinctWolf May 08 2017 00:57 i have no idea what i'm doing I thought I knew what booleans were but struggling Stephen James @sjames1958gm May 08 2017 01:01 @cybercyrill I used a regex that matched leading consonants, then used the size of the match to slice. function translate(str) { var prefix = str.match(/^[^aeiou]*/); if (prefix[0].length === 0) { return str + "way"; } else { return str.slice(prefix[0].length) + prefix[0] + "ay"; } } Nick Forlivio @whackdev May 08 2017 01:02 @FlashHero function whoBool(bool) { if (bool === null || undefined) { return "invalid value"; } else if (bool === true) { return true; } else { return false; } } Stephen James @sjames1958gm May 08 2017 01:02 @FlashHero Yes if bool equals true OR bool equals false return true that almost looks like code. @FlashHero return bool === true || bool === false; dyon3334 @dyon3334 May 08 2017 01:04 can anyone tell me what im doing wrong ? Stephen James @sjames1958gm May 08 2017 01:04 @dyon3334 We excel at that here :) DistinctWolf @DistinctWolf May 08 2017 01:04 oh thanks @whackdev @sjames1958gm CamperBot @camperbot May 08 2017 01:04 flashhero sends brownie points to @whackdev and @sjames1958gm :sparkles: :thumbsup: :sparkles: :cookie: 264 | @whackdev |http://www.freecodecamp.com/whackdev :star2: 7172 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm dyon3334 @dyon3334 May 08 2017 01:04 <script> var 1= 0; var name = "joe"; while (i<2) { document.write("Happy Birthday to you.<br>"); i = i + 1; document.write("Happy Birthday dear " + name + ",<br>"); } </script> @sjames1958gm thanks CamperBot @camperbot May 08 2017 01:05 dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7173 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm May 08 2017 01:05 @dyon3334 var 1 = 0 ? maybe var i = 0 dyon3334 @dyon3334 May 08 2017 01:05 thanks hahah but still not running right Stephen James @sjames1958gm May 08 2017 01:06 @dyon3334 Are you getting both twice instead of just the first? Find where your while loop ends. dyon3334 @dyon3334 May 08 2017 01:06 this is now my output }//]]> Happy Birthday to you Happy Birthday to you Happy Birthday to you happy birthday dear john happy birthday to you is the ouput i need Stephen James @sjames1958gm May 08 2017 01:08 @dyon3334 Looking at it I see. Happy Birthday to you happy birthday dear joe Happy Birthday to you happy birthday dear joe @sjames1958gm Do you see where the end of the while loop is? dyon3334 @dyon3334 May 08 2017 01:10 oh yes me to but it need to two times happy birthday to you then happy birthday to you dear joe then 1 time happy birthday to you Stephen James @sjames1958gm May 08 2017 01:11 @dyon3334 Your } closing the while loop is after the second document.write dyon3334 @dyon3334 May 08 2017 01:12 /<script> var i= 0; var name = "joe"; while (i<2) { document.write("Happy Birthday to you.<br>"); i = i + 1; document.write("Happy Birthday dear " + name + ",<br>"); } </script>/ yes can you give me the right example Stephen James @sjames1958gm May 08 2017 01:15 @dyon3334 Move the } to right after i = i + 1; @dyon3334 If you write the code with line breaks then you would see it easier. while (i<2) { document.write("Happy Birthday to you.<br>"); i = i + 1; } document.write("Happy Birthday dear " + name + ",<br>"); dyon3334 @dyon3334 May 08 2017 01:16 @sjames1958gm TTHanks a lot !! CamperBot @camperbot May 08 2017 01:16 dyon3334 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :warning: dyon3334 already gave sjames1958gm points Stephen James @sjames1958gm May 08 2017 01:18 @dyon3334 :+1: Julio Akiyama @julioakiyama May 08 2017 01:31 var code = "formatted"; Sorthes @Sorthes May 08 2017 01:50 hey guys, im in challenge 140 and I just can't wrap my head around this problem... I'm supposed to set a solution from scratch in where I convert celsius to fahrenheit... I just don't see where i'm wrong and if I could send you my history of resetted code I would, but i can't. here are two examples: function convertToF(celsius) { var fahrenheit; // Only change code below this line celsius = convertToF; celsius /= 9 * 5; celsius = fahrenheit; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(-30); and then we have: function convertToF(celsius) { var fahrenheit; // Only change code below this line fahrenheit = convertToF * 9 / 5 + 32; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(-30); cameron @whoopswoop May 08 2017 01:56 Fahrenheit = Celsius * 9/5 + 32; @Sorthes Mohamed Derhalli @derhallim May 08 2017 01:56 came to say hi @JLuboff @sjames1958gm :v: @HeebieGeeBee :v: cameron @whoopswoop May 08 2017 01:57 im trying to concatenate a couple strings and have this; whats wrong with it? : var myStr = "This is the first sentance. "; myStr += "This is the second sentance."; Stephen James @sjames1958gm May 08 2017 01:57 @Sorthes celsius is the parameter to the function - and contains the value to be converted each time the function is called. @whoopswoop sentence is spelled sentence - @derhallim :wave: Mohamed Derhalli @derhallim May 08 2017 01:59 what IDE/text editor do u use @sjames1958gm ? Stephen James @sjames1958gm May 08 2017 01:59 @derhallim vs code Mohamed Derhalli @derhallim May 08 2017 02:00 for all projects? Sorthes @Sorthes May 08 2017 02:01 @sjames1958gm thanks for the explanation brother! CamperBot @camperbot May 08 2017 02:01 sorthes sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7174 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm May 08 2017 02:01 @Sorthes :+1: Sorthes @Sorthes May 08 2017 02:01 @whoopswoop thank you, cant believe i didnt see it CamperBot @camperbot May 08 2017 02:01 sorthes sends brownie points to @whoopswoop :sparkles: :thumbsup: :sparkles: :cookie: 151 | @whoopswoop |http://www.freecodecamp.com/whoopswoop Stephen James @sjames1958gm May 08 2017 02:02 @derhallim Well, I have been using cloud9 a lot because I can work on stuff at home and at work. Mohamed Derhalli @derhallim May 08 2017 02:02 oh ok people in the main chat, like most of them use emacs or vims.. once I said: use vscode/sublime .. I was like 1 v 5 :O Sorthes @Sorthes May 08 2017 02:03 guys another question, should I use codepen or should I familiarize myself with something that I can run offline in my computer? like brackets Stephen James @sjames1958gm May 08 2017 02:03 @derhallim I have 39 cloud9 workspaces now ;) Sorthes @Sorthes May 08 2017 02:03 when coding on my own so to speak Mohamed Derhalli @derhallim May 08 2017 02:03 they were like; u will be more efficient with emacs etc.. etc.. @sjames1958gm that's cool @Sorthes yeah that's gd Brackets is an awesome editor Stephen James @sjames1958gm May 08 2017 02:04 @derhallim I don't agree I have used vim and emacs and vs code - if you are a power user on emacs, maybe but the newer tools are much better. Mohamed Derhalli @derhallim May 08 2017 02:04 but why would I wanna go use emacs, and when I wanna save a file click :w instead of control -command S Stephen James @sjames1958gm May 08 2017 02:04 :) Sorthes @Sorthes May 08 2017 02:04 @derhallim alright thanks for the tip CamperBot @camperbot May 08 2017 02:04 sorthes sends brownie points to @derhallim :sparkles: :thumbsup: :sparkles: :cookie: 310 | @derhallim |http://www.freecodecamp.com/derhallim Mohamed Derhalli @derhallim May 08 2017 02:05 @sjames1958gm yea.. it was like a 15 min debate.. everyone: emacs/vim are better, bla bla bla .. I was the only 1 out there saying sublime/vscode are better .. :joy: am glad that discussion ended Stephen James @sjames1958gm May 08 2017 02:06 @derhallim Yeah, I can click and download a add on to vs code - I can attach a chrome debugger in vs code, etc. Mohamed Derhalli @derhallim May 08 2017 02:06 yeah, they still claim emacs/vim is better because u can heavily customize it .. LOL .. intcreate @intcreate May 08 2017 02:07 console.log(hi); var hi = '100'; // undefined function ethan(){ console.log(hi); } var hi = '100'; ethan(); // 100 can any1 help me why does bottom one work , but top one doesnt Stephen James @sjames1958gm May 08 2017 02:07 @derhallim You can do the same with vs code and do it in javascript @intcreate Because when the bottom one calls the function it is after hi has been assigned a value in the top one it hasn't yet HeebieGeeBee @HeebieGeeBee May 08 2017 02:08 @derhallim :wave: Mohamed Derhalli @derhallim May 08 2017 02:08 @sjames1958gm yeah, u can customize it via the json file in vscode @sjames1958gm but for example, they customize emacs text highlighting, text colors, etc.. Stephen James @sjames1958gm May 08 2017 02:08 @derhallim editor wars happen all the time online - Mohamed Derhalli @derhallim May 08 2017 02:08 @HeebieGeeBee hey man, how r u HeebieGeeBee @HeebieGeeBee May 08 2017 02:09 im alright Stephen James @sjames1958gm May 08 2017 02:09 @derhallim Cool, I did that with a click that adds a javascript, or java, or C++ add on to vs code HeebieGeeBee @HeebieGeeBee May 08 2017 02:09 hows you? Mohamed Derhalli @derhallim May 08 2017 02:09 @sjames1958gm yeah, but someone can't say I won't be efficient because I use vscode.. that's just a wrong statement @HeebieGeeBee am gd gd Stephen James @sjames1958gm May 08 2017 02:09 @derhallim I agree. intcreate @intcreate May 08 2017 02:09 @sjames1958gm oh ty CamperBot @camperbot May 08 2017 02:09 intcreate sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 7175 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Stephen James @sjames1958gm May 08 2017 02:09 @intcreate yw Mohamed Derhalli @derhallim May 08 2017 02:10 I feel am lost between ES6 and Typescript and when I see code that's written, I don't know if it's Typescript functionality, or it's just one that came with ES6 Vikram @vikramnr May 08 2017 02:27 Hi All why this is line is not giving any output \ str=str.charAt(0).toUpperCase; Mario Fredricko @marfredd May 08 2017 02:27 hello guys, can I ask something about nodejs? I'm building a simple WebRTC with video call, peer to peer in my pc. I build the server using nodejs, and then run the script for server and also for client in the first pc I want to access the server from another pc in the same network as a second client, so I access my 1st pc IP address. the result is the html appeared but it seems not connected to the server.. do you guys have a clue here? I'm using this git repo: https://github.com/sitepoint-editors/peer-messenger cameron @whoopswoop May 08 2017 02:27 @Sorthes Lol that might just be the answer, thanks! CamperBot @camperbot May 08 2017 02:27 whoopswoop sends brownie points to @sorthes :sparkles: :thumbsup: :sparkles: :cookie: 146 | @sorthes |http://www.freecodecamp.com/sorthes intcreate @intcreate May 08 2017 02:28 function sayHi(){ var string = 'hi'; printHi(string); } sayHi(); function printHi(param){ console.log(param) } // " hi" I don't understand why this works. I can invoke printHi() before i define it i thought u had to define functions before u can use them but here, printHi is last and it still works ryanbaldoza @ryanbaldoza May 08 2017 02:30 Hello. Can you help me test out my wikipedia viewer before I submit. Thanks in advance https://codepen.io/ryanbaldoza/full/oWobar/ Nick Forlivio @whackdev May 08 2017 02:32 @intcreate the way you see it on the screen is just the list of instructions, when you are calling sayHi(); it searches the code for what it needs and since the printHi(param) function is defined it works @intcreate that's part of the power of object oriented programming @intcreate you can test this by commenting out the printHi(param) function intcreate @intcreate May 08 2017 02:34 but what about this, it doenst work console.log(hi); var hi = '100'; // undefined hi is at the bottom but i cannot print it Nick Forlivio @whackdev May 08 2017 02:35 @intcreate you are telling it to print something no defined not referring to a function that is later defined intcreate @intcreate May 08 2017 02:35 so it only works for functions and not variables Nick Forlivio @whackdev May 08 2017 02:36 @intcreate to the best of my knowledge yes intcreate @intcreate May 08 2017 02:36 functions u can use it before u define, and variables u have to define before u use Nick Forlivio @whackdev May 08 2017 02:36 correct intcreate @intcreate May 08 2017 02:36 oh ok thanks @whackdev CamperBot @camperbot May 08 2017 02:36 intcreate sends brownie points to @whackdev :sparkles: :thumbsup: :sparkles: :cookie: 265 | @whackdev |http://www.freecodecamp.com/whackdev Randy @rsmorin2 May 08 2017 02:37 Working my way though largest number in an array in javascript beginner js challenges.... I know that I need to store the largest num in each subarray and I hava a variable for it, but what I'm having trouble with is how to tell the for loop to iterate and push the largest number in each subarray to the largestNumArr that I already defined. Can anyone help? function largestOfFour(arr) { var largestNum = 0; var largestNumArr = []; for (var x = 0; x < arr.length; x++) { for (var y = 0; y < arr[x].length; y++) { } } // You can do this! return largestNumArr; } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); var code = "formatted"; Nick Forlivio @whackdev May 08 2017 02:37 @ryanbaldoza working great for me ryanbaldoza @ryanbaldoza May 08 2017 02:38 @whackdev Thanks :thumbsup: CamperBot @camperbot May 08 2017 02:38 ryanbaldoza sends brownie points to @whackdev :sparkles: :thumbsup: :sparkles: :cookie: 266 | @whackdev |http://www.freecodecamp.com/whackdev Nick Forlivio @whackdev May 08 2017 02:40 @rsmorin2 you do not need two loops since you only need to iterate through each sub array @rsmorin2 scratch that I misspoke Randy @rsmorin2 May 08 2017 02:41 @whackdev I was going to say lol. that might work if I was going to do something like .math on the individual arrays, but I would still need a way to iterate though it Nick Forlivio @whackdev May 08 2017 02:42 @rsmorin2 try putting var largestNumArr in the first loop, then use the second loop to iterate through each sub array TayCodes @TayCodes May 08 2017 02:43 Does anyone know how to use the replace function with RegExp starting out with two variables like this? https://codepen.io/dev999/pen/vmWvEQ Randy @rsmorin2 May 08 2017 02:44 so each time I loop, I'm going to store the largestNumArr in the first loop then replace it every time I iterate though the subarray or are you saying that I can push the largest number from each subarray in the second loop to largestNumArr? @whackdev TayCodes @TayCodes May 08 2017 02:44 document.write("My "+color+" shoes").replace(RegExp(color), RegExp(color2)); is not working unfortunately Nick Forlivio @whackdev May 08 2017 02:44 @rsmorin2 the first one, that's how i got it to work TayCodes @TayCodes May 08 2017 02:44 document.write("My "+color+" shoes").replace(RegExp(color), RegExp(color2)); is not working unfortunately Randy @rsmorin2 May 08 2017 02:46 @whackdev what did you do to compare the values in the second loop to determine the largest num in the subarray to push it to the first loop? Nick Forlivio @whackdev May 08 2017 02:47 if (arr[i][j] > max) { ... Ming Zhu @chocobrownie May 08 2017 02:48 Hi I'm trying to understand how "Free Code Camp Twitch API Pass-through" works. Is it like an api that request data from twitch tv api? A second level api like google who request data once in a while and caches it? Is second level api ligit? Any terms for it? and where is it used? Randy @rsmorin2 May 08 2017 02:48 @whackdev let me give it a shot I'll be back in a few Nick Forlivio @whackdev May 08 2017 02:49 @rsmorin2 let me know I had to tinker with that one Randy @rsmorin2 May 08 2017 02:49 will do James Fredericks @jamesfredericks May 08 2017 02:54 anybody else completed lost on this word blanks challenge? Iris Shields @calluna May 08 2017 02:55 Hi! I'm stuck with the "Profile Lookup" exercise, my code keeps giving me the value of the first object in the array, no matter what, lol My code: var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line var i = 0; while (i < contacts.length) { if (!contacts[i].firstName) { return contacts[i].firstName; } else if (!contacts[i][prop]) { return "No such property"; } else if (contacts[i].firstName && contacts[i][prop]){ var result = contacts[i][prop]; return result; } i++; } } lookUpProfile("Sherlock", "likes"); HeebieGeeBee @HeebieGeeBee May 08 2017 02:57 @TayCodes var color = "white"; var color2= "blue"; document.write(("My " + color + " shoes").replace(new RegExp(color, 'g'), color2)); is this what youre trying to do? @calluna you need to compare the firstName in the object to the firstName parameter, and then you need to check to see if that contact has a property of prop use the .hasOwnProperty() method @calluna also remember a return willl stop the function so you onyl want to have a return hit in a loop if you want the whole function to stop Iris Shields @calluna May 08 2017 03:03 ok, I'll give it another go tx! HeebieGeeBee @HeebieGeeBee May 08 2017 03:10 @jamesfredericks you need to create a sentence using the parameters of the function and extra words and special character strings like spaces thats assigned to the result variable, so the result variable can return a complete sentence so result = "myVerb + " " + myAdjective....... for example Randy @rsmorin2 May 08 2017 03:13 @whackdev this is where I'm at so far .....  function largestOfFour(arr) { var largestNumArr = []; for (var x = 0; x < arr.length; x++) { var largestNum = arr[x][0]; for (var y = 0; y < arr[x].length; y++) { if (arr[x][y] > largestNum) { largestNumArr = arr[x][y]; } } } // You can do this! alert(largestNumArr); } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); var code = "formatted";  but is still only returning the largest num in the whole subarray.... 1001 HeebieGeeBee @HeebieGeeBee May 08 2017 03:15 @rsmorin2 push into the largestNumArr dont assign Randy @rsmorin2 May 08 2017 03:15 fml Thank you @HeebieGeeBee & @whackdev CamperBot @camperbot May 08 2017 03:16 rsmorin2 sends brownie points to @heebiegeebee and @whackdev :sparkles: :thumbsup: :sparkles: :cookie: 267 | @whackdev |http://www.freecodecamp.com/whackdev :star2: 1594 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee HeebieGeeBee @HeebieGeeBee May 08 2017 03:16 @rsmorin2 but you have other problems var largestNum = arr[x][0]; this here youre only making it the first element so youre only ever comparing to the first element you need to go through assign this a new number if a larger number is found and then after you have looked through all the elements Torrey @torreyn May 08 2017 03:18 having problems with Profile Lookup function lookUpProfile(firstName, prop){ // Only change code below this line if ( contacts.firstName == firstName ) { if ( contacts.firsName[firstName].hasOwnProperty(prop) ) { // code } else { return "No such property"; } } else { return "No such contact"; } The line "contacts.firsName[firstName].hasOwnProperty(prop)" doesn't seem to do anything HeebieGeeBee @HeebieGeeBee May 08 2017 03:18 then push this into the array Torrey @torreyn May 08 2017 03:19 (even without the typo firsName which I just fixed) HeebieGeeBee @HeebieGeeBee May 08 2017 03:19 @torreyn contacts is the array, it contains elements, which are objects that contain contact data you need to iterate through the arrays elements testing each one Torrey @torreyn May 08 2017 03:20 @HeebieGeeBee hmm. lightbulb is a little dim, but let me mull that over for a sec... Randy @rsmorin2 May 08 2017 03:21 @HeebieGeeBee so what I would want to do is include a largestNum assignment in my if statement to assign it a new value when the if statement makes the comparison? HeebieGeeBee @HeebieGeeBee May 08 2017 03:21 @rsmorin2 after youve got that way working i can give you hints on much simpler ways @rsmorin2 yes Randy @rsmorin2 May 08 2017 03:22 I was looking at some of the map methods to see what i could get working, but honestly I need a better understanding of assignments when dealing with for loops and how to store values when iterating. HeebieGeeBee @HeebieGeeBee May 08 2017 03:22 then after your nested loop completes its iterations push that value into the array Randy @rsmorin2 May 08 2017 03:23 I'll go take a whack at it and report back @HeebieGeeBee HeebieGeeBee @HeebieGeeBee May 08 2017 03:24 function largestOfFour(arr) { var largestNumArr = []; for (var x = 0; x < arr.length; x++) { var largestNum = arr[x][0]; for (var y = 0; y < arr[x].length; y++) { if (arr[x][y] > largestNum) { largestNumArr = arr[x][y]; // youre making an assignment here just to the wrong variable, so should be an easy thing to change } } } // You can do this! alert(largestNumArr); } @rsmorin2 Randy @rsmorin2 May 08 2017 03:26 got it Iris Shields @calluna May 08 2017 03:28 @HeebieGeeBee I changed my code but now it keeps looking at the last object in the array (instead of the first in my previous code) Code: function lookUpProfile(name, prop){ var i = 0; var result = ""; while (i < contacts.length) { if (contacts[i].firstName !== name) { result = "no such contact"; } else if (contacts[i].hasOwnProperty[prop]) { result = "No such property"; } else if (contacts[i].firstName && contacts[i][prop]){ result = contacts[i][prop]; } i++; } return result; } // Change these values to test your function lookUpProfile("Sherlock", "likes"); and of course it keeps saying "no such contact" as Kristian != Sherlock Though Sherlock is there in one of the objects Nick Forlivio @whackdev May 08 2017 03:30 @rsmorin2 sorry I was taking care of my kids looks like you and @HeebieGeeBee figured it out HeebieGeeBee @HeebieGeeBee May 08 2017 03:30 if it finds a match for the firstName youre loops need to stop so you can make a return Randy @rsmorin2 May 08 2017 03:30 I just got the challenge. I see where I wasn't making an assignment in the first for loop and returned the value into the array. HeebieGeeBee @HeebieGeeBee May 08 2017 03:31 of either No such property or the values of the prop but your logic is kinda all messed up Randy @rsmorin2 May 08 2017 03:32  function largestOfFour(arr) { var largestNumArr = []; for (var x = 0; x < arr.length; x++) { var largestNum = 0; for (var y = 0; y < arr[x].length; y++) { if (arr[x][y] > largestNum) { largestNum = arr[x][y]; } } largestNumArr.push(largestNum); } // You can do this! alert(largestNumArr); } largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]); var code = "formatted";  Nick Forlivio @whackdev May 08 2017 03:33 nice HeebieGeeBee @HeebieGeeBee May 08 2017 03:33 @calluna while (i < contacts.length) { if (contacts[i].firstName !== name) { result = "no such contact"; } else if (contacts[i].hasOwnProperty[prop]) { // this will return true if their is a property so the return for it is wrong should be returning the property value if true result = "No such property"; // you can return this dont assign to a variable } else if (contacts[i].firstName && contacts[i][prop]){ // the logic here isnt right either result = contacts[i][prop]; // and you can return this too } but everything is kinda back to front Iris Shields @calluna May 08 2017 03:35 aside from the returns though, when I test it, it keeps comparing the value of the last array with the (name) value, and seems to totally skip the first couple objects. I think I'm really lost on this one... oh, ok, lemme check what you wrote... HeebieGeeBee @HeebieGeeBee May 08 2017 03:35 @calluna becuase its running through all the contacts, and youre just assigning a value to a variable each time @calluna so youre just going to get what ever it was assigned on the last iteration of the loop Iris Shields @calluna May 08 2017 03:36 ah...yeah... ok Aizaz Shahid @aizazshahid May 08 2017 03:40 @HeebieGeeBee :) HeebieGeeBee @HeebieGeeBee May 08 2017 03:40  does the contacts firstName match the name parameter if yes > does that contact have the property of the prop parameter?, if yes > return that Properties value. if no > return no such contact. name doesnt match? continue to loop another iteration all iterations complete but still no name matches? > return no such contact @calluna think about this pseudo code @forwebtech yo Aizaz Shahid @aizazshahid May 08 2017 03:41 @HeebieGeeBee store that guide for the future :) HeebieGeeBee @HeebieGeeBee May 08 2017 03:41 @forwebtech meh its not well written Aizaz Shahid @aizazshahid May 08 2017 03:41 well i will do it for you ! wait any way how are you @HeebieGeeBee HeebieGeeBee @HeebieGeeBee May 08 2017 03:43 @rsmorin2 there is a sort method in javascript if those arrays were sorted could simplify things @forwebtech im alright hows you? Aizaz Shahid @aizazshahid May 08 2017 03:44 had installed sublime text 3 seems great ! but am wondering how to backup the code. HeebieGeeBee @HeebieGeeBee May 08 2017 03:44 what do you mean backup the code? Aizaz Shahid @aizazshahid May 08 2017 03:44 means auto backup sometimes my laptop gets shutdown due the battery low :) HeebieGeeBee @HeebieGeeBee May 08 2017 03:45 well with coding you should be saving regular anyways Aizaz Shahid @aizazshahid May 08 2017 03:45 notepad++ has the option to make autobackups but seems sublime text hasn't. @HeebieGeeBee actually if the computer directly shutdown my files got corrupt ! showing null null .... in notepad++ HeebieGeeBee @HeebieGeeBee May 08 2017 03:45 what about using something like cloud9 online ide you can also keep a repo on github and just keep pushing updates Aizaz Shahid @aizazshahid May 08 2017 03:47 i have seen atom which have some great cloud features, that we can directly edit from github repo's just read it ! but didn't install because someone says it will eat my cpu ! HeebieGeeBee @HeebieGeeBee May 08 2017 03:47 @forwebtech what will? oh atom yeah its a bit slow Randy @rsmorin2 May 08 2017 03:48 @HeebieGeeBee sort the elements in the array and pop the last one off and push it into the largestNumArr that I was using before? HeebieGeeBee @HeebieGeeBee May 08 2017 03:48 sublime has lots of packages @rsmorin2 well you dont need to pop it you just need to push the value Nico @Nico17x May 08 2017 03:49 Hello! Can someone please tell me why arr[3][0][1]; equals 11? var arr = [ [1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14] ]; arr[3]; // equals [[10,11,12], 13, 14] arr[3][0]; // equals [10,11,12] arr[3][0][1]; // equals 11 Joseph @revisualize May 08 2017 03:49 @Nico17x Sure. Claudio Restifo @Marmiz May 08 2017 03:50 I use atom everyday at work and it's not as bad as people point it out. The only real difference is when using a unix editor like vim or emacs. There I see the difference Christopher McCormack @cmccormack May 08 2017 03:50 @forwebtech you could try https://packagecontrol.io/packages/auto-save but it may be more than you need Joseph @revisualize May 08 2017 03:50 @Nico17x Wait, You have the answer right there. @Nico17x Array elements are just values. That value can be another array. You then just access the array element like any other array element. Aizaz Shahid @aizazshahid May 08 2017 03:51 @cmccormack plugins written in python ?? @HeebieGeeBee in sublime HeebieGeeBee @HeebieGeeBee May 08 2017 03:53 most likely couldnt say for sure though never looked Torrey @torreyn May 08 2017 03:54 Not sure what I'm doing wrong here: function lookUpProfile(firstName, prop) { // Only change code below this line var i=0; var result =""; while (i < contacts.length) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty[prop]) { return contacts[i][prop]; } else { return "No such property"; } } else { return "No such contact"; } i++; } } Christopher McCormack @cmccormack May 08 2017 03:55 @forwebtech I believe Sublime Text uses python as it's interpreter Torrey @torreyn May 08 2017 03:55 function lookUpProfile(firstName, prop) { // Only change code below this line var i=0; var result =""; while (i < contacts.length) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty[prop]) { return contacts[i][prop]; } else { return "No such property"; } } else { return "No such contact"; } i++; }} Aizaz Shahid @aizazshahid May 08 2017 03:55 @cmccormack thanks i was looking for that, also @HeebieGeeBee CamperBot @camperbot May 08 2017 03:55 forwebtech sends brownie points to @cmccormack and @heebiegeebee :sparkles: :thumbsup: :sparkles: :cookie: 526 | @cmccormack |http://www.freecodecamp.com/cmccormack :star2: 1595 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee Christopher McCormack @cmccormack May 08 2017 03:55 @torreyn surround your code with  Aizaz Shahid @aizazshahid May 08 2017 03:55 :+1: HeebieGeeBee @HeebieGeeBee May 08 2017 03:56 Christopher McCormack @cmccormack May 08 2017 03:56 I just started using VS Code just to try it out, it's really nice and free Torrey @torreyn May 08 2017 03:56 function lookUpProfile(firstName, prop) { // Only change code below this line var i=0; var result =""; while (i < contacts.length) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty[prop]) { return contacts[i][prop]; } else { return "No such property"; } } else { return "No such contact"; } i++; } } ah! Ok, so what did I do wrong above? HeebieGeeBee @HeebieGeeBee May 08 2017 03:56 @revisualize has a question to ask you @torreyn if he's still here Joseph @revisualize May 08 2017 03:57 @HeebieGeeBee @HeebieGeeBee How did you make that? HeebieGeeBee @HeebieGeeBee May 08 2017 03:57 its just gif mad ein photoshop Christopher McCormack @cmccormack May 08 2017 03:58 @torreyn you're returning No such contact after the first contact if no match. You should only return that when you've exhausted all contacts Joseph @revisualize May 08 2017 03:58 @torreyn Something to know about functions. Manish Giri @Manish-Giri May 08 2017 03:58 @HeebieGeeBee :wave: HeebieGeeBee @HeebieGeeBee May 08 2017 03:58 @Manish-Giri yo Joseph @revisualize May 08 2017 03:58 @torreyn Whenever a return statement is triggered. The function HALTS and returns that value back to the function caller. Torrey @torreyn May 08 2017 03:59 @cmccormack ok. hmmm @cmccormack ok, so seems like this would work with that logic. I'm missing something tho... function lookUpProfile(firstName, prop) { // Only change code below this line var i=0; result =""; while (i < contacts.length) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty[prop]) { return contacts[i][prop]; } else { return "No such property"; } } else { result = "No such contact"; } i++; return result; } // Only change code above this line } Joseph @revisualize May 08 2017 04:01 @torreyn You're still returning inside of your loop. @torreyn Your other code was better. Torrey @torreyn May 08 2017 04:01 hmmm Joseph @revisualize May 08 2017 04:02 @torreyn Look. Torrey @torreyn May 08 2017 04:02 doesn' t return break out of a loop? Christopher McCormack @cmccormack May 08 2017 04:02 @torreyn you don't want it to break out of the loop yet Joseph @revisualize May 08 2017 04:02 @torreyn It does. @torreyn It breaks out of the loop by HALTING the WHOLE function. @torreyn 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? Torrey @torreyn May 08 2017 04:03 @revisualize after checking them all Joseph @revisualize May 08 2017 04:04 @torreyn 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? @torreyn Why is your loop returning that it doesn't have a contact before you've looked through them all?  // code before a for loop. for (..........) { // Code inside of a for loop. } // code after a for loop. Torrey @torreyn May 08 2017 04:06 @revisualize so like if there are more than one Janes? Joseph @revisualize May 08 2017 04:06 @torreyn You're over complicating it now. @torreyn Not every if requires an else. @torreyn Not all of your return statements need to be inside of the loop. Torrey @torreyn May 08 2017 04:07 @revisualize not getting it :/ I was thinking if I find the name, then I test to see if she has the field, and if she doesn't, then I break the loop Joseph @revisualize May 08 2017 04:09 @torreyn function lookUpProfile(firstName, prop) { // Only change code below this line var i=0; result =""; while (i < contacts.length) { if (contacts[i].firstName == firstName) { if (contacts[i].hasOwnProperty[prop]) { return contacts[i][prop]; } else { return "No such property"; } } // ..... The code above this line is correct else { result = "No such contact"; } i++; return result; } // Only change code above this line } Torrey @torreyn May 08 2017 04:10 @revisualize ok, thanks :smile: CamperBot @camperbot May 08 2017 04:10 torreyn sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :star2: 3909 | @revisualize |http://www.freecodecamp.com/revisualize Torrey @torreyn May 08 2017 04:10 @revisualize gimmie a sec... Joseph @revisualize May 08 2017 04:11 Don't really know why you're using a while loop. But, whatever. Pritam Chougale @Pritam-Chougale May 08 2017 04:12 hello guys in JS problem number 145 i am not getting Escape Sequences in Strings , can you explain a little bit nonso-o123 @nonso-o123 May 08 2017 04:13 Hi guys, I'm finding it hard solving spinal-case challenge, can anyone help? Here is what I did: function spinalCase(str) { // "It's such a fine line between stupid, and clever." // --David St. Hubbins var reg = /[^a-z-]/g; var arr = str.match(reg); var word = []; for(var i = 0; i < arr.length; i++){ var c = arr[i]; if(i == arr.length-1){ word.push(str.slice(str.indexOf(c))); break; } var a = arr[i+1]; word.push(str.slice(str.indexOf(c), str.indexOf(a))); str = str.replace(word[i], ''); } var newreg = /[^A-Za-z]/g; for(var j = 0; j < word.length; j++){ if(word[j].match(newreg)){ word.splice(word.indexOf(word[j]), 1); } } str = word.join(" "); str = str.toLowerCase(); var re = /[^a-z]/g; str = str.replace(re, '-'); return str; } spinalCase('ThisIsSpinal Tap'); Vibhaas @vibhaas May 08 2017 04:14 @Pritam91 @nonso-o123 send the link/code/picture Joseph @revisualize May 08 2017 04:14 @Pritam91 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? Torrey @torreyn May 08 2017 04:14 @revisualize was using a while because that was the previous lesson Muhammad Gufron @KkhanxDef May 08 2017 04:14 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)); need help... Joseph @revisualize May 08 2017 04:15 @KkhanxDef Stand In Line is a CheckPoint where 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) { } With that function declaration you have a function name of nextInLine. You have two parameters arr which represents an array passed into the function and item that represents a number passed to the function. A few example function calls: nextInLine([4,3,2] , 1) the values passed to arr is [4,3,2] and the value passed to item is 1 nextInLine([2,4,6,8] , 10) ... arr is [2,4,6,8] & item is 10 nextInLine([2,3,5,7,11] , 13) ... arr is [2,3,5,7,11] & item is 13 (first 5 and 6th prime numbers) nextInLine([] , 0) ... arr is [] & item is 0 var myArr = [1,3,5,7]; nextInLine(myArr , 9) ... arr is [1,3,5,7] a copy of the value of the global variable myArr & item is 9 Parameters are treated like variables that represent the values that get passed into your function from the function call (arguments). Again the two parameters for the nextInLine function are arr & item. Per the instructions: 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. You need to add the number (item) to the end of an array (arr). You also need to remove the first element from an array (arr). Then you need to have your function return the removed element from the array arr. Torrey @torreyn May 08 2017 04:18 @revisualize so return breaks out of the whole function, not just the loop? Joseph @revisualize May 08 2017 04:18 @torreyn Correct. Torrey @torreyn May 08 2017 04:19 then is seems like this would work: function lookUpProfile(firstName, prop) { // Only change code below this line result =""; for (i=0; i < contacts.length; i++) { if (contacts[i].firstName == firstName) { // if the "ith" firstName is a match if (contacts[i].hasOwnProperty[prop]) { // if it's a match AND has the "prop" property return contacts[i][prop]; // gimmie the property and break } else { return "No such property"; // if it's a match, but no property, tell me and break } } } return "No such contact"; } nonso-o123 @nonso-o123 May 08 2017 04:19 Hi guys, I'm finding it hard solving spinal-case challenge, can anyone help? Here is what I did: https://www.freecodecamp.com/challenges/spinal-tap-case#?solution=%0Afunction function spinalCase(str) { // "It's such a fine line between stupid, and clever." // --David St. Hubbins var reg = /[^a-z-]/g; var arr = str.match(reg); var word = []; for(var i = 0; i < arr.length; i++){ var c = arr[i]; if(i == arr.length-1){ word.push(str.slice(str.indexOf(c))); break; } var a = arr[i+1]; word.push(str.slice(str.indexOf(c), str.indexOf(a))); str = str.replace(word[i], ''); } var newreg = /[^A-Za-z]/g; for(var j = 0; j < word.length; j++){ if(word[j].match(newreg)){ word.splice(word.indexOf(word[j]), 1); } } str = word.join(" "); str = str.toLowerCase(); var re = /[^a-z]/g; str = str.replace(re, '-'); return str; } spinalCase('ThisIsSpinal Tap'); Torrey @torreyn May 08 2017 04:19 (err, remove result =""; Lionel @Lionl-N May 08 2017 04:20 Hello can someone explain to me what I am doing wrong ? I am leaning basic Javascript  // Setup var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty("gift")) { return myObj [checkProp]; } else if (myObj.hasOwnProperty("pet")) { return myObj [checkProp]; } else if (myObj.hasOwnProperty("bed")) { return myObj [checkProp]; } else { return "Not Found"; } } // Test your code by modifying these values checkObj("house");  Thanks in advance. God bless. Joseph @revisualize May 08 2017 04:21 @Lionl-N You're not using the parameter @Lionl-N Try removing the space between myObj [ @Lionl-N You only need 1 if condition. Nguyen Hoang @honnhien12h May 08 2017 04:21 Use any loop to check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.?  //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line // Only change code above this line } // Change these values to test your function lookUpProfile("Akira", "likes"); Joseph @revisualize May 08 2017 04:22 @torreyn That should work. @honnhien12h You haven't done anything. Lionel @Lionl-N May 08 2017 04:23 @revisualize thanks for the hints ! CamperBot @camperbot May 08 2017 04:23 lionl-n sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :star2: 3910 | @revisualize |http://www.freecodecamp.com/revisualize Torrey @torreyn May 08 2017 04:23 @revisualize it doesn't tho :/ Joseph @revisualize May 08 2017 04:24 @torreyn Let me look. Nguyen Hoang @honnhien12h May 08 2017 04:24 @revisualize I do not know how to do Give me 1 suggestion.. Torrey @torreyn May 08 2017 04:24 Here's the whole code:  //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop) { // Only change code below this line for (i=0; i < contacts.length; i++) { if (contacts[i].firstName == firstName) { // if the "ith" firstName is a match if (contacts[i].hasOwnProperty[prop]) { // if it's a match AND has the "prop" property return contacts[i][prop]; // gimmie the property and break } else { return "No such property"; // if it's a match, but no property, tell me and break } } } return "No such contact"; // if the loop hasn't stopped the function, then there's not such contact } // Change these values to test your function lookUpProfile("Akira", "likes"); Joseph @revisualize May 08 2017 04:24 @torreyn contacts[i].hasOwnProperty[prop] <-- This isn't correct. @torreyn .hasOwnProperty() is a method. And methods are functions and functions use ()s Torrey @torreyn May 08 2017 04:25 oh! that was what I was struggling with in the beginning and thought I solved @revisualize ok, that was it Lionel @Lionl-N May 08 2017 04:27 @revisualize I got it thanks for your help CamperBot @camperbot May 08 2017 04:27 lionl-n sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :warning: lionl-n already gave revisualize points Torrey @torreyn May 08 2017 04:27 thanks @revisualize CamperBot @camperbot May 08 2017 04:27 torreyn sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles: :warning: torreyn already gave revisualize points Torrey @torreyn May 08 2017 04:28 Oh, you can only brownie someone once? Alright, I'm going to review what happened and then go to bed and tomorrow keep plugging away Aizaz Shahid @aizazshahid May 08 2017 04:30 @HeebieGeeBee check out, edited your algorithm: Challenge: Lookup Profile | Algorithm > First make a loop which runs to the length of the contacts array > Does the contacts firstName match the firstName parameter ? > If found then check the contacts has the property (prop parameter)? > If found then return that Properties value. > If not then return No such contact. > Continue to loop another iteration if not found. > After the completion of loop, if still no name matches. > return No such contact. HeebieGeeBee @HeebieGeeBee May 08 2017 04:31 @forwebtech cool nice one Iris Shields @calluna May 08 2017 04:32 @HeebieGeeBee YES! I got the solution to "Profile Lookup"! Thanks! And also thanks to @torreyn as you gave me insight on the structure of the code ;) CamperBot @camperbot May 08 2017 04:32 calluna sends brownie points to @heebiegeebee and @torreyn :sparkles: :thumbsup: :sparkles: :cookie: 218 | @torreyn |http://www.freecodecamp.com/torreyn :star2: 1596 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee Aizaz Shahid @aizazshahid May 08 2017 04:32 i think we don't have to waste time on describing every time same thing! Joseph @revisualize May 08 2017 04:33 Aizaz Shahid @aizazshahid May 08 2017 04:34 good also explanations are there :+1: @revisualize @revisualize i like that you have challenged the user to make it by self not just giving direct algorithm ! Aizaz Shahid @aizazshahid May 08 2017 04:41 @revisualize make your file .md and then add backticks three times javascript ...... backticks three times it will be more readable, sample: https://gist.githubusercontent.com/forwebtech/25b43fe35c9c0f37f0f563268f2ee6ed/raw/70e569d1978ef5f86effa9fd4b8abdb9aa2b1619/FCC%2520%257C%2520Challenge%2520%257C%2520Search%2520and%2520Replace.md Torrey @torreyn May 08 2017 04:41 Yay! My first brownie point! Aizaz Shahid @aizazshahid May 08 2017 04:43 @torreyn :+1: Iris Shields @calluna May 08 2017 04:43 lol, I ogled your code 👀 you're close @torreyn john g @jgwould May 08 2017 04:45 Confused with: // Setup var myObj = { gift: "pony", pet: "kitten", bed: "sleigh" }; function checkObj(checkProp) { // Your Code Here if(myObj.hasOwnProperty(checkProp) === true){ return myObj(checkProp); } else { return "Not Found"; } } // Test your code by modifying these values checkObj("gift"); Torrey @torreyn May 08 2017 04:45 @calluna yea, but my brain is full :) john g @jgwould May 08 2017 04:47 checkObj is not a function... is the error message I am getting Aizaz Shahid @aizazshahid May 08 2017 04:48 @jgwould working or not ? john g @jgwould May 08 2017 04:49 not working Aizaz Shahid @aizazshahid May 08 2017 04:50 @jgwould let me try your code ! john g @jgwould May 08 2017 04:50 Got it. It was the brackets! Needed to use [ ] instead of () Aizaz Shahid @aizazshahid May 08 2017 04:51 @jgwould return myObj(checkProp); ?? john g @jgwould May 08 2017 04:51 yes Aizaz Shahid @aizazshahid May 08 2017 04:51 to access the properties of an object you only have two solutions ! dot notation and bracket notation. john g @jgwould May 08 2017 04:52 now it is return myObj[checkProp]; Aizaz Shahid @aizazshahid May 08 2017 04:52 @jgwould but the thing is that you can refactor your code ! SavInge @SavInge May 08 2017 04:52 I'm having trouble with this. Can anyone help? john g @jgwould May 08 2017 04:53 ok, how Aizaz Shahid @aizazshahid May 08 2017 04:53 @jgwould if( myObj.hasOwnProperty(checkProp) ){ // equals to what you did because it returns the boolean ! and other thing, don't need else statement, because when we use return, it will automatically terminates your function and return the statement !  if( myObj.hasOwnProperty(checkProp) ){ return myObj[checkProp]; } return "Not Found"; john g @jgwould May 08 2017 04:54 ok, got it Aizaz Shahid @aizazshahid May 08 2017 04:55 @jgwould and do you know ternary operator ?? SavInge @SavInge May 08 2017 04:55 my original try I think I just had a regular array, so I tried adding some subarray brackets, but that doesn't work either. john g @jgwould May 08 2017 04:56 no, show me Joseph @revisualize May 08 2017 04:56 @forwebtech Look, the problem with making it a .md file. I can't copy and paste from it. Aizaz Shahid @aizazshahid May 08 2017 04:56 @revisualize didn't get you @jgwould ( condition ... ) ? statement if true : statement if false; Joseph @revisualize May 08 2017 04:56 @forwebtech What? Aizaz Shahid @aizazshahid May 08 2017 04:57 :point_up: May 8, 2017 9:56 AM john g @jgwould May 08 2017 04:57 thank you for your help @forwebtech CamperBot @camperbot May 08 2017 04:57 :cookie: 448 | @forwebtech |http://www.freecodecamp.com/forwebtech jgwould sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: Aizaz Shahid @aizazshahid May 08 2017 04:57 john g @jgwould May 08 2017 04:57 Not quite there with ternary operator yet Joseph @revisualize May 08 2017 04:57 @forwebtech You don't seem to understand that I copy and paste from my gists all the time. Aizaz Shahid @aizazshahid May 08 2017 04:58 if you open the link then you can copy it ! @revisualize but you don't need to copy it just paste the link here. i think ! Joseph @revisualize May 08 2017 04:58 @forwebtech But, I don't always copy and paste the links. Aizaz Shahid @aizazshahid May 08 2017 04:58 the text is copy able here ! Joseph @revisualize May 08 2017 04:59 @forwebtech I often pull selective text from my gists. Aizaz Shahid @aizazshahid May 08 2017 04:59 well, ok :+1: SavInge @SavInge May 08 2017 05:00 Can I have some help with sub-arrays? Ricardo Zazueta @Drummaric May 08 2017 05:02 Hi I'm having trouble understanding what to do for this section on converting Celsius to Fahrenheit 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(0); Joseph @revisualize May 08 2017 05:02 @SavInge var arr = [ [ "a1" ] , [ "b2" , "c2" ] , [ "d3" , "e3" , "f3" ] , [ [ "g4" , "h4" ] , "i4" , "k4" ] ]; var arr = [ // this is where the parent array starts. [ "a1" ] , // this is arr[0] [ "b2" , "c2" ] , // this is arr[1] [ "d3" , "e3" , "f3" ] , // this is arr[2] [ // this is where arr[3] starts [ "g4" , "h4" ] , // this is arr[3][0] "i4" , // this is arr[3][1] "k4" // this is arr[3][2] ] // this is where arr[3] ends ]; // This is where the parent array ends SavInge @SavInge May 08 2017 05:03 @revisualize what was I doing wrong? Did I just have too many brackets? var myList = [["milk", 15], ["eggs", 14]], [["chocolate", 13], ["cheese", 12]], [["fruit", 11]]; Joseph @revisualize May 08 2017 05:04 @SavInge You have too many brackets Aizaz Shahid @aizazshahid May 08 2017 05:04 @SavInge it doesn't matter how many arrays are nested into one array but you need [ ... ] those one to quote them ! actually you are doing it like .... arr = [ [..] , [...] ] , [ [..] , [...] ], [ [..] , [...] ] SavInge @SavInge May 08 2017 05:05 if it has to be written [string, number] and have at least five sub arrays, I'm not sure I understand when to braket. Aizaz Shahid @aizazshahid May 08 2017 05:06 if you wrap them with [ .. ] then it will works ! you need to understand dimensions of arrays. Aizaz Shahid @aizazshahid May 08 2017 05:13 @SavInge  var items = [ [1, 2], [3, 4], [5, 6] ]; console.log(items[0][0]); // 1 console.log(items); two-dimensional array Bryan Reese @breese8009 May 08 2017 05:18 @Drummaric the math is in the directions...just set fahrenheit equal to it __SharifTarver__ @Sharifdesigns22 May 08 2017 05:19 what's wrong with my code? // Setup function abTest(a, b) { // Only change code below this line console.log(0 > a); console.log(0 > b); // 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); Return Early Patterns for functions Markus Kiili @Masd925 May 08 2017 05:20 @Sharifdesigns22 Console.log doesn't do anything really there. You need an if to test a and b. And you need to make the function to return undefined on that if block. Steven @LemonTruth May 08 2017 05:21 function findLongestWord(str) { str = str.split(" "); for (i = 0; i < str.length; i++){ str.push(str[i].length); str.shift(str[i]); } str.sort(function(a, b){ return b - a; }); return str[1]; } I'm getting an error: "cannot read property 'length' of undefined" Markus Kiili @Masd925 May 08 2017 05:23 @LemonTruth Mutating the array you iterate over with for usually messes up the indices. __SharifTarver__ @Sharifdesigns22 May 08 2017 05:23 @Masd925  like so? // Setup function abTest(a, b) { // Only change code below this line if (a,b < 0) return undefined; // 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);  •  // Setup function abTest(a, b) { // Only change code below this line if (a,b < 0) return undefined; // 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);  Markus Kiili @Masd925 May 08 2017 05:23 @Sharifdesigns22 if(cond1 || cond2)... a is not a (good) condition here. __SharifTarver__ @Sharifdesigns22 May 08 2017 05:25 @Masd925 Could you elaborate? I've never seen || before in a statement.. Markus Kiili @Masd925 May 08 2017 05:25 @Sharifdesigns22 You need to test if a is negative OR b is negative. || is the OR operator. __SharifTarver__ @Sharifdesigns22 May 08 2017 05:28 Gotcha, @Masd925  // Setup function abTest(a, b) { // Only change code below this line if (a||b < 0) return undefined; // 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); Markus Kiili @Masd925 May 08 2017 05:29 @Sharifdesigns22 No, you need to have a condition on the left side of ||. Just a is not a (suitable) condition. __SharifTarver__ @Sharifdesigns22 May 08 2017 05:34 @Masd925 i guess I'm not understanding this one as quickly, why would I add a condition or in another example what would that look like? I think I'm totally overthinking it. Markus Kiili @Masd925 May 08 2017 05:34 @Sharifdesigns22 You need to check both with if( a<0 || b<0 ) {...}. Ah Kei @TwoSim May 08 2017 05:35 // Setup function abTest(a, b) { // Only change code below this line if (a<0 || b<0) { return "undefined"; } // 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); I got undefined on the console. but not passed. Aizaz Shahid @aizazshahid May 08 2017 05:35 @Sharifdesigns22 ( condition first || condition second ), but you are trying to combining it ! Markus Kiili @Masd925 May 08 2017 05:35 @TwoSim "undefined" is a string and undefined is a special value of type Undefined. Ah Kei @TwoSim May 08 2017 05:35 Alexander @AlexanderPuhl May 08 2017 05:36 Hey guys, i'm having a hard time with this switch statement. Ah Kei @TwoSim May 08 2017 05:36 Right. No “” will pass @Masd925 thank you CamperBot @camperbot May 08 2017 05:36 twosim sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles: :star2: 4030 | @masd925 |http://www.freecodecamp.com/masd925 __SharifTarver__ @Sharifdesigns22 May 08 2017 05:36 @Masd925 @forwebtech Thank you guys both! I knew it had to be super simple haha CamperBot @camperbot May 08 2017 05:36 sharifdesigns22 sends brownie points to @masd925 and @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 449 | @forwebtech |http://www.freecodecamp.com/forwebtech :star2: 4031 | @masd925 |http://www.freecodecamp.com/masd925 Alexander @AlexanderPuhl May 08 2017 05:36 This is the result I get when I try to test it... Aizaz Shahid @aizazshahid May 08 2017 05:37 @AlexanderPuhl you have wrong string in case 4 @AlexanderPuhl check you strings against all cases. Alexander @AlexanderPuhl May 08 2017 05:38 I'm kind of confused lol, the test says I got that one right. minnkhant-koko @minnkhant-koko May 08 2017 05:39 Hi ! Everyone! I have no idea to pass The javaScript Can someone help me ? Aizaz Shahid @aizazshahid May 08 2017 05:39 @AlexanderPuhl you didn't include those cases 'a', 'b', 'c' @minnkhant-koko yes ? minnkhant-koko @minnkhant-koko May 08 2017 05:40 // Declarations var StUdLyCapVaR; var properCamelCase; var TitleCaseOver; // Assignments STUDLYCAPVAR = 10; PRoperCAmelCAse = "A String"; tITLEcASEoVER = 9000; @forwebtech Alexander @AlexanderPuhl May 08 2017 05:40 I feel like I did, I used case 1... case 2... case 3, instead of case a... case b... case c Aizaz Shahid @aizazshahid May 08 2017 05:40 @minnkhant-koko you need to change the casing of your words to camelCase . @AlexanderPuhl you can also do that, ... case 1: case 'a': statement...; break; ... minnkhant-koko @minnkhant-koko May 08 2017 05:41 Can you tell me specifically , please ? Alexander @AlexanderPuhl May 08 2017 05:41 k, let me give that a try. minnkhant-koko @minnkhant-koko May 08 2017 05:41 @forwebtech Aizaz Shahid @aizazshahid May 08 2017 05:42 @minnkhant-koko camelCase: first word should be in small case and after each word, first letter should be in Upper case, like: myVar Alexander @AlexanderPuhl May 08 2017 05:42 oh man, ya they wanted it in letters, gotta be in quotes when doing letters. Thanks @forwebtech ! CamperBot @camperbot May 08 2017 05:42 alexanderpuhl sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 450 | @forwebtech |http://www.freecodecamp.com/forwebtech Aizaz Shahid @aizazshahid May 08 2017 05:43 :+1: minnkhant-koko @minnkhant-koko May 08 2017 05:43 Like studlyCapVar, properCamelCase, and titleCaseOver ? @forwebtech Aizaz Shahid @aizazshahid May 08 2017 05:43 right ! minnkhant-koko @minnkhant-koko May 08 2017 05:44 Thanks,dude! @forwebtech Can you explain me what is brownie points again ...? I want to know ... CamperBot @camperbot May 08 2017 05:44 minnkhant-koko sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 451 | @forwebtech |http://www.freecodecamp.com/forwebtech Ming Zhu @chocobrownie May 08 2017 05:45 Hi, I have a question regarding asynchronous function callback: I can set a callback for an individual asynchronous function when I need its returned data to proceed with certain functions. But what if I need data from two asynchronous function to proceed? I need something that performs a callback for the two of them but I don't see a way of doing that. Markus Kiili @Masd925 May 08 2017 05:45 @chocobrownie You can make the second ajax call inside the callback of the first call. There are also other ways. Ming Zhu @chocobrownie May 08 2017 05:46 @Masd925 Any keywords for the first and other ways I could search on? Markus Kiili @Masd925 May 08 2017 05:47 @chocobrownie Using the first way is simpler, but you can use JS Promises too . Thomas Mullen @t-mullen May 08 2017 05:51 @chocobrownie If the second async function doesn't need anything from the first, you should do them in parallel. Here's how to do it with jQuery: var d1 =$.ajax("test1.json")
var d2 = $.ajax("test2.json")$.when(d1, d2).then(function (x, y) {
x[0] // data from first ajax
y[0] // data from second ajax
})

Or if you want them to be done in series:

$.ajax("test1.json").then(function (data1) {$.ajax("test2.json").then(function (data2) {
// done
})
})

or

$.ajax("test1.json").then(function (data1) { return$.ajax("test2.json")
}).then(function (data2) {
// done
})
Ming Zhu
@chocobrownie
May 08 2017 05:55
@RationalCoding Ajax is so mighty lol
Thomas Mullen
@t-mullen
May 08 2017 05:56
@chocobrownie Yeah, with promises it's very versatile.
Ming Zhu
@chocobrownie
May 08 2017 05:57
@RationalCoding Oh wait, what you showed me is called JavaScript Promeses?
Promises*
Thomas Mullen
@t-mullen
May 08 2017 05:57
@chocobrownie Those are jQuery promises, which are very similar but slightly different.
Markus Kiili
@Masd925
May 08 2017 05:58
@chocobrownie I meant just that.
Ming Zhu
@chocobrownie
May 08 2017 05:58
@Masd925 Cool! I think jQuery promises is better cuz it is faster. But your first method works as well
But promising two/multiple conditions, it saves time by running them together
Thomas Mullen
@t-mullen
May 08 2017 05:59
@chocobrownie Yes, parallel will be faster. You sometimes need the results from the first call to make the second one, so it can't always be used.
Markus Kiili
@Masd925
May 08 2017 05:59
@chocobrownie Just remember that there is nothing parallel in JS/Jquery. It is just syntax sugar.
Ming Zhu
@chocobrownie
May 08 2017 06:00
@RationalCoding jQuery should be more simple and robust, it is an extension, they wouldn't come up with this method if it's not considered better lol
@Masd925 Huh???
Are you telling me all these concepts are useless?
How could it be fake?
Thomas Mullen
@t-mullen
May 08 2017 06:00
@Masd925 I disagree. You are pushing those unresolved requests to the stack. It's parallel for all intents and purposes.
Unless you mean that in a threading sense, then yeah.
Markus Kiili
@Masd925
May 08 2017 06:01
@RationalCoding I mean in the treading sense. It still makes the two ajax calls the same in all the cases.
Thomas Mullen
@t-mullen
May 08 2017 06:03
Well making them in series will be slower, since you don't even begin the second request until the first is completed.
It's t1+t2 vs max(t1, t2)
I wouldn't dream of making 100+ requests in series.
Aizaz Shahid
@aizazshahid
May 08 2017 06:04
$(document).ready(function(){ var x ....; foo(); }); foo() { .... accessing x; } why it can't access that x ? Thomas Mullen @t-mullen May 08 2017 06:04 @chocobrownie, no these concepts are very useful. Markus was just pointing out an issue with my terminology. Aizaz Shahid @aizazshahid May 08 2017 06:06 ReferenceError: x is not defined Thomas Mullen @t-mullen May 08 2017 06:06 @forwebtech Which variables you can access inside a function depend on where the function was defined, not where it was called. ie) function foo1 () { // can't access x }$(document).ready(function(){
var x ....;
function foo2 () {
// CAN access x
}
});
Markus Kiili
@Masd925
May 08 2017 06:07
@RationalCoding Yes, that is true. I was just stating the fact that JS engine does one thing at the time. Using the term parallel might make someone think that something is run at the same time.
Ming Zhu
@chocobrownie
May 08 2017 06:07
@RationalCoding Ah I see lol, I was thinking that maybe @Masd925 was talking about defect of the coding language JavaScript itself? Maybe the concept exists but only can be done in C++ or Ruby and Phython and stuffs?
Aizaz Shahid
@aizazshahid
May 08 2017 06:07
@RationalCoding seems not correct answer !
Thomas Mullen
@t-mullen
May 08 2017 06:08
@forwebtech No, the code I gave you won't do the same thing.
I'm saying it matters where you define foo, not where you call it.
Aizaz Shahid
@aizazshahid
May 08 2017 06:08
well the problem is that we can't access the functions outside the .ready(){} got it ??
but why it can't access it, as we know that the function will load at first ??
Thomas Mullen
@t-mullen
May 08 2017 06:09
@forwebtech Ah, I misunderstood you.
Functions protect the variables that are declared inside them. So nothing declared inside your "ready" callback can be seen outside of it.
Aizaz Shahid
@aizazshahid
May 08 2017 06:09
oh so that one is a callback ??
Thomas Mullen
@t-mullen
May 08 2017 06:09
Either declare x outside of your ready callback, or move your code inside the callback.
Aizaz Shahid
@aizazshahid
May 08 2017 06:10
well i know about callback functions, that they can't allow outsiders to access their data. right ?
Thomas Mullen
@t-mullen
May 08 2017 06:10

Yup, this code:

$(document).ready(function(){ }) means, "when the document is ready, call this function" You're right, nothing outside of a function can access data declared inside that function. Markus Kiili @Masd925 May 08 2017 06:11 @forwebtech JS has function scope. Thomas Mullen @t-mullen May 08 2017 06:11 function foo() { var x; // can see x } // can't see x Aizaz Shahid @aizazshahid May 08 2017 06:12 even the normal functions don't allow that didn't think that first.:) var x = 10;$(document).ready(function(){

foo();
});

function foo() {
console.log(x);
}
Ming Zhu
@chocobrownie
May 08 2017 06:13
@Masd925 Ic, so you mean Javascript is like a CPU, it can assign stuffs one by one to GPU and make them run "parallel", which they sort of are, but CPU (JS) is never parallel itself?
Thomas Mullen
@t-mullen
May 08 2017 06:13

@chocobrownie Javascript is a little different in the sense that it only has a single thread. Some people see this as a limitation, but it can actually be very powerful when you are dealing with many small async functions.

It's the reason Node is good for webservers. You don't need a thread for each client. But it also means you can't compute in parallel.

Aizaz Shahid
@aizazshahid
May 08 2017 06:13
@Masd925 @RationalCoding :+1: thanks !
CamperBot
@camperbot
May 08 2017 06:13
forwebtech sends brownie points to @masd925 and @rationalcoding :sparkles: :thumbsup: :sparkles:
:star2: 4032 | @masd925 |http://www.freecodecamp.com/masd925
Thomas Mullen
@t-mullen
May 08 2017 06:14
@chocobrownie You can always offload your parallel computing needs to something like C though, and use Node for everything else.
The browsers are out of luck though!
Ming Zhu
@chocobrownie
May 08 2017 06:15
@RationalCoding I see your point, but is it true that other "decent" coding languages can do both single thread and multiple thread? If this is true those languages are better in anyway. Cuz they can do JavaScript's job and they can do something more if they want to
Thomas Mullen
@t-mullen
May 08 2017 06:17

@chocobrownie Yes, you can do anything in C that you can do in Node. But code complexity is something to keep in mind. Something that will take you 10 lines in Javascript could take you 500 in C.

Each language is good for a different purpose, and you should try to understand the pros and cons of each.

It's tempting to say power is the most important thing, but then we would all write in assembly and nothing would get done xD
Aizaz Shahid
@aizazshahid
May 08 2017 06:18
@RationalCoding JS is made from C++, C i think
Ming Zhu
@chocobrownie
May 08 2017 06:19
@RationalCoding Ic, It's just I'm being told multiple times from programmers that "JavaScript and Matlab are not coding language", and they strongly encourage me to learn Python throughly.
Thomas Mullen
@t-mullen
May 08 2017 06:19
Yeah, it's V8, which is C++
bilaal-s
@bilaal-s
May 08 2017 06:19

Hello guys a node question, when typing the command

curl \$domain/messages/ -d "string"

the below server does not respond, any ideas?

"use strict";
const http = require('http');
const fs = require('fs');

const server = http.createServer(function(request, response) {
let method = request.method;
console.log(method)
let url = request.url;
console.log(url)
let body = [];

if (method === "POST") {
console.log("The method is: " + method)
if (url === "/domain/messages/") {
console.log("The url is: " + url)

request.on('error', function(err) {
console.error(err);
}).on('data', function(chunk) {
body.push(chunk);
}).on('end', function() {
body = Buffer.concat(body).toString();
// At this point, we have the headers, method, url and body, and can now
// do whatever we need to in order to respond to this request.

'Content-Type': 'text/plain'
});

response.end(function() {
console.log("data");
})

});
}
}

}).listen(8080, '127.0.0.1', function() {
console.log("You are now listening on 8080!");
});
Aizaz Shahid
@aizazshahid
May 08 2017 06:20
@bilaal-s https://gitter.im/FreeCodeCamp/HelpBackEnd i think, good feedback from their !
Markus Kiili
@Masd925
May 08 2017 06:20
@chocobrownie jQuery is just a bunch of JS objects and methods. So using its methods just change how things are structured and wrapped and look, not the way things work in JS. JS engine always runs one function at the time. The browser has different parts besides the JS engine.
bilaal-s
@bilaal-s
May 08 2017 06:20
@forwebtech thanks
CamperBot
@camperbot
May 08 2017 06:20
bilaal-s sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Thomas Mullen
@t-mullen
May 08 2017 06:20
@chocobrownie I can see why some people wouldn't consider Matlab a programming language. It's technically a programming language, but it's designed for strictly mathematical calculation.
Aizaz Shahid
@aizazshahid
May 08 2017 06:20
@bilaal-s :+1:
Thomas Mullen
@t-mullen
May 08 2017 06:21
Javascript is a programming language. Most people who think it's not typically have some prejudice towards web development as a profession, because it's popular with beginners.
Aizaz Shahid
@aizazshahid
May 08 2017 06:22
@RationalCoding yes, but the difference is that it's precompiled !
Thomas Mullen
@t-mullen
May 08 2017 06:22
I usually point out that Javascript with V8 is faster than python bytecode and that settles the debate.
@forwebtech Python is interpreted.
Oh you mean Matlab? I don't know a lot about the implementation of it.
Aizaz Shahid
@aizazshahid
May 08 2017 06:23
Python ?? didn't need to compile like Java / C
Thomas Mullen
@t-mullen
May 08 2017 06:23
Java compiles to bytecode, which is interpreted by the JVM.
Aizaz Shahid
@aizazshahid
May 08 2017 06:23
@RationalCoding well i talked about JS not python :point_up: May 8, 2017 11:22 AM
May 08 2017 06:23
hey I was wondering: i am working on one of the API project and getting help from a tutorial. is it considered cheating?
Aizaz Shahid
@aizazshahid
May 08 2017 06:23
@RationalCoding know that !
Ming Zhu
@chocobrownie
May 08 2017 06:24
@RationalCoding Is there anything C++ can't do and has to outsource? Like how u said JS has to out source to C sometimes
Aizaz Shahid
@aizazshahid
May 08 2017 06:24
@ahmadabdolsaheb no you are learning actually :exclamation:
Ming Zhu
@chocobrownie
May 08 2017 06:24
@Masd925 Got it, it's just and extension to make things easier to write and read
Alexander Køpke
@alexanderkopke
May 08 2017 06:24
@ahmadabdolsaheb if that is how you learn best then that is the way you should do it
Thomas Mullen
@t-mullen
May 08 2017 06:25
@chocobrownie C++ is basically C with some syntax sugar. And if there's something you can't do with C... you probably can't do it.
Aizaz Shahid
@aizazshahid
May 08 2017 06:25
@ahmadabdolsaheb that's the great way to learn actually, working on real projects, you will learn a lot rather than who just reads tutorials !
Thomas Mullen
@t-mullen
May 08 2017 06:25
Some things that JS does would take some time to write in C though.
Ming Zhu
@chocobrownie
May 08 2017 06:25
@RationalCoding So C++ Ruby Python Java C# is considered "a real coding language" cause of their versatality
Thomas Mullen
@t-mullen
May 08 2017 06:26
@ahmadabdolsaheb As long as you understand everything you submit, it's fine. You can only cheat yourself in FCC.
Ming Zhu
@chocobrownie
May 08 2017 06:26
I understand, Both Matlab and JS saved me a lot of time on development
But honestly, I tried Matlab. It REALLY gives me a headache when the program becomes big lol, too slow
Thomas Mullen
@t-mullen
May 08 2017 06:27
@chocobrownie JS is a "real" programming language. Matlab is too, although it's more limited in where it's the right choice.
Ming Zhu
@chocobrownie
May 08 2017 06:28
Up to how you define real lol. I get what you mean
Thomas Mullen
@t-mullen
May 08 2017 06:29
If you want to get technical, look up "Turing completeness" haha. But then virtually everything is a programming language.
Markus Kiili
@Masd925
May 08 2017 06:30
@RationalCoding I think even HTML5+CSS3 is Turing complete.
Ming Zhu
@chocobrownie
May 08 2017 06:30
I'd rather stay in the middle, not having a shitty face when ppl are just joking around playing with concepts
Thomas Mullen
@t-mullen
May 08 2017 06:30
@Masd925 I think you're right. Can't you do computation with the animations or something?
Markus Kiili
@Masd925
May 08 2017 06:31
@RationalCoding There was an article somewhere about that.
Thomas Mullen
@t-mullen
May 08 2017 06:31
Great, now I'm going to have nightmares about having to code huge projects in CSS3. xD
Ming Zhu
@chocobrownie
May 08 2017 06:34
So is front end development the only realm JavaScript is good for?
Or say specialized in
Markus Kiili
@Masd925
May 08 2017 06:34
@chocobrownie You can also do backend with JS nowadays.
grfraser
@grfraser
May 08 2017 06:35
best javascript tutorial site?
Markus Kiili
@Masd925
May 08 2017 06:35
@chocobrownie FCC has Node+Express content
May 08 2017 06:36
@RationalCoding great answer, totally deserve a brownie thanks
CamperBot
@camperbot
May 08 2017 06:36
ahmadabdolsaheb sends brownie points to @rationalcoding :sparkles: :thumbsup: :sparkles:
Joseph
@revisualize
May 08 2017 06:36
@chocobrownie you can do Back End Programming with JavaScript using Node.js
Ming Zhu
@chocobrownie
May 08 2017 06:36
@Masd925 whole thing of MEAN full stack start to make sense lol, thx
CamperBot
@camperbot
May 08 2017 06:36
chocobrownie sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4033 | @masd925 |http://www.freecodecamp.com/masd925
Ming Zhu
@chocobrownie
May 08 2017 06:36
@revisualize same for u
grfraser
@grfraser
May 08 2017 06:37
besides fcc
May 08 2017 06:39
@alexanderkopke @forwebtech thanks
CamperBot
@camperbot
May 08 2017 06:39
ahmadabdolsaheb sends brownie points to @alexanderkopke and @forwebtech :sparkles: :thumbsup: :sparkles:
:star2: 1353 | @alexanderkopke |http://www.freecodecamp.com/alexanderkopke
Harut
@harut-g
May 08 2017 07:01
Who completed the Diff Two Arrays?
Markus Kiili
@Masd925
May 08 2017 07:02
@harut-g I did.
Harut
@harut-g
May 08 2017 07:02
@Masd925

function diffArray(arr1, arr2) {
var newArr = arr1.concat(arr2);
return newArr.filter(function(value,i){
return (newArr.indexOf(value,i+1)==-1 && newArr.slice(0,i).indexOf(value)==-1)?true:false;
});
}
diffArray(["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"]);
it's my solution
Markus Kiili
@Masd925
May 08 2017 07:02
@harut-g It works?
Harut
@harut-g
May 08 2017 07:03
any other solutions more better?
@Masd925 yes,it's
Markus Kiili
@Masd925
May 08 2017 07:03
function diffArray(arr1, arr2) {
return arr1.concat(arr2).filter(function(val, index, array){
return array.indexOf(val)===array.lastIndexOf(val);
});
}
Harut
@harut-g
May 08 2017 07:04
@Masd925 cool!
Harut
@harut-g
May 08 2017 07:06
@amirsaleem96 :+1:
Drew
@educatedrisk
May 08 2017 07:06
Hey all .. wondering if i could get a hand
Harut
@harut-g
May 08 2017 07:06
@educatedrisk what do you need?
Drew
@educatedrisk
May 08 2017 07:06
anyone done the FreeCodeCamp basic javascript Profile Lookup challenge?
I think I have it mostly figured out
Just need to return a nested array back .and getting undefined
Harut
@harut-g
May 08 2017 07:07
Which section it is?
Drew
@educatedrisk
May 08 2017 07:07
Basic Javacript > Profile Lookup
Markus Kiili
@Masd925
May 08 2017 07:08
@educatedrisk You need to return a property value or one of the given strings.
Drew
@educatedrisk
May 08 2017 07:09
yeah .. I try and return contact[i
return contact[i].prop;
Markus Kiili
@Masd925
May 08 2017 07:10
@educatedrisk .prop looks for property key "prop", and not the key stored in parameter prop.
Drew
@educatedrisk
May 08 2017 07:10
is that a reserved word ?
Markus Kiili
@Masd925
May 08 2017 07:11
@educatedrisk No. prop is the function parameter.
Parameters hold the passed arguments from the function call.
Drew
@educatedrisk
May 08 2017 07:12
having issues with contacts[i].[prop][1]
or trying to return contacts[i].prop; in my first IF
Markus Kiili
@Masd925
May 08 2017 07:14
@educatedrisk Use return contacts[i][prop];
Drew
@educatedrisk
May 08 2017 07:16
Ugghh .. thanks @Masd925 I tried looking up how to access nested arrays
CamperBot
@camperbot
May 08 2017 07:16
educatedrisk sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4034 | @masd925 |http://www.freecodecamp.com/masd925
Drew
@educatedrisk
May 08 2017 07:16
was trying to trouble shoot the problem .. was just banging my head against the wall
Markus Kiili
@Masd925
May 08 2017 07:16
@educatedrisk No nested arrays here, just an array of objects.
Drew
@educatedrisk
May 08 2017 07:17
wasn't it an array of objects that had a nested array in them ?
Markus Kiili
@Masd925
May 08 2017 07:18
@educatedrisk Those objects have some property value that is an array.
wizzoz
@wizzoz
May 08 2017 07:18
guys need help
var myStr="Firstline\n\SecondLine\\rThirdLine"; // Change this line
myStr should have encoded text with the proper escape sequences and no spacing.
Harut
@harut-g
May 08 2017 07:20
@Masd925 Markus do you work as developer now?
Markus Kiili
@Masd925
May 08 2017 07:20
@harut-g Yes.
Harut
@harut-g
May 08 2017 07:20
@Masd925 front or back?
Markus Kiili
@Masd925
May 08 2017 07:21
@harut-g Front.
Harut
@harut-g
May 08 2017 07:21
@Masd925 and your experience more than 1 year?
Markus Kiili
@Masd925
May 08 2017 07:22
@harut-g I graduated 1,5 years ago and have been working since.
Harut
@harut-g
May 08 2017 07:22
@Masd925 great!
@Aberoom
May 08 2017 07:22
@wizzoz what's the problem, what is the test returning as a result?
Claudio Restifo
@Marmiz
May 08 2017 07:33
Mind If I ask what do you use at work @Masd925?
Last time I looked job opening in EU Angular was the main requested front-end skill ^^
Aizaz Shahid
@aizazshahid
May 08 2017 07:34
@Masd925 @Aberoom :wave:
@Aberoom
May 08 2017 07:34
@forwebtech Hey buddy :)
Aizaz Shahid
@aizazshahid
May 08 2017 07:35
what's going on !
@Aberoom how do you manage your hairs ?
seems very long !
@Aberoom
May 08 2017 07:37
@forwebtech It's easier to have them long than go to the hairdresser every couple months and have them fuck up your head :D
@forwebtech nothing much, currently at work. Looking for a job somewhere else :P
Aizaz Shahid
@aizazshahid
May 08 2017 07:38
@Aberoom yes do the job which you like also !
well all is good !
@Aberoom on what price for one time ?
Markus Kiili
@Masd925
May 08 2017 07:40
@Marmiz I do AngularJS and JS simulation applets for paper/pulp industry learning software.
@forwebtech Hi.
Aizaz Shahid
@aizazshahid
May 08 2017 07:42
@Masd925 how are you ?
minnkhant-koko
@minnkhant-koko
May 08 2017 07:42

Hi ! Everyone ....
@forwebtech Hi:)

I got stack by this. Can anyone help me!
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";

Markus Kiili
@Masd925
May 08 2017 07:42
Aizaz Shahid
@aizazshahid
May 08 2017 07:42
@minnkhant-koko :wave:
@Masd925 same !
Claudio Restifo
@Marmiz
May 08 2017 07:43
@Masd925 'right! thanks for replying :)
CamperBot
@camperbot
May 08 2017 07:43
marmiz sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4035 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
May 08 2017 07:43
@minnkhant-koko you need to change the outer double quotes to single ones.
and then also remove the backslashes !
because same quotes within same quotes needed escaping, but, double quotes within single quotes don't need escaping, vice versa !
minnkhant-koko
@minnkhant-koko
May 08 2017 07:46
@forwebtech
var myStr = '<a href="http://www.example.com" target="_blank ">Link</a>';
I m still wrong in it
Aizaz Shahid
@aizazshahid
May 08 2017 07:46
seems right ! what's the instructions perhaps ?
minnkhant-koko
@minnkhant-koko
May 08 2017 07:47
@forwebtech Quoting Strings with Single Quotes
Aizaz Shahid
@aizazshahid
May 08 2017 07:47
var myStr = '<a href="http://www.example.com/" target="_blank
">Link</a>';
try that !
Markus Kiili
@Masd925
May 08 2017 07:48
@Marmiz Not sure if I would pick angular if I was learning frameworks.
Claudio Restifo
@Marmiz
May 08 2017 07:48
@Masd925 never intended to learn Angular to be hones. I'm fine with React, and Vue lately.
was just curious
Since last time I looked Angular was heavily requested
Markus Kiili
@Masd925
May 08 2017 07:49
@Marmiz Yeah. It is one of the big ones.
minnkhant-koko
@minnkhant-koko
May 08 2017 07:49
@forwebtech I can't ...
I got 2 errors left... remove all errors left and ,it said, I should have 2 single quotes and 4 double quotes
Claudio Restifo
@Marmiz
May 08 2017 07:50
@Masd925 guess depends on your region; here in Asia angular is rarely seen :)
Aizaz Shahid
@aizazshahid
May 08 2017 07:51
copy your line, reset the page and then try.
Claudio Restifo
@Marmiz
May 08 2017 07:51
Vue is increasing at an incredible speed; lots of Chinese (and around) companies are using it at the moment.
That's why I was curious :)
Markus Kiili
@Masd925
May 08 2017 07:51
@Marmiz What languages and frameworks schools and universities use as learning tools must have a big effect locally.
minnkhant-koko
@minnkhant-koko
May 08 2017 07:53
@forwebtech I m still stack
@forwebtech
Aizaz Shahid
@aizazshahid
May 08 2017 07:54
@minnkhant-koko
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'; working fine at my side !
minnkhant-koko
@minnkhant-koko
May 08 2017 07:54
After 2 times refreshing pages
I got it
Aizaz Shahid
@aizazshahid
May 08 2017 07:54
copy that !
minnkhant-koko
@minnkhant-koko
May 08 2017 07:55
:+1:
Julian Mansueto
@julianmnst
May 08 2017 07:55
hi there people
minnkhant-koko
@minnkhant-koko
May 08 2017 07:55
Thanks again , Dude ! You are help me a lots! :smile:
@forwebtech
Vedant Kashyap
@vedant15188
May 08 2017 07:55

Hey guys I really couldn't understand the question itself... in truncate a string challenge... I'll post the question....

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

minnkhant-koko
@minnkhant-koko
May 08 2017 07:56
See you around everyone!
See you @forwebtech
Aizaz Shahid
@aizazshahid
May 08 2017 07:56
@minnkhant-koko helped you accidentally ! :laughing:
Julian Mansueto
@julianmnst
May 08 2017 07:56
i'm at finder keepers challenge. i think there's a bug or something
Vedant Kashyap
@vedant15188
May 08 2017 07:56

Output example ^^

Julian Mansueto
@julianmnst
May 08 2017 07:56
can anyone help me?
Markus Kiili
@Masd925
May 08 2017 07:57
@julianmnst Haven't heard of any bug. Post the code you have done.
Julian Mansueto
@julianmnst
May 08 2017 07:57
oh no i'm sotty
sorry
Aizaz Shahid
@aizazshahid
May 08 2017 07:57
@vedant15188 means your content, just show as short like A-tsket...
Julian Mansueto
@julianmnst
May 08 2017 07:57
sorry :(
@Masd925 thanks anyway!
CamperBot
@camperbot
May 08 2017 07:57
julianmnst sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 4036 | @masd925 |http://www.freecodecamp.com/masd925
Aizaz Shahid
@aizazshahid
May 08 2017 07:57
@vedant15188 what is your code anyway ?
Markus Kiili
@Masd925
May 08 2017 07:57
@julianmnst Decriptions are sometimes not so good.
Vedant Kashyap
@vedant15188
May 08 2017 07:57
@forwebtech what do you mean?
Aizaz Shahid
@aizazshahid
May 08 2017 07:58
@vedant15188 did you try something ??
Julian Mansueto
@julianmnst
May 08 2017 07:58
@Masd925 true haha and it doesn't get any better after hours of coding
Vedant Kashyap
@vedant15188
May 08 2017 07:59
@forwebtech i couldn't understand the damn question
the starting code on which i have to work on is:

function truncateString(str, num) {
// Clear out that junk in your trunk
return str;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
truncateString("Peter Piper picked a peck of pickled peppers", 14) should return "Peter Piper...".
truncateString("A-", 1) should return "A...".
truncateString("Absolutely Longer", 2) should return "Ab...".
OUTPUT EXAMPLES ^^
Julian Mansueto
@julianmnst
May 08 2017 08:01
return str.slice(0, -num)
the - is wrong
slice(0, num)
str.split('').slice(0, num)
@vedant15188
Valentin
@idefix92
May 08 2017 08:02
Hey guys I am stuck at 172 (Word Blanks). I don't know what is wanted from me :worried: any help? Please :)
Vedant Kashyap
@vedant15188
May 08 2017 08:03
@julianmnst what about the 3 dots...?
Robert Arifin
@renkachan
May 08 2017 08:04

function matchNumber(value) {
var abc = [12,5,8];
}

var filtered = [12, 5, 8, 130, 44].filter(matchNumber);
console.log(filtered);

this one is wrong, i want to match it with array, is it possible?
Claudio Restifo
@Marmiz
May 08 2017 08:05

@vedant15188 the description already described 3 cases:
1) the number to cut is bigger than 3 --> cut the string and INCLUDE the three ... in the string length.
2) the number is smaller or equal to 3 --> cut and ADD the three ... at the end
3) probably a case to just return the string if any of the previous case is not matched.

Plus there's a method suggested to use: slice()

@Aberoom
May 08 2017 08:06
@idefix92 What they want you to do is create a valid sentence, with your own input and the arguments passed in the function
Vedant Kashyap
@vedant15188
May 08 2017 08:06
@Marmiz that cleared up some doubts... thanks... I'll try again
CamperBot
@camperbot
May 08 2017 08:06
vedant15188 sends brownie points to @marmiz :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
May 08 2017 08:06
@renkachan You need to return true or false from the filter callback function matchNumber. The value is the array element being iterated by filter and you need to return true for those elements that you like filter to keep.
CamperBot
@camperbot
May 08 2017 08:06
Robert Arifin
@renkachan
May 08 2017 08:07
@Masd925 i try to return abc ,it doesnt work
Julian Mansueto
@julianmnst
May 08 2017 08:08
@vedant15188 it says: However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.
Markus Kiili
@Masd925
May 08 2017 08:08
@renkachan Try return abc.indexOf(value)>-1;
Claudio Restifo
@Marmiz
May 08 2017 08:08
@vedant15188 remember also that there's no need to add the three ... if I'm not performing any cut
(and that's why there's a case where the string is returned exactly as it is, as you asked)
Vedant Kashyap
@vedant15188
May 08 2017 08:08
@idefix92 just use those words to create a sentence... so basically you just have to insert words like is/am/are bla bla any of kind of words... the sentence might not mean something but it will complete the challenge lol
Julian Mansueto
@julianmnst
May 08 2017 08:09
@vedant15188 Ok i already did this challenge but now i just don't really understand i
t
Valentin
@idefix92
May 08 2017 08:09
@vedant15188 @Aberoom thank you! I will try to do my best haha
CamperBot
@camperbot
May 08 2017 08:09
idefix92 sends brownie points to @vedant15188 and @aberoom :sparkles: :thumbsup: :sparkles:
@Aberoom
May 08 2017 08:09
@idefix92 @vedant15188 yeah it doesn't even have to make any sense, they just want you to separate the arguments with spaces and add punctuation. But you can fit as many words as you want in there.
Valentin
@idefix92
May 08 2017 08:09
thx!
Vedant Kashyap
@vedant15188
May 08 2017 08:10

we did NOT add the 3 dots because i haven't actually sliced any part of the string .... yeah?

Robert Arifin
@renkachan
May 08 2017 08:10
@Masd925 thanks, it works, but i am not sure, can i ask a couple of questions ?
CamperBot
@camperbot
May 08 2017 08:10
renkachan sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
May 08 2017 08:11
@renkachan Sure.
CamperBot
@camperbot
May 08 2017 08:11
api offline
Markus Kiili
@Masd925
May 08 2017 08:12
@renkachan The filter method automatically iterates the array and passes each element to the callback function you provide. It keeps those that return a truthy value from the callback. So here it keeps those that are found on the array abc.
Because abc.indexOf(value)>-1 is true when value is found on abc.
Aizaz Shahid
@aizazshahid
May 08 2017 08:14
cbot
CamperBot
@camperbot
May 08 2017 08:14
you called?
Aizaz Shahid
@aizazshahid
May 08 2017 08:14
api online ?
cbot api online
CamperBot
@camperbot
May 08 2017 08:14
you called?
Aizaz Shahid
@aizazshahid
May 08 2017 08:14
no !
seems, just know how to ask ?
Ming Zhu
@chocobrownie
May 08 2017 08:15
Hi, I am doing the Twitch TV project, I'm imagining if I have 100 channels to show, when I only want to show whose online, there could be 50, there could be 2, there could be 70 and it varies. I want to show one box for each channel that happens to be online. Do I have to create 100 boxes and play with hide/show property? Or there's a smart way to program this html boxes?
@Aberoom
May 08 2017 08:16
@vedant15188 you should be able to see the required output when you try to test your code. If it fails just check what exactly needs to be changed and alter your code accordingly.
Robert Arifin
@renkachan
May 08 2017 08:16
@Masd925 ok , i got it that filter method automatically iterate it. But, I still dont get it why value is used for the indexOf, why its not abc.indexOf(abc) > -1?
Ming Zhu
@chocobrownie
May 08 2017 08:16
Because 100 boxes is definitely a pain in the ass
Aizaz Shahid
@aizazshahid
May 08 2017 08:17
@chocobrownie why don't you automate it ?
@Aberoom
May 08 2017 08:17
@chocobrownie what if you made a function that created a box for every online channel up to 100 boxes.
Ming Zhu
@chocobrownie
May 08 2017 08:18
@forwebtech How do I automate html? With jQuery?
The formatting could be complicated to program with jQuery
Aizaz Shahid
@aizazshahid
May 08 2017 08:18
yes you can make html boxes with JQuery !
so don't use JQuery just use vanilla javascript!
Vedant Kashyap
@vedant15188
May 08 2017 08:19
@forwebtech @julianmnst @Aberoom Thanks guys
CamperBot
@camperbot
May 08 2017 08:19
vedant15188 sends brownie points to @forwebtech and @julianmnst and @aberoom :sparkles: :thumbsup: :sparkles:
Ming Zhu
@chocobrownie
May 08 2017 08:19
Hmm...how may I ask? In code pen JS and HTML is in completely different sessions, how do I mix them? @forwebtech @Aberoom
SAURABH SHEORAIN
@SSheorain
May 08 2017 08:19
Aizaz Shahid
@aizazshahid
May 08 2017 08:21
@chocobrownie :) you don't have to worry about that actually it will show on your html page .
ok try to do document.write("something")
@Aberoom
May 08 2017 08:22
@SSheorain Looks cool. Try to put a default unit of measurement (C or F) depending on location (basically if the IP is from the US, default is F, you know what I mean?)
Ming Zhu
@chocobrownie
May 08 2017 08:22
Claudio Restifo
@Marmiz
May 08 2017 08:23

@forwebtech

so don't use JQuery just use vanilla javascript!

The vanilla JS homepage cracks me every time :laughing: :laughing:

Aizaz Shahid
@aizazshahid
May 08 2017 08:25
@Marmiz did you really open their library file !
it has just two comments in it.
Ming Zhu
@chocobrownie
May 08 2017 08:26
@forwebtech I definitely have new toys to play with now, thanks... just making sure this is vanilla JavaScript right?
CamperBot
@camperbot
May 08 2017 08:26
chocobrownie sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
Aizaz Shahid
@aizazshahid
May 08 2017 08:27
@chocobrownie simple JS also called Vanilla JS
Claudio Restifo
@Marmiz
May 08 2017 08:27

@forwebtech no but from time to time looking at their page gives me a good laugh!
I mean... this is great!

To use Vanilla JS, just put the following code anywhere in your application's HTML:
<script src="path/to/vanilla.js"></script>
When you're ready to move your application to a production deployment, switch to the much faster method:

That's right - no code at all. Vanilla JS is so popular that browsers have been automatically loading it for over a decade.

especially since I'm one of those to use libraries even when not needed :stuck_out_tongue:

Aizaz Shahid
@aizazshahid
May 08 2017 08:28
well its depend !
random
@toasted121
May 08 2017 08:29
Hi, does anyone know about JSON APIs? I'm stuck calling with ajax and reading in the JSON.
Ming Zhu
@chocobrownie
May 08 2017 08:29
Lmao
random
@toasted121
May 08 2017 08:29
keep getting error
SAURABH SHEORAIN
@SSheorain
May 08 2017 08:31
@Aberoom thanks and i'll try
CamperBot
@camperbot
May 08 2017 08:31
ssheorain sends brownie points to @aberoom :sparkles: :thumbsup: :sparkles:
Ming Zhu
@chocobrownie
May 08 2017 08:32
@toasted121 1.you didnt install jquery/jquery UI
2.the message class is not really passed to anywhere
3.json is not a variable, the variable passed down to success can be anything
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:33
Stephen James
@sjames1958gm
May 08 2017 08:33
@toasted121 You are trying to get from a site using an http:// URL from a https:// site it is not allowed.
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:33
i dont know
Ogundele Olumide
@Lumexralph
May 08 2017 08:33
@sjames1958gm another pic :smile: ..... good morning
Stephen James
@sjames1958gm
May 08 2017 08:33
@Lumexralph :wave:
Ming Zhu
@chocobrownie
May 08 2017 08:33
4.json format and http webpage doesn't really work, try jsonp and find a https api
Aviran Avraham Swissa
@aaswissa
May 08 2017 08:34
Good morming @Lumexralph
Stephen James
@sjames1958gm
May 08 2017 08:34
@santhu342 You were supposed to copy this string. "FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine"
Ogundele Olumide
@Lumexralph
May 08 2017 08:34
@aaswissa good morning
Aviran Avraham Swissa
@aaswissa
May 08 2017 08:34
I don't know how to start Word Blanks...
@Aberoom
May 08 2017 08:34
@santhu342 Yeah just read the errors on your test. You have spaces, and you haven't escaped backslash twice. Just fix those errors and youll complete the problem.
Aleksander Gębicki
@Takumar
May 08 2017 08:35
@aaswissa just create sentence using given words (parameters of function) and assign such created sentence to the variable and return it from your function.
Aviran Avraham Swissa
@aaswissa
May 08 2017 08:35
Tried many ways with + operator and .length
Ogundele Olumide
@Lumexralph
May 08 2017 08:35
@santhu342 FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine
@Aberoom
May 08 2017 08:35
@aaswissa You want the script to return a sentence that is filled with your input, and the arguments passed in the function. Basically, make sure there is correct spacing between words and punctuation.
Aleksander Gębicki
@Takumar
May 08 2017 08:35
@aaswissa you don't need to check length of string, just concatenate words with + operator. But remember about punctuation and spaces.
Stephen James
@sjames1958gm
May 08 2017 08:36
@aaswissa Use the four parameters myNoun, myAdjective, etc. plus other strings values to build a string
Ogundele Olumide
@Lumexralph
May 08 2017 08:36
@aaswissa you need to form a string(sentence or phrase) by concatenating the strings held by the 4 parameters of your function and assigning it to result
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:37
@Lumexralph its not working
Aviran Avraham Swissa
@aaswissa
May 08 2017 08:37
Okay I go to check meanwhile tnx @Takumar @sjames1958gm @Lumexralph
CamperBot
@camperbot
May 08 2017 08:37
aaswissa sends brownie points to @takumar and @sjames1958gm and @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1674 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 3575 | @takumar |http://www.freecodecamp.com/takumar
:star2: 7176 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Ogundele Olumide
@Lumexralph
May 08 2017 08:37
@santhu342 show what you have
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:38
Ogundele Olumide
@Lumexralph
May 08 2017 08:38
@santhu342 can you post the code here?
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:38
var myStr = "FirstLine \nSecondLine \rThirdLine";
water-melon91
@water-melon91
May 08 2017 08:39
how to used reaminder
Ogundele Olumide
@Lumexralph
May 08 2017 08:39
@santhu342 eliminate any space between your string
water-melon91
@water-melon91
May 08 2017 08:39
i don't understand
Ogundele Olumide
@Lumexralph
May 08 2017 08:39
@santhu342 you've not escaped backslash \\
@water-melon91 do you know how % works?
water-melon91
@water-melon91
May 08 2017 08:41
yes % is divided
sorry modulus
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:42
@Lumexralph its not working
Claudio Restifo
@Marmiz
May 08 2017 08:42
@water-melon91 % means "give me back the reminder"
so:
num % num  // return the reminder of this operation
12 % 5 // 2
Markus Kiili
@Masd925
May 08 2017 08:42
@renkachan Filter passes each array element into the callback function as value. That is why value is used there.
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:42
var myStr = "FirstLine \n \SecondLine\ \rThirdLine ";
var myStr = "FirstLine \n \SecondLine\ \rThirdLine "; // Change this line
Markus Kiili
@Masd925
May 08 2017 08:46
@Lumexralph @Takumar Morning.
Santhosh Kumar Rajagiri
@santhu342
May 08 2017 08:46
error is
myStr should have encoded text with the proper escape sequences and no spacing.
Ogundele Olumide
@Lumexralph
May 08 2017 08:50
@water-melon91
5 / 3.....  is  1 remaining  2,  % returns that remaining value  (2)
May 08 2017 08:52
Aleksander Gębicki
@Takumar
May 08 2017 08:52
Hello @Masd925, how are you doing today?
Ogundele Olumide
@Lumexralph
May 08 2017 08:52
@santhu342 "FirstLine\n\\SecondLine\\\rThirdLine "
@Masd925 Hey Bro! :smile:
Markus Kiili
@Masd925
May 08 2017 08:52
Aleksander Gębicki
@Takumar
May 08 2017 08:53
@auswade you have to call function processArg() below comment: // Only change code below this line
Pass it argument 7 and assign returned value to variable.
You need to create single line of code.
Enric Llopis Fabra
@qiqete
May 08 2017 08:54

function uniteUnique(arr) {
return arr;
}

console.log(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])); //Returns [1,2,3]
//Why it doesn't return [1, 3, 2], [5, 2, 1, 4], [2, 1]??
Stephen James
@sjames1958gm
May 08 2017 08:54
@water-melon91 You have to remember that only variables can go on the left of the =
variable = expression.
where x % y is an expression.
Aleksander Gębicki
@Takumar
May 08 2017 08:54
@Masd925 I'm waiting for some results in work, so I made a little break and entered this chat :-)
Blauelf
@Blauelf
May 08 2017 08:54
@qiqete You might want to use the arguments object, an array-like containing all the arguments passed to the function.
May 08 2017 08:54
ok thanks...i think the "return item;" has me confused
Enric Llopis Fabra
@qiqete
May 08 2017 08:55
@Blauelf ok, thanks
CamperBot
@camperbot
May 08 2017 08:55
qiqete sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star2: 4067 | @blauelf |http://www.freecodecamp.com/blauelf
May 08 2017 08:55
@Takumar ok thanks...i think the "return item;" has me confused
CamperBot
@camperbot
May 08 2017 08:55
auswade sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star2: 3577 | @takumar |http://www.freecodecamp.com/takumar
Bogdan Gatej
@Bogdan2992
May 08 2017 08:55
hello I have a question this is my code for getting the geolocation is it correct or no't ?
function getLocation(){
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
} else {
alert("Geolocation is not supported by this browser.");
}
function geoSuccess(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
alert("lat:" + lat + " lng:" + lng);
}
function geoError() {
}}
random
@toasted121
May 08 2017 08:56
@sjames1958gm I just saw that answer, that's probably what it is, so it's trying to authenticate on the way through, I'll check that out, thanks.
CamperBot
@camperbot
May 08 2017 08:56
toasted121 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 7177 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Bogdan Gatej
@Bogdan2992
May 08 2017 08:56
and how can i log the lat and lng
May 08 2017 08:57
@Takumar were you on the test"Stand in Line"?
water-melon91
@water-melon91
May 08 2017 08:58
thanks all ,
Aleksander Gębicki
@Takumar
May 08 2017 08:58
i think i posted the one before the one that i am stuck on... i think i have to modify the contents of the array
Shann
@lu-visser
May 08 2017 08:59
Hi all, I'm sure my problem would be rather silly for you. But here is where I'm currently stuck at
Ogundele Olumide
@Lumexralph
May 08 2017 09:00
@auswade can you post the code here?
@lu-visser where?
Shann
@lu-visser
May 08 2017 09:00
FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine (<-- this is the instruction) var myStr = "FirstLine\n\SecondLine\\rThirdline"; (<-- this is my code)
and this is the error message --> myStr should have encoded text with the proper escape sequences and no spacing.
Aleksander Gębicki
@Takumar
May 08 2017 09:01
@auswade yes you are right. You get array as argument of your function and you have to modify it.
Ogundele Olumide
@Lumexralph
May 08 2017 09:01
@lu-visser Thirdline ==> ThirdLine
May 08 2017 09:01

@Lumexralph
function nextInLine(arr, item) {

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

Ogundele Olumide
@Lumexralph
May 08 2017 09:01
@auswade you need 2 array methods
Shann
@lu-visser
May 08 2017 09:01
@Lumexralph ahh.... man... silly me! Let me try
@Lumexralph Thanks so so much! Always the silly mistakes..
CamperBot
@camperbot
May 08 2017 09:02
lu-visser sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1675 | @lumexralph |http://www.freecodecamp.com/lumexralph
May 08 2017 09:02
i tried using push, pop & splice, but i need to use them in a better environment.
Ogundele Olumide
@Lumexralph
May 08 2017 09:02
@auswade 1. to add item to the end arr array 2. ro remove the first element in arr and return that removed element
@lu-visser :+1:
heroiczero
@heroiczero
May 08 2017 09:03
@auswade review Manipulate array ...` in Free code camp map