These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Apr 2017
Joseph
@revisualize
Apr 23 2017 00:01 UTC
Hello.
Keon Samuel
@keonsam
Apr 23 2017 00:04 UTC
I made a monstrosity of a code who have time to look though it?
if(isTurn ===false){
var arr=["#firstRow1","#firstRow2","#firstRow3","#secondRow1","#secondRow2","#secondRow3","#thirdRow1","#thirdRow2","#thirdRow2"];
for(var i=0;i<arr.length;i++){
if($(arr[i]).html()==""){$(arr[i]).html(computer);
isTurn = true;
$(".boxDim").on("click"); break; } } } for some reason that is not working.$(arr[i]).html(computer);
that part.
Jocelyn van Dam
@Jocelyn114
Apr 23 2017 00:10 UTC
hey can anyone help me on a beginner javascript challenge?? it seems pretty simple but can't figure it out
Danny Welstad
@GoonTwo
Apr 23 2017 00:10 UTC
Hi guys, having some trouble with my tic tac toe logic. Anybody have any ideas why this logic isn't giving me true? The current state is meant to represent the first winning case. I'm using the every() method to determine if any of the winning cases are being met by player X (represented by 1)
  var winningCases = [[1,2,3],[1,5,9],[1,4,7],[2,5,6],[3,5,7],[3,6,9],[4,5,6],[7,8,9]]
var currentState = [1,1,1,0,0,0,0,0,0]
var X = 1;
var O = -1;

function terminal(player){
for (var i = 0; i < winningCases.length; i++){
if(winningCases[i].every(function(Val){
currentState[(Val-1)] === player;
})){
return true;
}
}
}
terminal(X);
Moisés Man
@moigithub
Apr 23 2017 00:24 UTC

winingcases.every
[1,4,7].every
on the callback val would be each of those values

currentState[1]  === player
currentState[4]  === player
currentState[7]  === player

@GoonTwo
its that correct ?

Stephen James
@sjames1958gm
Apr 23 2017 00:24 UTC
@Jocelyn114 which challenge
Danny Welstad
@GoonTwo
Apr 23 2017 00:27 UTC
@moigithub yes that looks right
Moisés Man
@moigithub
Apr 23 2017 00:27 UTC
currentstate array will ALWAYS have 9 values ??? @GoonTwo
array are 0 index based
Stephen James
@sjames1958gm
Apr 23 2017 00:27 UTC
@keonsam what does the HTML look like for one of those IDs?
Jason Luboff
@JLuboff
Apr 23 2017 00:27 UTC
@sjames1958gm I'm sadden to see you're no longer doing Star Wars.
Danny Welstad
@GoonTwo
Apr 23 2017 00:27 UTC
@moigithub yes, they represent the 9 spots on a tic tac toe board, moving left to right top to bottom
Stephen James
@sjames1958gm
Apr 23 2017 00:27 UTC
@JLuboff Just felt stoogey today
Jason Luboff
@JLuboff
Apr 23 2017 00:28 UTC
:D
Danny Welstad
@GoonTwo
Apr 23 2017 00:28 UTC
@moigithub so teh current state I have on there would be a win on the top row
Stephen James
@sjames1958gm
Apr 23 2017 00:28 UTC
@GoonTwo Why not put zero based values in the winning array- that way you don't have to have Val -1
Danny Welstad
@GoonTwo
Apr 23 2017 00:28 UTC
@moigithub yes except I am using currentSate[Val -1]
@sjames1958gm good point. I'll cahnge that
Keon Samuel
@keonsam
Apr 23 2017 00:30 UTC
@sjames1958gm
Danny Welstad
@GoonTwo
Apr 23 2017 00:30 UTC
@sjames1958gm not sure that's gonna make it work though. I did some console logging and it looks like it returns true and then immediatly returns false without going back through for the second value
Stephen James
@sjames1958gm
Apr 23 2017 00:30 UTC
@keonsam remove the # from id="#firstRow1"
Keon Samuel
@keonsam
Apr 23 2017 00:31 UTC
how will I target it will Jquery then?
with*
hekri-d
@hekri-d
Apr 23 2017 00:32 UTC
@sjames1958gm not wanting to interfere while you help others but just a quick question if you find the time. Would it be acceptable to solve the tic-tac-toe challenge with a huge bunch of if else statements /
Laura Veee
@Cyclokitty
Apr 23 2017 00:32 UTC
@sjames1958gm @JLuboff everybody knows Curly was the talented one
Moisés Man
@moigithub
Apr 23 2017 00:32 UTC
@GoonTwo return missing ?
from every callback
Keon Samuel
@keonsam
Apr 23 2017 00:32 UTC
lol you are right
Jason Luboff
@JLuboff
Apr 23 2017 00:32 UTC
@Cyclokitty Oh absolutely.
Keon Samuel
@keonsam
Apr 23 2017 00:32 UTC
@sjames1958gm thanks
CamperBot
@camperbot
Apr 23 2017 00:32 UTC
keonsam sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6893 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Laura Veee
@Cyclokitty
Apr 23 2017 00:32 UTC
nyuck nyuck nyuck
Stephen James
@sjames1958gm
Apr 23 2017 00:32 UTC
@hekri-d I guess but that kind of code is very error prone and hard to debug. Data driven code usually results in less code/ less bugs
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 00:33 UTC

hey guys, i just get stuck in counting cards. Need help to understand my faults, I can't get result for:

Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"

here is my code

'''

var count = 0;

function cc(card) {
// Only change code below this line
if(card <= 6){
return ++count + " Bet";
}else if(card == 7 || card == 8 || card == 9){
return count + " Hold";
}else if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
return --count + " Hold";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
cc(7); cc(8); cc(9);
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');
cc(3); cc(7); cc("Q"); cc(8); cc("A");
cc(2); cc("J"); cc(9); cc(2); cc(7);
cc(2); cc(2); cc(10);
cc(3); cc(2); cc("A"); cc(10); cc("K");
'''

CamperBot
@camperbot
Apr 23 2017 00:33 UTC
:bulb: to format code use backticks!  more info
Stephen James
@sjames1958gm
Apr 23 2017 00:33 UTC
@Cyclokitty Why I outgha
Danny Welstad
@GoonTwo
Apr 23 2017 00:33 UTC
@moigithub ugh... always such a dumb mistake lol
thanks so much
Laura Veee
@Cyclokitty
Apr 23 2017 00:33 UTC
@sjames1958gm Soitenly!
Stephen James
@sjames1958gm
Apr 23 2017 00:34 UTC
@a2-zubair Only change count in your if / else if that tests card
After that compare count to zero per the instrutions
hekri-d
@hekri-d
Apr 23 2017 00:34 UTC
@sjames1958gm ok. Thanks. The thing is though I've been trying to come up with a better solution for it since last Monday and the game does seem to be a little bit over me. I can't come up with anything better without going online and copying stuff from the internet
CamperBot
@camperbot
Apr 23 2017 00:34 UTC
hekri-d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6894 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Moisés Man
@moigithub
Apr 23 2017 00:35 UTC
@hekri-d i did a bunch of if/else statements
too lazy to check minimax algorithm
Stephen James
@sjames1958gm
Apr 23 2017 00:36 UTC
@hekri-d make sure your code is modular then if you want to improve a function you can make the change in isolation.
hekri-d
@hekri-d
Apr 23 2017 00:36 UTC
@sjames1958gm OK. Thanks for the tips. :+1:
CamperBot
@camperbot
Apr 23 2017 00:36 UTC
hekri-d sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: hekri-d already gave sjames1958gm points
Stephen James
@sjames1958gm
Apr 23 2017 00:36 UTC
@keonsam The # goes in the selector not in the id - the # in the selector says look for an ID matching what is after the #
Saboor Malik
@MathematicsCoding
Apr 23 2017 00:48 UTC
@sjames1958gm hey
You know API projects?
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 00:50 UTC
@sjames1958gm i don't get it my fault. Can you help to understand error of my code?
Saboor Malik
@MathematicsCoding
Apr 23 2017 00:50 UTC
Can you help me with twitch tv?
@moigithub what about you? :\
Laura Veee
@Cyclokitty
Apr 23 2017 00:52 UTC
@a2-zubair This line? And other's like it: return ++count + " Bet"; try count++; return count + ' Bet';
David Rowan III
@rowanD72
Apr 23 2017 00:54 UTC
hello everyone
Laura Veee
@Cyclokitty
Apr 23 2017 00:59 UTC
@a2-zubair oh wait you need another if/else if at the end if the count <= 0 you return the count and hold. > 0 and you return count and bet
Joseph
@revisualize
Apr 23 2017 01:07 UTC
Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
You should NOT be returning based on the value of the card. The value of card should only be adding or subtracting 1 from the global variable count.
The value of the global variable count is used to determine the return statement.
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 01:13 UTC
is that right way to solve this problem:
var count = 0;

function cc(card) {
// Only change code below this line
if(card <= 6){
++count;
}else if(card == 7 || card == 8 || card == 9){
count = count;
}else if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
count--;
}

if(count <= 0){
return count + " Hold";
}else if (count > 0){
return count + " Bet";
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);
cc(7); cc(8); cc(9);
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');
cc(3); cc(7); cc("Q"); cc(8); cc("A");
cc(2); cc("J"); cc(9); cc(2); cc(7);
cc(2); cc(2); cc(10);
cc(3); cc(2); cc("A"); cc(10); cc("K");
Saboor Malik
@MathematicsCoding
Apr 23 2017 01:17 UTC
@revisualize hey
Can you help me with twitch tv?
Stephen James
@sjames1958gm
Apr 23 2017 01:21 UTC
@a2-zubair It is a common way. Don't really want to use the word "right" because there are other valid solutions
Laura Veee
@Cyclokitty
Apr 23 2017 01:22 UTC
@a2-zubair I used a switch statement
Manish Giri
@Manish-Giri
Apr 23 2017 01:23 UTC
@a2-zubair you could omit this
else if(card == 7 || card == 8 || card == 9){
count = count;
}
@sjames1958gm :wave:
Stephen James
@sjames1958gm
Apr 23 2017 01:23 UTC
@Manish-Giri :wave:
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 01:24 UTC
@sjames1958gm @Cyclokitty may i get your solution for this task?
phatmancode
@phatmancode
Apr 23 2017 01:24 UTC
"FirstLine\nSecondLine\rThirdLine"
where would i put backlash?
Stephen James
@sjames1958gm
Apr 23 2017 01:24 UTC
Laura Veee
@Cyclokitty
Apr 23 2017 01:24 UTC
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 += 0;
break;
case 10:
case 'J':
case 'K':
case 'Q':
case 'A':
count--;

}
if (count <=0){
return count + ' Hold';
}
else if (count > 0) {
return count + ' Bet';
}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
super mega code wall
Jason Luboff
@JLuboff
Apr 23 2017 01:25 UTC
@phatmancode Before and after SecondLine
Stephen James
@sjames1958gm
Apr 23 2017 01:25 UTC
@phatmancode On either side of SecondLine would be an escaped backslash
phatmancode
@phatmancode
Apr 23 2017 01:26 UTC
"FirstLine\nSecondLine\rThirdLine"
Jason Luboff
@JLuboff
Apr 23 2017 01:26 UTC
You need to escape them \\
phatmancode
@phatmancode
Apr 23 2017 01:26 UTC
it was backlash carriage return
so \n?
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 01:27 UTC
@sjames1958gm @Cyclokitty thanks guys.
CamperBot
@camperbot
Apr 23 2017 01:27 UTC
a2-zubair sends brownie points to @sjames1958gm and @cyclokitty :sparkles: :thumbsup: :sparkles:
:cookie: 945 | @cyclokitty |http://www.freecodecamp.com/cyclokitty
:star2: 6895 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Apr 23 2017 01:27 UTC
\n\\
Stephen James
@sjames1958gm
Apr 23 2017 01:27 UTC
:+1:
@phatmancode backslash carriage-return is \\\r
phatmancode
@phatmancode
Apr 23 2017 01:28 UTC
myStr should have encoded text with the proper escape sequences and no spacing.
"FirstLine\n\SecondLine\r\ThirdLine"
Jason Luboff
@JLuboff
Apr 23 2017 01:30 UTC
Your backslash should be before the carriage return...so \n\\SecondLine\\\r
phatmancode
@phatmancode
Apr 23 2017 01:30 UTC
thankyou @JLuboff
CamperBot
@camperbot
Apr 23 2017 01:30 UTC
phatmancode sends brownie points to @jluboff :sparkles: :thumbsup: :sparkles:
:star2: 1586 | @jluboff |http://www.freecodecamp.com/jluboff
phatmancode
@phatmancode
Apr 23 2017 01:31 UTC
damn that was confusing
thankyou @sjames1958gm
CamperBot
@camperbot
Apr 23 2017 01:31 UTC
phatmancode sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6896 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 01:31 UTC
@sjames1958gm @Cyclokitty i should choose switch for this task. switch is the right choice for this.
Laura Veee
@Cyclokitty
Apr 23 2017 01:32 UTC
@a2-zubair switch is nice. Lots to type though. I tried doing a Caesar's Cipher using switch and the typing drove me spare.
Mohamed Derhalli
@derhallim
Apr 23 2017 01:32 UTC
:v:
Stephen James
@sjames1958gm
Apr 23 2017 01:33 UTC
@a2-zubair You could even do something like table = { 2: 1, 3: 1, 4: 1, 5: 1, 6:1, 10: -1} and so on for J-A
then you could use object lookup count += table.hasOwnProperty(card) ? table[card] : 0;
Abdullah-Al-Zubair
@a2-zubair
Apr 23 2017 01:36 UTC
@Cyclokitty @sjames1958gm i'll remember that.
CatherineKa
@CatherineKa
Apr 23 2017 01:37 UTC
Hello guys. Anyone knows how to capitalize the first letter of a word and make sure the rest of word is in lower case?
Stephen James
@sjames1958gm
Apr 23 2017 01:37 UTC
@CatherineKa Since strings are immutable you have to build a new string from the existing word
CatherineKa
@CatherineKa
Apr 23 2017 01:39 UTC
@sjames1958gm Yeah, and any function or property can realize the requirement?
Stephen James
@sjames1958gm
Apr 23 2017 01:39 UTC
@CatherineKa word[0] + toUpperCase() and slice() along with concatentation
oops
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:41 UTC
@CatherineKa word[0].toUpperCase() in your case
@sjames1958gm wow your profile photo changes every day
:D
Stephen James
@sjames1958gm
Apr 23 2017 01:42 UTC
@kuriakinzeng I have no idea what you are talking about - :)
Blara02
@Blara02
Apr 23 2017 01:43 UTC

whats up my keyboard warriors; how do you do?

I need some help with my code. I dont understand why this isnt working:
function nextInLine(arr, item) {
// Your code here
arr + "," + item;
var myReturn = arr.shift();
return myReturn; // 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));

Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:44 UTC
Instead of arr + "," + item; try arr.push(item)
@Blara02
Blara02
@Blara02
Apr 23 2017 01:46 UTC
You are a beautiful beautiful genius.
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:46 UTC
lol
Blara02
@Blara02
Apr 23 2017 01:46 UTC
thanks for the help
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:46 UTC
no problem
use functions like push and shift to handle array
there are many more
Joe Narvaez
@wordyallen
Apr 23 2017 01:51 UTC
any react person that avoids mutation here?
rooms
CamperBot
@camperbot
Apr 23 2017 01:51 UTC

freeCodeCamp rooms:

:point_right: Here is a list of our official chat rooms
Joseph
@revisualize
Apr 23 2017 01:52 UTC
@wordyallen You're coming to a basic JavaScript chat trying to get help with React Mutations?
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:52 UTC
Avoids mutation? For reducers?
Joseph
@revisualize
Apr 23 2017 01:52 UTC
@wordyallen You silly man.
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:53 UTC
@revisualize there isn't a room for react though
Henry
@GitHub-Henry
Apr 23 2017 01:54 UTC
@kuriakinzeng perhaps add a room, maybe others will join
there's an angular room, why not react
Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 01:55 UTC
I am not able to
Has to be admin ?
Henry
@GitHub-Henry
Apr 23 2017 01:56 UTC
@kuriakinzeng r u sure, i have an add room button and i'm not an admin
Stephen James
@sjames1958gm
Apr 23 2017 01:56 UTC
There is a front-end room.
Long Nguyen
@longnt80
Apr 23 2017 01:57 UTC
@kuriakinzeng
Go here
Find the button CREATE YOUR OWN
Joseph
@revisualize
Apr 23 2017 01:59 UTC
https://gitter.im/FreeCodeCamp/HelpFrontEnd HelpFrontEnd get help with our front end projects from your fellow campers
Derien Stephens
@haniaroad
Apr 23 2017 02:00 UTC
Could someone tell me what I'm doing wrong here? The task reads, "You should have multiplied the result of Math.random by 10 to make it a number that is between zero and nine."

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

Math.floor(Math.random(randomNumberBetween0and19) * 10);

return randomNumberBetween0and19;
}

Kuriakin Zeng
@kuriakinzeng
Apr 23 2017 02:02 UTC
Are you supposed to return 0 to 19?
Long Nguyen
@longnt80
Apr 23 2017 02:05 UTC
@haniaroad
This line
randomNumberBetween0and19
is their example, it should not be in your code
@haniaroad
you're supposed to write a new line of code
@haniaroad
use this
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
as preference to write your code
Roger Braun
@roger1891
Apr 23 2017 02:06 UTC
has anybody ever proceeded with the react challenge after the front end dev certificate? Do you have any cool references to what to study?
Stephen James
@sjames1958gm
Apr 23 2017 02:06 UTC
@haniaroad Math.floor returns a value that you should return. Math.random takes no parameter
Derien Stephens
@haniaroad
Apr 23 2017 02:08 UTC
Okay, I've tried the task this way but it's now saying, "SyntaxError: Illegal return statement"?? @sjames1958gm @longnt80

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

Math.floor(Math.random() * 10);

}

return randomWholeNum;

Kyle Janka
@KTJanka
Apr 23 2017 02:08 UTC
Ok I am stuck my console is suppose to say I am a "double quoted" string inside "double quotes".
var myStr = "I am a \"double quoted\"string inside\"double qoutes\".";
not sure what I am doing wrong
Stephen James
@sjames1958gm
Apr 23 2017 02:09 UTC
@haniaroad return outside of function is not allowed.
you can return the value of calling a function.
return Math.floor(Math.random() * 10);
@EverythingEpi Make sure the spacing is correct and misspelled qoutes
Kyle Janka
@KTJanka
Apr 23 2017 02:10 UTC
oops goodness
Stephen James
@sjames1958gm
Apr 23 2017 02:10 UTC
@EverythingEpi Looks like missing spaces on either side of string inside
patrickjbritton
@patrickjbritton
Apr 23 2017 02:11 UTC

'''

function testSize(num) {
// Only change code below this line
if (num >= 20){
return "Huge";
} else if (num >= 15 && num < 20){
return "Large";
} else if (num < 15 && num >= 10){
return "Medium";
} else if (num < 10 && num >= 5){
return "Small";
} else {
return "tiny";
}

// Only change code above this line
}

// Change this value to test
testSize(7);


CamperBot
@camperbot
Apr 23 2017 02:11 UTC
:bulb: to format code use backticks!  more info
patrickjbritton
@patrickjbritton
Apr 23 2017 02:11 UTC
ok, so, I can't get 4 to return tiny
everything else reads back fine
Kyle Janka
@KTJanka
Apr 23 2017 02:12 UTC
@sjames1958gm thank you! I really gotta practice this triple triple checking thing haha
CamperBot
@camperbot
Apr 23 2017 02:12 UTC
everythingepi sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6897 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 23 2017 02:12 UTC
@patrickjbritton Tiny or tiny?
@EverythingEpi For strings - best to copy/paste
Kyle Janka
@KTJanka
Apr 23 2017 02:13 UTC
@sjames1958gm I have been typing a lot of it to get my typing skills a bit faster
Stephen James
@sjames1958gm
Apr 23 2017 02:13 UTC
@EverythingEpi fair enough ;)
Derien Stephens
@haniaroad
Apr 23 2017 02:13 UTC
Okay, I've put the return back within the function. But any idea why this won't return an actual number? It's the only task that isn't listed as complete now. @sjames1958gm

var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.

Math.floor(Math.random() * 10);

return randomWholeNum;
}

Stephen James
@sjames1958gm
Apr 23 2017 02:14 UTC

@haniaroad Return the result of calling Math.floor - you are returning a reference to the function.

var num = Math.floor(Math.random() * 10);
return num;

or, simply

return Math.floor(Math.random() * 10);
Derien Stephens
@haniaroad
Apr 23 2017 02:16 UTC
Finally! The second option worked like a charm. Thanks a ton! @sjames1958gm
CamperBot
@camperbot
Apr 23 2017 02:16 UTC
haniaroad sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6898 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Long Nguyen
@longnt80
Apr 23 2017 02:16 UTC
@haniaroad
because the randomWholeNum() hasn't returned any value yet (before return randomWholeNum;)
CatherineKa
@CatherineKa
Apr 23 2017 02:18 UTC

Anyone knows how to do this case? Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.

For the purpose of this exercise, you should also capitalize connecting words like "the" and "of".

I need to split the string into an array, and then how to capitalize each first letter of word?
Andrew
@AndrewKTai
Apr 23 2017 02:23 UTC
@CatherineKa you can use .toUpperCase()
CatherineKa
@CatherineKa
Apr 23 2017 02:23 UTC
I know that method.
I just don't know how to capitalize each letter of each element in an array
capitalize letters of word is easy, just str.toUpperCase(),
Pagnito
@Pagnito
Apr 23 2017 02:27 UTC
when .each iterates over an object, does it iterate over the key and the value as two seperate properties?
Andrew
@AndrewKTai
Apr 23 2017 02:31 UTC
@CatherineKa once you've split the string into each word you can use charAt() and replaceAt()
Ogundele Olumide
@Lumexralph
Apr 23 2017 02:31 UTC
@Pagnito each on an object?
Pagnito
@Pagnito
Apr 23 2017 02:32 UTC
@Lumexralph yea $.each loop Keon Samuel @keonsam Apr 23 2017 02:32 UTC any here have the front end certi and is not working as a developer? Ogundele Olumide @Lumexralph Apr 23 2017 02:32 UTC @Pagnito jQuery? Pagnito @Pagnito Apr 23 2017 02:33 UTC @Lumexralph yea Ogundele Olumide @Lumexralph Apr 23 2017 02:33 UTC nah, been a while I used jQuery Pagnito @Pagnito Apr 23 2017 02:34 UTC @Lumexralph how come, if u domt mind me asking Ogundele Olumide @Lumexralph Apr 23 2017 02:35 UTC @CatherineKa split the string into an array, then loop through the array, and make each element to uppercase @Pagnito I chose to go VanillaJS my present project and others to come will be in VanillaJS Pagnito @Pagnito Apr 23 2017 02:36 UTC @Lumexralph i feel u, im plannin to go get off jquery too, once i get the front end certificate Ogundele Olumide @Lumexralph Apr 23 2017 02:37 UTC @Pagnito i have interest in react since it's the shout of everywhere but I'm not freaked by it cos frameworks will come and go but the language won't Treylerp @Treylerp Apr 23 2017 02:37 UTC function orderMyLogic(val) { if (val < 10) { return "Less than 10"; } else if (val < 5) { return "Less than 5"; } else { return "Greater than or equal to 10"; } } What am i supposed to reorder Ogundele Olumide @Lumexralph Apr 23 2017 02:38 UTC @Treylerp if (val < 5) means that val is also less than 10 so the second statement is never ran, you need to re-arrange the logic Pagnito @Pagnito Apr 23 2017 02:38 UTC @Lumexralph true true, ya i think its important to know vanilla Treylerp @Treylerp Apr 23 2017 02:38 UTC @Lumexralph Thanks CamperBot @camperbot Apr 23 2017 02:38 UTC treylerp sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles: :star2: 1554 | @lumexralph |http://www.freecodecamp.com/lumexralph Ogundele Olumide @Lumexralph Apr 23 2017 02:38 UTC @Pagnito yeah @Treylerp :+1: Harsh Patel @harshp814 Apr 23 2017 02:41 UTC var count = 0; function cc(card) { // Only change code below this line switch (card) { case 2, 3, 4, 5, 6: count++; break; case 7, 8, 9: count += 0; break; case 10, 'J', 'Q', 'K', 'A': count--; break; } if (count > 0) { return count + " Bet"; } else { return count + " Hold"; } // Only change code above this line } // Add/remove calls to test your function. // Note: Only the last will display cc(2); cc(3); cc(7); cc('K'); cc('A'); //cc(2); cc(3); cc(4); cc(5); cc(6); this is not working for me, i m on counting card challenge Ogundele Olumide @Lumexralph Apr 23 2017 02:42 UTC @harshp814 how does switch statement work? Harsh Patel @harshp814 Apr 23 2017 02:42 UTC can someone plz help it switches between cases Ogundele Olumide @Lumexralph Apr 23 2017 02:43 UTC @harshp814 take a lil time with this link it'll give you a better understanding of switch https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch Harsh Patel @harshp814 Apr 23 2017 02:43 UTC kk thank you Khoa Le @Zacele Apr 23 2017 02:44 UTC case only evaluate 1 value at a time Ogundele Olumide @Lumexralph Apr 23 2017 02:44 UTC @Rakesh18754 getting data..... ajax requests, right? patrickjbritton @patrickjbritton Apr 23 2017 02:44 UTC aha I figured it out lol I mean the code thing but pasted the wrong thing lol Khoa Le @Zacele Apr 23 2017 02:44 UTC @harshp814 case only evaluate 1 value at a time patrickjbritton @patrickjbritton Apr 23 2017 02:45 UTC  function testSize(num) { // Only change code below this line if (num >= 20){ return "Huge"; } else if (num >= 15 && num < 20){ return "Large"; } else if (num < 15 && num >= 10){ return "Medium"; } else if (num < 10 && num >= 5){ return "Small"; } else { return "tiny"; } // Only change code above this line } // Change this value to test testSize(7); RakeshNerkar @Rakesh18754 Apr 23 2017 02:45 UTC @Lumexralph it may or may not....it could be just an dummy json defined in it also Harsh Patel @harshp814 Apr 23 2017 02:45 UTC yea i thought i was being smart by putting all the cases together Khoa Le @Zacele Apr 23 2017 02:45 UTC @harshp814 you can nested multiple case by doing this trick case value1 : case value 2: ... expression... break; Harsh Patel @harshp814 Apr 23 2017 02:45 UTC thank you i will try putting them in one value RakeshNerkar @Rakesh18754 Apr 23 2017 02:46 UTC i have a function getData(){ //ONCE THIS GETS THE DATA IS PRESENT IT SHOULD TRIGGER 2 DIFFERENT FUNCTION ie. dataRecievedProcess1 and dataRecievedProcess2 //I KNOW THAT I HAVE TO USE CALL BACKS BUT CAN ANY ONE GIVE ME SYNTAX OR EXAMPLE } function dataRecievedProcess1(){ } function dataRecievedProcess2(){ } patrickjbritton @patrickjbritton Apr 23 2017 02:46 UTC But anyway, most numbers come back right but number under 5 not reading back tiny Ogundele Olumide @Lumexralph Apr 23 2017 02:47 UTC @Rakesh18754 then just call or execute the functions in the getData function Khoa Le @Zacele Apr 23 2017 02:48 UTC @harshp814 try to get all the number as a the primary case so these last case you can set your case as a default: . Saving you time RakeshNerkar @Rakesh18754 Apr 23 2017 02:48 UTC @Lumexralph but i dont know when data will come for eg ajax @Lumexralph patrickjbritton @patrickjbritton Apr 23 2017 02:48 UTC and sorry if someone already replied the chat bonkered on me Ogundele Olumide @Lumexralph Apr 23 2017 02:49 UTC @Rakesh18754 that's why you need an ajax and when the data is present or success, call the 2 functions Long Nguyen @longnt80 Apr 23 2017 02:49 UTC @patrickjbritton it's returned as tiny correctly patrickjbritton @patrickjbritton Apr 23 2017 02:49 UTC Aha I got it, thank you @sjames1958gm CamperBot @camperbot Apr 23 2017 02:49 UTC patrickjbritton sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 6899 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm patrickjbritton @patrickjbritton Apr 23 2017 02:49 UTC Proper capitalization is my nemesis Vamp @the-vampiire Apr 23 2017 02:59 UTC anyone know why I get this error? the stream and chat still run fine in the window but my console is displaying all of this red :( and on the actual twitch website I get this... is this normal? have I just never noticed that sites might be having all these errors in the background? I am confused how all these errors can be displaying on a seemingly polished website CatherineKa @CatherineKa Apr 23 2017 03:03 UTC function titleCase(str) { var newWord; array=str.split(" "); for (var i=0;i<array.length;i++){ firstLetter=array[i].slice(0,0).toUpperCase(); restLetter=array[i].slice(1).toLowerCase(); newWord=firstLetter[i]+restLetter[i]; newWord=newWord+" "; return newWord; } } titleCase("I'm a little tea pot"); anyone can tell me what's wrong with that? Moisés Man @moigithub Apr 23 2017 03:03 UTC @CatherineKa what slice(0,0) does ? CatherineKa @CatherineKa Apr 23 2017 03:04 UTC @moigithub capitalize the first letter of each word Ogundele Olumide @Lumexralph Apr 23 2017 03:04 UTC @CatherineKa nah Moisés Man @moigithub Apr 23 2017 03:04 UTC "hello".slice(0,0) returns "" <-- empty u can open devtools console.. and write that command there to test Ogundele Olumide @Lumexralph Apr 23 2017 03:05 UTC @CatherineKa slice starts at the index but stops before the next index @CatherineKa how do you think you can start from 0 but not reaching 1 index? CatherineKa @CatherineKa Apr 23 2017 03:06 UTC ok. I change 0 to 1. Ogundele Olumide @Lumexralph Apr 23 2017 03:07 UTC @CatherineKa which of the 0s ? CatherineKa @CatherineKa Apr 23 2017 03:07 UTC .slice(0,1) Ogundele Olumide @Lumexralph Apr 23 2017 03:07 UTC @CatherineKa try it out Moisés Man @moigithub Apr 23 2017 03:07 UTC IF firstLetter is this "h" what firstLetter[5] will return? newWord=firstLetter[i]+restLetter[i]; <-- asking about this why it have [i] @CatherineKa Ogundele Olumide @Lumexralph Apr 23 2017 03:09 UTC @CatherineKa newWord=newWord+" "; are you sure this won't return an error? no it won't CatherineKa @CatherineKa Apr 23 2017 03:10 UTC @moigithub I forgot to change it. newWord=firstLetter+restLetter; now it is like that Moisés Man @moigithub Apr 23 2017 03:10 UTC :+1: Jason G @Jay33Canada Apr 23 2017 03:10 UTC i've got a bit of a complicated question. how do i select the specific element i clicked on with an onclick event. the important thing to note is, there are a bunch of possible elements i might click on, but i need to know the value from the specific element i've clicked on. i hope that makes sense example //i'm going to get the user to click on one, how do i select the one they've clicked on with jquery? <p>somedata</p> <p>somedata</p> <p>somedata</p> <p>somedata</p> <p>somedata</p> CatherineKa @CatherineKa Apr 23 2017 03:10 UTC @Lumexralph Yeah, it wont return an error. but still achieve the desire effect not achieve the desire effect @Lumexralph Moisés Man @moigithub Apr 23 2017 03:11 UTC @CatherineKa what return does ? (conceptually) Ogundele Olumide @Lumexralph Apr 23 2017 03:11 UTC @Jay33Canada yeah it does, you can take advantage of this to reference the DOM element clicked CatherineKa @CatherineKa Apr 23 2017 03:12 UTC @moigithub Just the first word of the string Ogundele Olumide @Lumexralph Apr 23 2017 03:12 UTC @CatherineKa newWord=newWord+" "; do you know what this would do?, it'll always change the initial stored value of newWord CatherineKa @CatherineKa Apr 23 2017 03:13 UTC @moigithub like I'm in this case Jason G @Jay33Canada Apr 23 2017 03:13 UTC @Lumexralph something like,$(this).on('click', functioin(){do something})????
Moisés Man
@moigithub
Apr 23 2017 03:13 UTC
@CatherineKa return exit the function immediatelly (giving back a value)
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:13 UTC
@CatherineKa you need to just generate the string from your loop, @moigithub meant do you know what return does in a function?
Moisés Man
@moigithub
Apr 23 2017 03:14 UTC
soo that return will stop ur loop
processing only 1 word like u said
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:15 UTC
@Jay33Canada not totally, you can make a query selection for all p elements, add the click event and in the body of the callback you can do console.log(this); check your devTool console you'll see the element clicked
Jason G
@Jay33Canada
Apr 23 2017 03:16 UTC
ok i'll check that out @Lumexralph thanks
CamperBot
@camperbot
Apr 23 2017 03:16 UTC
jay33canada sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1555 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:17 UTC
@Jay33Canada :+1:
CatherineKa
@CatherineKa
Apr 23 2017 03:17 UTC
ok. I think where the problem is. give me some time to fix it. thanks. @Lumexralph @moigithub
CamperBot
@camperbot
Apr 23 2017 03:17 UTC
catherineka sends brownie points to @lumexralph and @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1556 | @lumexralph |http://www.freecodecamp.com/lumexralph
:star2: 3150 | @moigithub |http://www.freecodecamp.com/moigithub
CatherineKa
@CatherineKa
Apr 23 2017 03:28 UTC
@moigithub I am already run the code as the requirement, why still not pass the challenge. Confused
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:28 UTC
@CatherineKa show your code
CatherineKa
@CatherineKa
Apr 23 2017 03:28 UTC
function titleCase(str) {
var newWord;
var result="";

array=str.split(" ");
for (var i=0;i<array.length;i++){

firstLetter=array[i].slice(0,1).toUpperCase();
restLetter=array[i].slice(1).toLowerCase();
newWord=firstLetter+restLetter;
result=result+" "+newWord;

}
return result;

}

titleCase("sHoRt AnD sToUt");
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:32 UTC
@CatherineKa because there's always there's always space in the beginning of the string
CatherineKa
@CatherineKa
Apr 23 2017 03:33 UTC
aha @Lumexralph u r right
but how to fix it
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:33 UTC
@CatherineKa look for a way to eliminate that space
CatherineKa
@CatherineKa
Apr 23 2017 03:34 UTC
@Lumexralph ok..
@Lumexralph thanks
CamperBot
@camperbot
Apr 23 2017 03:34 UTC
catherineka sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: catherineka already gave lumexralph points
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:36 UTC
@CatherineKa return result.replace(result.substr(0, 1), ""); is a way to remove that
CatherineKa
@CatherineKa
Apr 23 2017 03:43 UTC
@Lumexralph Thanks a lot! fFinally I pass it.
CamperBot
@camperbot
Apr 23 2017 03:43 UTC
catherineka sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: catherineka already gave lumexralph points
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:43 UTC
@CatherineKa cool!
dadosfe
@dadosfe
Apr 23 2017 03:54 UTC
whats wrong in my code?
only one test is coming out wrong all the rest are right
Ogundele Olumide
@Lumexralph
Apr 23 2017 03:57 UTC
@dadosfe you need to return true when the loop is done
@dadosfe that means all the characters of arr[1] exists in arr[0]
dadosfe
@dadosfe
Apr 23 2017 03:59 UTC
@Lumexralph thats true thanks
CamperBot
@camperbot
Apr 23 2017 03:59 UTC
dadosfe sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1557 | @lumexralph |http://www.freecodecamp.com/lumexralph
Peter Nguyen
@iampeternguyen
Apr 23 2017 04:06 UTC
hey can someone help me understand what this code means?
for (var x in y) {foo (y [x]);}
i don't understand the var x in y part? what is that doing?
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:07 UTC
@iampeternguyen means using a for...in loop to iterate object y and calling a function foo on the value on each value of the object
Peter Nguyen
@iampeternguyen
Apr 23 2017 04:09 UTC
okay @Lumexralph let me do soem reading on for in loops. i haven't come across it yet haha and i kept searching "x in y javascript" and couldn't come up with anything. thanks!
CamperBot
@camperbot
Apr 23 2017 04:09 UTC
iampeternguyen sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1558 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:09 UTC
@iampeternguyen x during iteration by the loop, will hold the each property name of the object per iteration
@iampeternguyen cool
Abhishek Ghosh
@abhishekghosh97
Apr 23 2017 04:10 UTC

HELP
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";

Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.

Ogundele Olumide
@Lumexralph
Apr 23 2017 04:11 UTC
@abhishekghosh97 just change the outer double quotes of your string to ' qoute
Abhishek Ghosh
@abhishekghosh97
Apr 23 2017 04:12 UTC
did it. didn't work
yofri
@yofriadi
Apr 23 2017 04:12 UTC
can somebody tell me, what does [0] do here?
function findLongestWord(str) {
var arr = str.split(" ");
var longest = arr.sort(function (a, b) {
return b.length - a.length;
})[0];
return longest.length;

//   var longest = arr.reduce(function (a, b) {
//     return a.length > b.length ? a : b;
//   });
//   return longest.length;
}

findLongestWord("The quick brown fox jumped over the lazy dog");
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:13 UTC
@abhishekghosh97 let me see what you did
Abhishek Ghosh
@abhishekghosh97
Apr 23 2017 04:13 UTC
@Lumexralph it says remove all backslashes
@Lumexralph
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:15 UTC
@Yofri arr is an array, [0] is picking the first element in arr array
Gulsvi
@gulsvi
Apr 23 2017 04:15 UTC
@Yofri after the array is sorted, it is assigned to longest, so it's the same as doing longest[0] after the sorting completes, without the extra line of code.
yofri
@yofriadi
Apr 23 2017 04:15 UTC
@Lumexralph hmhh
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:16 UTC
@abhishekghosh97 var myStr = '<a href=\"http://www.example.com\" target=\"_blank\">Link</a>';
yofri
@yofriadi
Apr 23 2017 04:16 UTC
@SkyCoder01 hoo i get it
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:16 UTC
@Yofri yeah
Abhishek Ghosh
@abhishekghosh97
Apr 23 2017 04:17 UTC
@Lumexralph that's the same as what i wrote it's not accepting
says remove backslashes
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:18 UTC
@abhishekghosh97 this is what you wrote var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Abhishek Ghosh
@abhishekghosh97
Apr 23 2017 04:20 UTC
@Lumexralph w/e dude but it's sadly not working
Ogundele Olumide
@Lumexralph
Apr 23 2017 04:20 UTC
@abhishekghosh97 this is another way var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";
Khoa Le
@Zacele
Apr 23 2017 04:25 UTC
hi guys
in the challenge Seek and Destroy
how could you make the logic to make the program know that how many arguments you will pass into it after the conditional array
lake.lai
@xiaoxiaoyao
Apr 23 2017 04:35 UTC

4月23日周日 早读分享：
1、24个省份“扎堆”举行2017年公务员招录的省考笔试，总招录规模近12万。根据预测，本次24省份报名考生总数或超过370万。竞争最激烈的岗位是宁波江北区人才市场管理办公室“人才开发”岗位，竞争比高达1746:1。

2、成都公安查获两起无人机非法飞行案件，将依法查处涉案人员。最近几天，成都双流国际机场净空保护区内连续发生几起无人机非法活动，导致58个航班备降西安、重庆、贵阳和绵阳机场，4架飞机返航，超1万旅客出行受阻被滞留机场

3、侯亮平都惊呆了！这位官员300万炒股获利2.48亿。证监会通报，前深交所工作人员、股票发审委委员冯小树，以亲属名义入股拟上市公司，上市后抛售股票获取巨额利益达2.48亿元，而其本金仅为300万元。证监会：没收冯小树违法所得2.48亿元，并顶格处以2.51亿元罚款。这是证监会近来开出的又一天价罚单。(之前证监会对于操纵多伦股份的鲜言罚没34.7亿元，创下证监会罚没金额之最。)

4、你代购的匡威、Vans可能是假的！湖北一鞋厂仿制名牌鞋84万双被查，涉案金额超过2亿元。涉案鞋厂通过网上“正品代购”渠道销售，一双成本只有30元，利润惊人。经清查，现场生产加工的品牌有匡威、万斯、卡帕等9个品牌，连相关品牌厂家的打假人员都感叹“太像了！”

5、ofo共享单车宣布获得蚂蚁金服战略投资，双方将在支付、信用等领域合作，推动“信用解锁”。

6、《肿瘤生物学(Tumor Biology)》宣布撤回107篇发表于2012年至2015年的论文，原因是同行评议造假。107篇论文全部和中国研究机构有关。“论文假冒了评审人电子邮件，让编辑以为文章发给了真正评审人”。

7、受益于英国脱欧，德国取代中国成为全球第二大最具吸引力的投资目的地。2016年中国在德投资高达126亿美元，这让德国成了中国在欧洲的最大投资接受国。尽管投资者比去年更加看好中国经济，但是在连续四年稳居第二位之后，中国今年的排名还是降到了第三位。

8、只提神不染色！世界首款无色咖啡问世。最近斯洛伐克一对兄弟研制出世界首款透明咖啡“CLR CFF”，即“clear coffee”(净咖啡)的意思。原料是阿拉比卡咖啡豆和纯水，不添加防腐剂等。目前只在斯洛伐克和英国有售，200毫升装卖5.99英镑(约合52.75元)。

9、菲律宾总统杜特尔特声称尽快派军队占据南海无人岛礁，军方目前已经接到指令。同时下月还将与美国举行联合演习。越南也开始不断向岛礁调运防空炮和火炮。(中国在南海面临的挑战越来越多。)

10、朝鲜外务省：朝鲜正密切关注美国对朝“阴谋动向”。朝鲜军队已做好充分准备，美国若要与朝鲜对决，朝鲜将奉陪到底。如果美国发动战争，朝鲜将以全面战争应对全面战争，以朝鲜式核打击战应对核战争。

11、联合国安理会包括中俄等全体15个成员国，对朝鲜发出措辞强烈的谴责声明，要求朝鲜停止导弹试射、停止核试验，并首次明确提到制裁行动。(此前，俄罗斯对这份由美国起草的声明中的一些措辞有意见。在俄罗斯的要求下，在最终版本中加入了“通过对话”寻求和平方案的字句。不过中国对原有版本并无异议，令外交界人士颇为惊讶。)

12、人一生下就会哭，笑是后来才学会的。所以忧伤是一种低级的本能，而快乐是一种更高级的能力。人生就像一杯茶，不会苦一辈子，但总会苦一阵子。慢慢来品，幸福的生活总在后面。

Khoa Le
@Zacele
Apr 23 2017 04:36 UTC
no chinese please
Douglas Luce
@Doug-Luce
Apr 23 2017 04:36 UTC
@Zacele All functions get access to the Arguments object. you can use arguments.length to find out how many arguments were passed to the function
Khoa Le
@Zacele
Apr 23 2017 04:37 UTC
@xiaoxiaoyao NO CHINESE please
lake.lai
@xiaoxiaoyao
Apr 23 2017 04:37 UTC
sorry
Gulsvi
@gulsvi
Apr 23 2017 04:39 UTC
I like the last part: "people will cry at once, laugh is learned later. So sadness is a low-level instinct, and happiness is a more advanced ability. Life is like a cup of tea, not a lifetime, but always bitter for a while. Slowly to the goods, happy life is always behind.
A good day from the "taste of happiness" start!"
Douglas Luce
@Doug-Luce
Apr 23 2017 04:41 UTC
@Zacele Here is a JSFiddle https://jsfiddle.net/dsmjwrec/
lixchen
@lixchen
Apr 23 2017 05:02 UTC
function recursion(node) {
if (node.children[0]) {
recursion(node.children[0]);
}
console.log(node.className);
if (node.children[1]) {
recursion(node.children[1]);
}
}
recursion(box);
hello I want know, how can i print the className once a second
Douglas Luce
@Doug-Luce
Apr 23 2017 05:06 UTC
@lixchen setInterval(function(){ console.log(node.className); }, 1000); You might try this.
NachumOlman
@NachumOlman
Apr 23 2017 05:06 UTC
why when i reduce by more than 32 it does mathematical errors? http://jsbin.com/vadifiwomu/edit?html,js,output
lixchen
@lixchen
Apr 23 2017 05:08 UTC
@Doug-Luce it will print all once a second
i want it pring one of all until pring over
my English isn't good , sorry
Douglas Luce
@Doug-Luce
Apr 23 2017 05:12 UTC
No problem. I'm still not following though what you want to accomplish.
lixchen
@lixchen
Apr 23 2017 05:14 UTC
<div id="box" class="23">
<div class="16">
<div class="3">
<div class="2"></div>
<div class="5"></div>
</div>
<div class="22">
<div class="19"></div>
<div class="26"></div>
</div>
</div>
<div class="45">
<div class="37">
<div class="31"></div>
<div class="39"></div>
</div>
<div class="99">
<div class="54"></div>
<div class="120"></div>
</div>
</div>
</div>
this is the box
i here is pring
i here is pring
2
3
5
16
19
22
26
23
31
37
39
45
54
99
120
once a second
Douglas Luce
@Doug-Luce
Apr 23 2017 05:16 UTC
Does pring mean Print?
lixchen
@lixchen
Apr 23 2017 05:17 UTC
but i want pring 2 , a second later pring 3 , a second later pring 5
Douglas Luce
@Doug-Luce
Apr 23 2017 05:17 UTC
Oh okay, and they all just print immediately?
lixchen
@lixchen
Apr 23 2017 05:18 UTC
yes
TheTaxmt
@TheTaxmt
Apr 23 2017 05:29 UTC

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.car["inside"].glove_box; // Change this line

any reason this isnt working?

Douglas Luce
@Doug-Luce
Apr 23 2017 05:30 UTC

@lixchen 
function recursion(node) {
setTimeout(function(){
if (node.children[0]) {
recursion(node.children[0]);
}
console.log(node.className);
if (node.children[1]) {
recursion(node.children[1]);
}
}, 1000);

}
recursion(box);



How about this?
I can't get markdown to work correctly when pasting this
Ogundele Olumide
@Lumexralph
Apr 23 2017 05:31 UTC
@TheTaxmt because there's no property name called glove_box i n the object, it's glove box and bracket notation is used to handle property names with that kind of string
Douglas Luce
@Doug-Luce
Apr 23 2017 05:31 UTC
@lixchen Here's a JSFiddle https://jsfiddle.net/50Lfrort/
lixchen
@lixchen
Apr 23 2017 05:35 UTC
@Doug-Luce Ok thanks
CamperBot
@camperbot
Apr 23 2017 05:35 UTC
lixchen sends brownie points to @doug-luce :sparkles: :thumbsup: :sparkles:
:cookie: 366 | @doug-luce |http://www.freecodecamp.com/doug-luce
Douglas Luce
@Doug-Luce
Apr 23 2017 05:36 UTC
No problem, did that work?
lixchen
@lixchen
Apr 23 2017 05:36 UTC
@Doug-Luce your code is good
have i small problem, it will print faster and faster
i think now i can solve
thank you thank you
Douglas Luce
@Doug-Luce
Apr 23 2017 05:38 UTC
No problem, glad I could help
NachumOlman
@NachumOlman
Apr 23 2017 05:56 UTC
Hi, can somebody help me?
rugano
@rugano
Apr 23 2017 06:01 UTC
Where am i going wrong in this profile lookup?
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:03 UTC
hey gm @Lumexralph
Douglas Luce
@Doug-Luce
Apr 23 2017 06:03 UTC
@NachumOlman What's going on?
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:05 UTC
can anyone tell me why I'm getting Uncaught ReferenceError: auth is not defined?
https://codepen.io/sevensixtwo762/pen/vmKaPz
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:07 UTC
@sevensixtwo762 i dont see that error
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:08 UTC
I'm pretty sure it's from where I'm building the myURL variable, but I don't see how I can make it more scopey. You don't? Does the image get set as the background?
Douglas Luce
@Doug-Luce
Apr 23 2017 06:08 UTC
@sevensixtwo762 When I run it I'm not getting the error either
Khoa Le
@Zacele
Apr 23 2017 06:08 UTC
hi guys
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:09 UTC
Sorry, I'm talking about errors in the developer's console, not the website console
Khoa Le
@Zacele
Apr 23 2017 06:09 UTC
could someone show me how to use the Arguments object please
Douglas Luce
@Doug-Luce
Apr 23 2017 06:09 UTC
The background is white, I think I'm getting a 400 for the background image url
Khoa Le
@Zacele
Apr 23 2017 06:09 UTC
currently stuck at Seek and Destroy challenge
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:09 UTC
I'm getting 400 errors on the second ajax request because of an empty auth variable
Khoa Le
@Zacele
Apr 23 2017 06:09 UTC
function destroyer(arr,args) {
try to return args[0] but it return nothing
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:10 UTC
I know auth is set to the variable, because I use it. so why can't I get to it after the ajax call? does the ajax call override the variable, not set the global one?
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:12 UTC
@sevensixtwo762 its not an issue with the auth variable
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:15 UTC
that's not the link I'm using.
it's http. I'm using https
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:16 UTC
there seems to be something missing from the link you posted too, as the cx wasn't there
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:17 UTC
im getting the links from the console
Douglas Luce
@Doug-Luce
Apr 23 2017 06:18 UTC
That's what I get when I logged myURL, for some reason I can't log auth there?
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:18 UTC
@Doug-Luce yours was missing the query string, which I'm trying to pass in with the auth variable
Douglas Luce
@Doug-Luce
Apr 23 2017 06:18 UTC
But auth isn't getting the query string
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:18 UTC
auth is supposed to be the author of the first ajax request. It's being used in the html output for the quote
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:19 UTC
oh i put the second api in the first api's callback becuase thats where you set the auth
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:19 UTC
the url works if the query is there. You can click mine, and get back json with some text and an image url
you mean just have one ajax call?
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:20 UTC
@sevensixtwo762 you'll async issues
if you dont have the second api inside the first one
the second api will start running before there is a response from the first api
so you'll either need to put it inside the first api call or use a promise
flansolo
@flansolo
Apr 23 2017 06:23 UTC
any ideas on why my dns.lookup isn't good for http(s) anyone? www works fine, just trying to get it to work like the url shortener microservice in beta. coincidentally their example gives an invalid url for www, and only accepts those with the protocol
gheorghiank
@gheorghiank
Apr 23 2017 06:23 UTC
@HeebieGeeBee morning! I don t know what to do in local scope and functions
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:23 UTC
@gheorghiank gm
what have you tried? @gheorghiank
gheorghiank
@gheorghiank
Apr 23 2017 06:24 UTC

function myLocalScope() {
'use strict';

var myVar = 10;
console.log(myVar);
}
myLocalScope();

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

// Now remove the console log line to pass the test
rugano
@rugano
Apr 23 2017 06:25 UTC
function lookUpProfile(firstName,prop){
//Only change code below this line
if("Akira" === "Laine"){
output = "Laine";
}else if("number === "0543236543"){
output = "0543236543";
}else if("likes" === ["Pizza","Coding","Brownie Points"];
What is wrong with my interpretation of the challenge
NachumOlman
@NachumOlman
Apr 23 2017 06:26 UTC
@Doug-Luce when i reduce more than 32 from my number (96.74) it does not return correct mathematical answers: http://jsbin.com/vadifiwomu/edit?html,js,output is there a way around it or am i going to have to eliminate the decimal factor?
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:27 UTC
@gheorghiank refresh your browser and run the test again
@rugano thats just not what youre meant to do
youre not meant to be hard coding values like that
and thats not how you access object properties
there is lots wrong
gheorghiank
@gheorghiank
Apr 23 2017 06:29 UTC
@HeebieGeeBee referenceError : myVar is not defined
rugano
@rugano
Apr 23 2017 06:29 UTC
@HeebieGeeBee How should i handle it?
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:30 UTC
@gheorghiank delete the console.log line
@rugano loop throught the contacts array checking to see if any of the objects have a firstName that match the firstName parameter, then if a firstName match is made check if that contact has the prop property if it does return that properties value and if not return no susch property
then after the loop if you dont find a frist name match return no such contact
gheorghiank
@gheorghiank
Apr 23 2017 06:32 UTC
@HeebieGeeBee it worked. thank you!
CamperBot
@camperbot
Apr 23 2017 06:32 UTC
gheorghiank sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1430 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 06:32 UTC
@gheorghiank ok cool, well done
Douglas Luce
@Doug-Luce
Apr 23 2017 06:37 UTC
@NachumOlman https://jsfiddle.net/ubkw77y5/1/ You can used the .toFixed method
Julian Mansueto
@julianmnst
Apr 23 2017 06:41 UTC

Hi there guys! Greetings from Argentina! I have a question for you. Imagine you have these 3 arrays:

var arr1 = ["1", "2", "3"];
var arr2 = ["a", "b", "c"];
var arr3 = ["do", "re", mi"];

Is there a way to get the next result without a for loop?

result = ["1 a do", "2 b re", "3 c mi"];

I mean using map, or reduce, or something like that.

sorry for the typo
Jean-Paul Sauve
@jp-sauve
Apr 23 2017 06:44 UTC
I'm so close! Now I can't read property "snippet". Where is the json2 object from the search's success call? It got far enough to look for the link (which, based on console output, is correct) but I dunno...
Darth Skywalker
@adityaparab
Apr 23 2017 06:46 UTC
@julianmnst : Assuming all array are of same lengths, you can do something like this
var zippedArray = arr1.map(function(item, index, originalArray){
var val = ${item}${arr2[index]} ${arr3[index]}; }); Khoa Le @Zacele Apr 23 2017 06:47 UTC hi guys here is my code for the search and destroy challenge I don't know what is wrong with my code but it return the exact arguments that I wanna check but always return an empty array Darth Skywalker @adityaparab Apr 23 2017 06:48 UTC post your code Julian Mansueto @julianmnst Apr 23 2017 06:49 UTC @adityaparab yeap they're the same length. I'll try, but if it's not much trouble would you explain me a little? how does that work? thanks! CamperBot @camperbot Apr 23 2017 06:49 UTC julianmnst sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles: :star2: 1021 | @adityaparab |http://www.freecodecamp.com/adityaparab NachumOlman @NachumOlman Apr 23 2017 06:49 UTC @Doug-Luce thanks that helped! Douglas Luce @Doug-Luce Apr 23 2017 06:49 UTC @NachumOlman No problem Darth Skywalker @adityaparab Apr 23 2017 06:49 UTC @julianmnst : .map returns an array of the elements returned from the call back function that is passed to the .map so you iterate over arr1, that passes each element of arr1 to your function as item. Along with item, .map also passes index of item. You use this index to query arr2 and arr3. like arr2[item] and arr3[item] to get elements from arr2 and arr3 at the same index. NachumOlman @NachumOlman Apr 23 2017 06:51 UTC thanks @Doug-Luce CamperBot @camperbot Apr 23 2017 06:51 UTC nachumolman sends brownie points to @doug-luce :sparkles: :thumbsup: :sparkles: :cookie: 369 | @doug-luce |http://www.freecodecamp.com/doug-luce Darth Skywalker @adityaparab Apr 23 2017 06:51 UTC You contact them to your item Jean-Paul Sauve @jp-sauve Apr 23 2017 06:51 UTC success function not passing anything to json2 I think. Any ideas on how to access inner success function's object? https://codepen.io/sevensixtwo762/pen/vmKaPz?editors=1111 $(document).ready(function() {
var auth="";
$('#quothMore').on("click", function() {$.ajax({type:'GET',
dataType:'json',
url:'https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1',
success: function(json){
var html="";
auth = json[0].title;
html += "<div class='quotes'>";
html += json[0].content + "<p class='authorName'>-- " + auth + "</p>";
html += "</div>";
$("#rcol").html(html); console.log("auth variable set to: "+auth); var myURL = 'https://www.googleapis.com/customsearch/v1?q='+(encodeURIComponent(auth))+'&num=1&imgType=face&safe=high&searchType=image&fields=items(link,snippet)&cx=016785142417644725210:ecuzg4lxswe&key=AIzaSyC2ntpD3H9RQuRcD2SyrN4GX38kI1IMcDI';$.ajax({type:'GET',
dataType:'json',
url:myURL,
success: function(json2) {
console.log(myURL);
var snippet = json2.snippet;
var imgURL = json2.link;
$("#background").css("background-image",imgURL); }, cache:false }); }, cache: false }); }); }); Darth Skywalker @adityaparab Apr 23 2017 06:52 UTC  var val = ${item} ${arr2[index]}${arr3[index]};
is same as
 var val = item + " " + arr2[index] + " " + arr3[index];
Julian Mansueto
@julianmnst
Apr 23 2017 06:53 UTC
@adityaparab is there a name for that ${} syntax? Darth Skywalker @adityaparab Apr 23 2017 06:54 UTC @julianmnst : String templates or string literal syntax... it's an ES6 feature Khoa Le @Zacele Apr 23 2017 06:55 UTC I still don't get how the Argument objects works could someone help me out Julian Mansueto @julianmnst Apr 23 2017 06:56 UTC @adityaparab Hey man thank you a LOT. I'm a big fan of your name CamperBot @camperbot Apr 23 2017 06:56 UTC julianmnst sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles: :warning: julianmnst already gave adityaparab points Galib Hossain @formulajp60 Apr 23 2017 06:56 UTC  var Car = function(wheels, seats, engines) { //Change this constructor this.wheels = 4; this.seats = 5; this.engines = 1; }; //Try it out here var myCar = new Car(3, 1, 2); Guys why my code is not working? I am trying to create an object by passing argument. Douglas Luce @Doug-Luce Apr 23 2017 06:57 UTC function myFunction(value1, value2){ //Accessing the arguments function alert(arguments[0] + ' ' + arguments[1]); } myFunction('1', '2'); Darth Skywalker @adityaparab Apr 23 2017 06:57 UTC @julianmnst :+1: Douglas Luce @Doug-Luce Apr 23 2017 06:57 UTC Here is an example of accessing the arguments object @Zacele Darth Skywalker @adityaparab Apr 23 2017 06:58 UTC Khoa Le @Zacele Apr 23 2017 06:58 UTC function destroyer(arr) { // Remove all the value var result = []; for (i=0; i<arguments.length;i++){ arg = arguments[i]; } return arg; } destroyer([3, 5, 1, 2, 2], 2, 3, 5); Khoa Le @Zacele Apr 23 2017 06:58 UTC that is my code HeebieGeeBee @HeebieGeeBee Apr 23 2017 06:59 UTC this is the response i get Khoa Le @Zacele Apr 23 2017 06:59 UTC it extract the right argument Darth Skywalker @adityaparab Apr 23 2017 06:59 UTC @Zacele : You need to separate out all the arguments passed to a function from index 1 and onward. Jean-Paul Sauve @jp-sauve Apr 23 2017 06:59 UTC aaw darn. that's why I was hitting 403 Darth Skywalker @adityaparab Apr 23 2017 07:00 UTC @Zacele you can run a for loop on arguments. Starting from i = 1 to i < arguments.length. And then push arguments[i] in a separate array. Khoa Le @Zacele Apr 23 2017 07:00 UTC @adityaparab which mean pass it to a new array ??? Jean-Paul Sauve @jp-sauve Apr 23 2017 07:00 UTC or I should just go back to older fork, make it look nice, and submit. What do you think? Douglas Luce @Doug-Luce Apr 23 2017 07:01 UTC @formulajp60 Hey Galib, it seems to be working https://jsfiddle.net/p9x37gqp/ Jean-Paul Sauve @jp-sauve Apr 23 2017 07:01 UTC it would have been pretty cool to get automatic images working cusbus @cusbus Apr 23 2017 07:03 UTC hi guys, sorry to barge in. i've been trying to figure this out for an hour now. it is just not clicking... i need to use this function to add ITEM to the end of the array, remove the first element of the array, and then return the element that was removed Jean-Paul Sauve @jp-sauve Apr 23 2017 07:03 UTC read the suggested function docs carefully cusbus @cusbus Apr 23 2017 07:04 UTC ugh. and i cant even copy code correctly... h1tag @h1tag Apr 23 2017 07:06 UTC @cusbus review the array manipulation lessons HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:06 UTC @sevensixtwo762 no idea do whatever you think is best CamperBot @camperbot Apr 23 2017 07:06 UTC :bulb: to format code use backticks!  more info flansolo @flansolo Apr 23 2017 07:09 UTC nvm no one knows cusbus @cusbus Apr 23 2017 07:09 UTC @fortMaximus i have tried using .push and .shift HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:10 UTC @cusbus how are you using them cus thats what youre meant to use h1tag @h1tag Apr 23 2017 07:10 UTC @cusbus show me your solution that uses push and shift yofri @yofriadi Apr 23 2017 07:11 UTC can someone tell my why my code only returns first letter instead of all the word function titleCase(str) { var arr = str.toLowerCase().split(" "); var i; for (i = 0; i < arr.length; i++) { arr[i] = arr[i].charAt(0).toUpperCase(); } return arr.join(); } titleCase("I'm a little tea pot"); cusbus @cusbus Apr 23 2017 07:11 UTC i cant figure out how to add my dang code correctly HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:11 UTC @Yofri because thats all youre assigning h1tag @h1tag Apr 23 2017 07:11 UTC ''' CamperBot @camperbot Apr 23 2017 07:11 UTC :bulb: to format code use backticks!  more info yofri @yofriadi Apr 23 2017 07:11 UTC @HeebieGeeBee sorry can you be specific? HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:12 UTC arr[i] = arr[i].charAt(0).toUpperCase(); h1tag @h1tag Apr 23 2017 07:12 UTC @cusbus click more info above HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:12 UTC @Yofri youre assigning the first letter in uppercase Aizaz Shahid @aizazshahid Apr 23 2017 07:12 UTC @HeebieGeeBee is .split(" ") equal to .split("") ?? HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:12 UTC @forwebtech nope CamperBot @camperbot Apr 23 2017 07:13 UTC :bulb: to format code use backticks!  more info Khoa Le @Zacele Apr 23 2017 07:13 UTC @forwebtech not at all Aizaz Shahid @aizazshahid Apr 23 2017 07:13 UTC @HeebieGeeBee thanks, checked it CamperBot @camperbot Apr 23 2017 07:13 UTC forwebtech sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles: :star2: 1431 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee :bulb: to format code use backticks!  more info HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:14 UTC Ramesh Mahajan Remi @remimahajan Apr 23 2017 07:14 UTC can someone help me with this issue? Jor @joreyesl Apr 23 2017 07:14 UTC @Yofri arr[i].charAt(0).toUpperCase() thats the first letter. you need to also concatenate the rest of the world. look at substring() to get the rest of the word. flansolo @flansolo Apr 23 2017 07:15 UTC omg are you all being paid just to go over common stuff with noobs no one else will do? okay maybe not paid either way i applaud you. ty Aizaz Shahid @aizazshahid Apr 23 2017 07:15 UTC to Format your code please follow, Formatting code Jor @joreyesl Apr 23 2017 07:15 UTC @remimahajan remove the count = 0 you are resetting count. They say not to do that. yofri @yofriadi Apr 23 2017 07:15 UTC @joreyesl okey flansolo @flansolo Apr 23 2017 07:15 UTC goodbye :) h1tag @h1tag Apr 23 2017 07:15 UTC Ramesh Mahajan Remi @remimahajan Apr 23 2017 07:16 UTC Big thanks @joreyesl CamperBot @camperbot Apr 23 2017 07:16 UTC remimahajan sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles: :cookie: 787 | @joreyesl |http://www.freecodecamp.com/joreyesl Ramesh Mahajan Remi @remimahajan Apr 23 2017 07:16 UTC its worked cusbus @cusbus Apr 23 2017 07:18 UTC  function nextInLine(arr, item) { // Your code here testArr.push([item]); var wontWork = testArr.shift([0]); return wontWork; // Change this line } // Test Setup var testArr = [1,2,3,4,5]; Aizaz Shahid @aizazshahid Apr 23 2017 07:18 UTC @cusbus you can't use testArr inside your function, instead use argument arr. h1tag @h1tag Apr 23 2017 07:18 UTC @cusbus and shift doesn't need arguments HeebieGeeBee @HeebieGeeBee Apr 23 2017 07:19 UTC @cusbus and dont put item inside an array Jor @joreyesl Apr 23 2017 07:19 UTC @cusbus .push([item]) you are passing in an array with item. ex: its like doing .push([2]), but what you should be doing is .push(2) cusbus @cusbus Apr 23 2017 07:20 UTC okay thank you @joreyesl @fortMaximus @forwebtech CamperBot @camperbot Apr 23 2017 07:20 UTC cusbus sends brownie points to @joreyesl and @fortmaximus and @forwebtech :sparkles: :thumbsup: :sparkles: :cookie: 735 | @fortmaximus |http://www.freecodecamp.com/fortmaximus :cookie: 311 | @forwebtech |http://www.freecodecamp.com/forwebtech :cookie: 788 | @joreyesl |http://www.freecodecamp.com/joreyesl flansolo @flansolo Apr 23 2017 07:22 UTC ty @joreyesl CamperBot @camperbot Apr 23 2017 07:22 UTC flansolo sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles: :cookie: 789 | @joreyesl |http://www.freecodecamp.com/joreyesl Vamp @the-vampiire Apr 23 2017 07:25 UTC @sjames1958gm was a matter of when, not if https://www.vampiire.org/Projects/multitwitch a ways to go UI wise need to add an online / offline marker, stream game, and a tabbed view for on / offline but the heart of it is working bug free. flansolo @flansolo Apr 23 2017 07:26 UTC ty @sjames1958gm CamperBot @camperbot Apr 23 2017 07:26 UTC flansolo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles: :star2: 6900 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Vamp @the-vampiire Apr 23 2017 07:26 UTC click ESL/sc2 channel it’s 24/7 streaming so you can see it in action :) Rahul Kumar @rkredux Apr 23 2017 07:26 UTC Hi Campers, is there a bug in the Record Collection Algorithm Challenge (Advance Level Algorithm challenge #2). My first test does not pass the test but it does when I test it in codepen or in jsfiddle. All the other tests pass easily. Anyone else has faced this issue? Here is my code : function updateRecords(id, prop, value) { if (prop === "tracks" && value !== "") { if(collection[id][prop]) { collection[id][prop].push(value); } else { collection[id][prop]=[value]; } } else if (value !== "") { collection[id][prop] = value; } else { delete collection[id][prop]; } return collection; } Thanks for looking into it Aizaz Shahid @aizazshahid Apr 23 2017 07:27 UTC :bulb: To format your code please follow, Formatting code Khoa Le @Zacele Apr 23 2017 07:30 UTC  function destroyer(arr) { // Remove all the value var result = []; var argsArray = []; // create the Argument Array for (var i=1; i<arguments.length;i++){ arg = arguments[i]; argsArray.push(arg); } // function destroyArg(value){ return value !== argsArray; } arr.filter(destroyArg); return arr; } destroyer([3, 5, 1, 2, 2], 2, 3, 5); hi guys flansolo @flansolo Apr 23 2017 07:30 UTC @sjames1958gm gonna hit 7000 soon, like the damn babe ruth of this bitch Khoa Le @Zacele Apr 23 2017 07:30 UTC why is my code return the exact input arr but cannot filter the Arg :( Aizaz Shahid @aizazshahid Apr 23 2017 07:31 UTC @Zacele you have to use callback function into your .filter(..) The filter() method creates a new array with all elements that pass the test implemented by the provided function Khoa Le @Zacele Apr 23 2017 07:31 UTC I did use the callback function destroyArg I create right abobe it above Aizaz Shahid @aizazshahid Apr 23 2017 07:32 UTC @Zacele sorry my bad ! Blara02 @Blara02 Apr 23 2017 07:33 UTC whats up script kiddies, can i link a block of code here thats giving me the buisness flansolo @flansolo Apr 23 2017 07:34 UTC why not be a script kiddy yourself? google/stack it Aizaz Shahid @aizazshahid Apr 23 2017 07:34 UTC @Zacele why did you start your loop from i = 1 ?? if wrong, let me know. flansolo @flansolo Apr 23 2017 07:34 UTC dont' trick yourself into thinking you gotta remember it all Aizaz Shahid @aizazshahid Apr 23 2017 07:34 UTC sorry i = 1, started from here Blara02 @Blara02 Apr 23 2017 07:35 UTC @flansolo well my code works but im not sure why here ill just link it function switchOfStuff(val) { var answer = ""; // Only change code below this line switch (val) { case "a": return "apple"; break; case "b": return "bird"; break; case "c": return "cat"; break; default: return "stuff"; } // Only change code above this line return answer; } // Change this value to test switchOfStuff(1); Aizaz Shahid @aizazshahid Apr 23 2017 07:35 UTC :bulb: To format your code please follow, Formatting code flansolo @flansolo Apr 23 2017 07:35 UTC yeah put your code between  Blara02 @Blara02 Apr 23 2017 07:36 UTC okay sorry yofri @yofriadi Apr 23 2017 07:37 UTC how can i improve this function titleCase(str) { var arr = []; var arr2 = []; var strLower = ""; var strLower2 = ""; var i; arr = str.split(' '); for (i=0; i < arr.length; i++) { arr[i] = arr[i].toLowerCase(); strLower = arr[i]; arr2 = strLower.split(''); arr2[0] = arr2[0].toUpperCase(); strLower2 = arr2.join(''); arr[i] = strLower2; } str = arr.join(' '); return str; } titleCase("I'm a little tea pot"); i made it into array, then i made it into string, then i made it into multidimensional array, then made it again into string? Khoa Le @Zacele Apr 23 2017 07:38 UTC @forwebtech i=1 is the arr input in the parameters Aizaz Shahid @aizazshahid Apr 23 2017 07:38 UTC @Yofri literally, you are using unnecessary statements ! Khoa Le @Zacele Apr 23 2017 07:38 UTC @Yofri lookup slice Aizaz Shahid @aizazshahid Apr 23 2017 07:38 UTC @Zacele as i know array start from index 0 @Zacele may be, didn't get the logic of yours ! Khoa Le @Zacele Apr 23 2017 07:41 UTC @forwebtech Create an arguments array first then look up to the initial array and filter out the arguments Vamp @the-vampiire Apr 23 2017 07:43 UTC @Yofri function titleCase(str) { var split = str.split(' '); var i = 0; for(i; i < split.length; i++){ split[i] = split[i][0].toUpperCase()+split[i].slice(1); } return split.join(' '); } console.log(titleCase("I'm a little tea pot")); //output I'm A Little Tea Pot yofri @yofriadi Apr 23 2017 07:44 UTC @the-vampiire i need logs every line first Vamp @the-vampiire Apr 23 2017 07:44 UTC i dont know what that means Aizaz Shahid @aizazshahid Apr 23 2017 07:45 UTC @Yofri please read the comments also: function titleCase(str) { var arr, result, ch; // Converting string into array, but first changing to Lower Case arr = str.toLowerCase().split(/\s/g); // Changing every First letter to uppercase for(var i = 0; i < arr.length; i++) { // Holding first character from the element ch = arr[i].charAt(0); // Getting the first letter and change it to uppercase result = arr[i].replace(ch, ch.toUpperCase()); // Initializing the modified string to array arr[i] = result; } // Joining array into a string, and returned it return arr.join(' '); } yofri @yofriadi Apr 23 2017 07:45 UTC @the-vampiire what .slice(1) does? @forwebtech wait Vamp @the-vampiire Apr 23 2017 07:47 UTC Jean-Paul Sauve @jp-sauve Apr 23 2017 07:47 UTC slices like a ninja yofri @yofriadi Apr 23 2017 07:48 UTC @forwebtech wow your code is more straight forward, but i didnt know regex @the-vampiire pls just tell me after reading the docs i am more confusing Aizaz Shahid @aizazshahid Apr 23 2017 07:50 UTC @Yofri for that please visit Regex yofri @yofriadi Apr 23 2017 07:51 UTC @the-vampiire oh i know it extracts second char and the rest @forwebtech ok Vamp @the-vampiire Apr 23 2017 07:51 UTC @Yofri you must learn to read the docs if the text confuses you then look at the examples Akshat Bahety @akshatbahety Apr 23 2017 07:52 UTC Hye yofri @yofriadi Apr 23 2017 07:52 UTC @the-vampiire the hard parts i think haha Vamp @the-vampiire Apr 23 2017 07:52 UTC slice means slice a str or array Akshat Bahety @akshatbahety Apr 23 2017 07:52 UTC  function rot13(str) { // LBH QVQ VG! var a = str.split(" "); var b = []; var c = ""; var d = ""; var e = []; var f = ""; for(var i = 0 ; i < a.length ; i++){ b = a[i].split(""); // Spliting into diffrent letters //console.log(b); for(var j = 0;j<b.length;j++){ //Putting in the basic unicode conditions so only letters are involved if(b[j].charCodeAt(0)>=65 & b[j].charCodeAt(0)<=77) { d = b[j].charCodeAt(0)+13; } else if(b[j].charCodeAt(0)>77 & b[j].charCodeAt(0)<=90) { d = b[j].charCodeAt(0)-13; } var res = String.fromCharCode(d); //console.log(res); e.push(res); //Creating and array of letters } f = e.join(""); // Joining those letters // console.log(f); } return f; } // Change the inputs below to test rot13("SERR PBQR PNZC"); So I am at caesars cipher Vamp @the-vampiire Apr 23 2017 07:53 UTC slice(from, to) if to is left out then it goes to end to is NOT INCLUSIVE meaning it will go UP TO but not INCLUDE that number Akshat Bahety @akshatbahety Apr 23 2017 07:53 UTC The problem is I can't add spaces between the words i am returning And I don't know how i can achieve it using spaces or join? Jean-Paul Sauve @jp-sauve Apr 23 2017 07:53 UTC join(" ") Vamp @the-vampiire Apr 23 2017 07:54 UTC str = the str.length // 3 str.slice(0) // the str.slice(1) // he str.slice(2) // e str.slice(3) // str.slice(0,1) // t UP TO ‘h’ but NOT INCLUDE ‘h" @Yofri Akshat Bahety @akshatbahety Apr 23 2017 07:54 UTC @sevensixtwo762 that'll split all of them into different spaces like this F R E E I am currently getting this FREECODECAMP i need FREE CODE CAMP yofri @yofriadi Apr 23 2017 07:55 UTC @the-vampiire thanks thanks, so it starts at index 1, because 0 didnt change anything CamperBot @camperbot Apr 23 2017 07:55 UTC yofri sends brownie points to @the-vampiire :sparkles: :thumbsup: :sparkles: :cookie: 306 | @the-vampiire |http://www.freecodecamp.com/the-vampiire Vamp @the-vampiire Apr 23 2017 07:56 UTC starts at 1 why? what did we do with 0? Jean-Paul Sauve @jp-sauve Apr 23 2017 07:58 UTC @akshatbahety you've forgotten to return characters that don't need to be rot13'd Akshat Bahety @akshatbahety Apr 23 2017 08:00 UTC @sevensixtwo762 Yeah but i took a very different approach I altogether removed all those characters Jean-Paul Sauve @jp-sauve Apr 23 2017 08:00 UTC and you don't have to split it. just use charCodeAt on the string and use i Akshat Bahety @akshatbahety Apr 23 2017 08:00 UTC Let me give another shot at it Jean-Paul Sauve @jp-sauve Apr 23 2017 08:01 UTC you can build your new string with concat while you're checking, so you don't need all of those variables Akshat Bahety @akshatbahety Apr 23 2017 08:01 UTC @sevensixtwo762 Yeah I am getting the idea Akshat Bahety @akshatbahety Apr 23 2017 08:08 UTC @sevensixtwo762 Got it done thanks CamperBot @camperbot Apr 23 2017 08:08 UTC akshatbahety sends brownie points to @sevensixtwo762 :sparkles: :thumbsup: :sparkles: :cookie: 286 | @sevensixtwo762 |http://www.freecodecamp.com/sevensixtwo762 Sandbagger @Sandbagger Apr 23 2017 08:11 UTC '''test''' CamperBot @camperbot Apr 23 2017 08:11 UTC :bulb: to format code use backticks!  more info Sandbagger @Sandbagger Apr 23 2017 08:11 UTC test1 Jean-Paul Sauve @jp-sauve Apr 23 2017 08:12 UTC thunder Vamp @the-vampiire Apr 23 2017 08:14 UTC @akshatbahety here is mine if you want to compare. I am trying to follow what you did. What is char code ? function rot13(str) { // setup to build a decoder // alphabet + repeating 13 characters for spillover in loop // produces 'undefined' artifacts but those will be dealt with var alphabet = 'abcdefghijklmnopqrstuvwxyzabcdefghijklm'; // lazily type it out in lowercase...make JS do the work... var caps_alpha = alphabet.toUpperCase(); // alphabet in caps and split into an array for looping purposes var alpha_arr = caps_alpha.split(''); // array to capture the shifted alphabet, shifted by 13 places in the alphabet var decoder = []; // loop to populate the decoder array, takes alphabet character and pushes the letter 13 letters after it for(var i = 0; i < alpha_arr.length; i++){ decoder.push(alpha_arr[i+13]); } // clean up the decoder array by filtering for undefined elements decoder = decoder.filter(undefined_filter); // function to filter undefined elements from decoder array, artifacts of a lazy loop function undefined_filter(val){ if(val === undefined){ return false; } return true; } // decoding occurs below this line // clean alphabet without spillover characters - used for matching var clean_alpha = 'abcdefghijklmnopqrstuvwxyz'; var clean_alpha_caps_arr = clean_alpha.toUpperCase().split(''); // define two variables, alpha_index will store the index of the matching letter from the string // the other will hold the decoded string var alpha_index; var decoded_str = ''; // loop through the string and determine the index of the matching letter from the string to the alphabet // build the decoded_str by running the same index through the decoder array for(i = 0; i < str.length; i++){ alpha_index = clean_alpha_caps_arr.indexOf(str[i]); // correct for spaces / characters not found in alphabet switch(str[i]){ case ' ': console.log('called'); decoded_str += ' '; break; case '.': decoded_str += '.'; break; case '!': decoded_str += '!'; break; case '?': decoded_str += '?'; break; default: decoded_str += decoder[alpha_index]; } } return decoded_str; // Shia_Lebouf_magic.gif // the vampiire } Sandbagger @Sandbagger Apr 23 2017 08:14 UTC Hello all, where am I going wrong? I don't seem to be pushing values to the empty array:  var largest = []; // iterate through array, returning highest value of sub arrays for(i=0; i < arr; i++) { var top = Math.max.apply(Math, arr[i]); largest.push(top); } return largest;  arr= array of arrays containing series of numbers HeebieGeeBee @HeebieGeeBee Apr 23 2017 08:16 UTC @Sandbagger what is Math meant to be in your apply argument? Sandbagger @Sandbagger Apr 23 2017 08:17 UTC I didn't think it mattered what was in the first argument... alpox @alpox Apr 23 2017 08:18 UTC @Sandbagger in that case you usually put there null :) Everything else is confusing to read @Sandbagger in the for loop you should check for < arr.length Sandbagger @Sandbagger Apr 23 2017 08:19 UTC okay, I will bear that in mind flansolo @flansolo Apr 23 2017 08:20 UTC Sandbagger @Sandbagger Apr 23 2017 08:21 UTC @alpox oh crikey that was a simple oversight! @alpox thank you! CamperBot @camperbot Apr 23 2017 08:21 UTC sandbagger sends brownie points to @alpox :sparkles: :thumbsup: :sparkles: :cookie: 965 | @alpox |http://www.freecodecamp.com/alpox CatherineKa @CatherineKa Apr 23 2017 08:30 UTC Hi anyone knows which methods of string can extract the last word of a sentence? Johnny @JohnnyBizzel Apr 23 2017 08:30 UTC @CatherineKa pop CatherineKa @CatherineKa Apr 23 2017 08:30 UTC Like I need to extrat the "pen" in the sentence "I have a pen" Johnny @JohnnyBizzel Apr 23 2017 08:31 UTC @CatherineKa .pop() ...long pause CatherineKa @CatherineKa Apr 23 2017 08:36 UTC @JohnnyBizzel Thanks for your reply. You give me the inspiration. maybe I can convert a string to an array first CamperBot @camperbot Apr 23 2017 08:36 UTC catherineka sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles: :star2: 1660 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel Johnny @JohnnyBizzel Apr 23 2017 08:37 UTC @CatherineKa Yes, convert the sentence to an array of words with .split(' ') CatherineKa @CatherineKa Apr 23 2017 08:40 UTC @JohnnyBizzel Yeah let me figure it out whether I can use this logic to finsih the challenge CatherineKa @CatherineKa Apr 23 2017 08:47 UTC but I also have to extract the last letter of a word using the same str, I need to use .split("")to split the word and use .split(" ")to split the sentence, Shriprada @Shriprada Apr 23 2017 08:48 UTC @cupaslo thanks. CamperBot @camperbot Apr 23 2017 08:48 UTC shriprada sends brownie points to @cupaslo :sparkles: :thumbsup: :sparkles: :cookie: 80 | @cupaslo |http://www.freecodecamp.com/cupaslo CatherineKa @CatherineKa Apr 23 2017 08:48 UTC the two methods conflict when I focus on the same str confused I need one method which both can extraxt the last word of a sentence and last letter of a word alpox @alpox Apr 23 2017 08:49 UTC @CatherineKa you have to assign the return values of these functions to new variables. There shouldnt be a confusion then CatherineKa @CatherineKa Apr 23 2017 08:52 UTC @alpox but stris either a word or a sentence, when it is a word, I can use str.substr(-1) but when it is a sentence, I don't know use which method Johnny @JohnnyBizzel Apr 23 2017 08:54 UTC @CatherineKa So the array is spit into a sentence. Now loop over the words. And split them - into an array of chars. CatherineKa @CatherineKa Apr 23 2017 08:56 UTC but how I make a condition on which str is a sentence you know when it is a sentence, use.split(" "), but when it is a word, use.split("") Johnny @JohnnyBizzel Apr 23 2017 08:58 UTC @CatherineKa var sentence = "I have a pen"; console.log(sentence.split(" ").pop().split("").shift()); returns "p" var sentence = "I have a pen"; console.log(sentence.split(" ").pop().split("").pop()); returns "n" Pieter Stokkink @forkerino Apr 23 2017 08:58 UTC @CatherineKa check if str contains a space, if so , do the word splitting, otherwise the letter splitting. or am I misunderstanding the thing you want to do? Johnny @JohnnyBizzel Apr 23 2017 09:00 UTC @forkerino Morgen Pieter Pieter Stokkink @forkerino Apr 23 2017 09:00 UTC @JohnnyBizzel goedemorgen! CatherineKa @CatherineKa Apr 23 2017 09:01 UTC @forkerino no , you think the way exactly what I think Johnny @JohnnyBizzel Apr 23 2017 09:01 UTC @forkerino Hoe gaat het? Pieter Stokkink @forkerino Apr 23 2017 09:01 UTC @JohnnyBizzel goed, met jou? Johnny @JohnnyBizzel Apr 23 2017 09:01 UTC @forkerino Hartstikke goed!! (that's the one I remember!!) Pieter Stokkink @forkerino Apr 23 2017 09:01 UTC that's a good one Johnny @JohnnyBizzel Apr 23 2017 09:03 UTC I am working with ajisty on the nightlife app but I am also in the middle of doing ... http://codepen.io/JohnnyBizzel/pen/dvjBOW sai yaswanth reddy kudumala @sai5163 Apr 23 2017 09:07 UTC I am stuck in counting cards problem can any body help me Pieter Stokkink @forkerino Apr 23 2017 09:07 UTC @JohnnyBizzel how do you like React? I'm just starting to learn it a little bit, but still have to write some actual code @sai5163 show us what you wrote so far CodeGeek3 @codeGeek3 Apr 23 2017 09:08 UTC hello CatherineKa @CatherineKa Apr 23 2017 09:09 UTC @sai5163 where are you stuck? Pieter Stokkink @forkerino Apr 23 2017 09:09 UTC @codeGeek3 good day Johnny @JohnnyBizzel Apr 23 2017 09:10 UTC @forkerino Yes, I am just starting to get how it works. I am not sold on it completely because it is a big change. The nightlife app is using Redux and React Router too so that is another few things to learn. @sai5163 Ace's high CodeGeek3 @codeGeek3 Apr 23 2017 09:10 UTC @forkerino ^^ good day to you too Johnny @JohnnyBizzel Apr 23 2017 09:10 UTC Or maybe :card_index: Pieter Stokkink @forkerino Apr 23 2017 09:11 UTC @JohnnyBizzel aah, good! I was thinking of incorporating React into my Book Exchange app. But not sure if it is the right tool for the job. Johnny @JohnnyBizzel Apr 23 2017 09:12 UTC @forkerino It would be a good one to practice. I've seen @yasserhussain1110 's - he did is using VueJS. Pieter Stokkink @forkerino Apr 23 2017 09:15 UTC @JohnnyBizzel great! I'll study a bit more and get to coding. Had a break from coding for pretty much three weeks because I was moving house and travelling and it is hard to get back into the groove. Johnny @JohnnyBizzel Apr 23 2017 09:17 UTC @forkerino I am interested in some of the other frameworks but for now I am sticking to React! Get good at one then move to the next... Pieter Stokkink @forkerino Apr 23 2017 09:19 UTC @JohnnyBizzel definitely. If you want to dig a well, you need to keep digging in one place. Once you got a well, you can dig a new one without going thirsty. wow. that was one cheesy metaphor CatherineKa @CatherineKa Apr 23 2017 09:19 UTC @JohnnyBizzel @forkerino Thanks both of you. I just get through the challenge by a little trick, haha the suggestions you give are very valuable CamperBot @camperbot Apr 23 2017 09:19 UTC catherineka sends brownie points to @johnnybizzel and @forkerino :sparkles: :thumbsup: :sparkles: :warning: catherineka already gave johnnybizzel points :star2: 1869 | @forkerino |http://www.freecodecamp.com/forkerino Pieter Stokkink @forkerino Apr 23 2017 09:20 UTC you're welcome @CatherineKa Johnny @JohnnyBizzel Apr 23 2017 09:20 UTC @CatherineKa :+1: @forkerino I like the metaphor! :sparkles: @forkerino Apart from the digging yourself into a hole part!! lol Pieter Stokkink @forkerino Apr 23 2017 09:21 UTC lol I have a tendency to learn too many things at once. without applying them properly. Johnny @JohnnyBizzel Apr 23 2017 09:25 UTC @forkerino Remember the Feynman technique! https://www.youtube.com/watch?v=tkm0TNFzIeg a27-suryansh @a27-suryansh Apr 23 2017 09:30 UTC @a27-suryansh Hi The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. What does this means? Pieter Stokkink @forkerino Apr 23 2017 09:30 UTC @JohnnyBizzel thanks, that is very helpful. Looking at how I very quickly became proficient at JS, it is definitely due to helping beginners here and explaining the concepts to them. I precisely did what he said, i.e. when I noticed a gap in my knowledge, go back to studying and formulating an answer in the language that someone else could understand. CamperBot @camperbot Apr 23 2017 09:30 UTC forkerino sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles: :star2: 1661 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel Yasser Hussain @yasserhussain1110 Apr 23 2017 09:30 UTC @forkerino You can build it using React/Redux. If you have already learned React it will be easier for you to use it. As @JohnnyBizzel said I made it using Vue, but I am not sure that was the best decision as it took a long long time to finish it. Johnny @JohnnyBizzel Apr 23 2017 09:31 UTC @forkerino Yes, me too. Pairing up with others and explaining things definitely helps. @yasserhussain1110 Morning Yasser. Do you have a good opinion of Vue now? It is getting lots of good reports. Pieter Stokkink @forkerino Apr 23 2017 09:32 UTC @yasserhussain1110 it would be my first React project, so I'm still on the fence on whether it is too complex for that. or whether I should build something simpler first Yasser Hussain @yasserhussain1110 Apr 23 2017 09:34 UTC Morning @JohnnyBizzel I have a very good opinion of Vue. It has the potential to eat both React and Angular alive. Johnny @JohnnyBizzel Apr 23 2017 09:34 UTC @yasserhussain1110 Ha ha! Nom nom!! Pieter Stokkink @forkerino Apr 23 2017 09:34 UTC @yasserhussain1110 could you explain why? the eating part Johnny @JohnnyBizzel Apr 23 2017 09:34 UTC ^^ Feynman technique ^^ Pieter Stokkink @forkerino Apr 23 2017 09:35 UTC and maybe the alive part ;) Yasser Hussain @yasserhussain1110 Apr 23 2017 09:35 UTC Simple reason @forkerino . Much less boilerplate code. Tau Lin @TajoLin Apr 23 2017 09:35 UTC sorry,why is wrong? Yasser Hussain @yasserhussain1110 Apr 23 2017 09:36 UTC If you are not sure about React, what technology do you want to use for frontend? @forkerino JQuery? Pieter Stokkink @forkerino Apr 23 2017 09:36 UTC @yasserhussain1110 ok, that sounds good. Johnny @JohnnyBizzel Apr 23 2017 09:36 UTC I had a look at Ember but got stuck trying to make a table but I will definitely take a look at Vue :+1: @forkerino I would encourage you to try one of the frameworks Pieter Stokkink @forkerino Apr 23 2017 09:36 UTC @yasserhussain1110 I despise jQuery :smile: I usually use vanilla js with simple templating (usually ejs) @TajoLin your cases don't need to compare, just do case "bob": and so on Yasser Hussain @yasserhussain1110 Apr 23 2017 09:37 UTC I would say try out React. Its not half bad you know. Pieter Stokkink @forkerino Apr 23 2017 09:38 UTC I definitely will. I bought a udemy course on React / Redux, which is very good so far, and will continue studying it. Step 2 is to actually write some code. Yasser Hussain @yasserhussain1110 Apr 23 2017 09:38 UTC :+1: a27-suryansh @a27-suryansh Apr 23 2017 09:39 UTC @forkerino Can you please help me with JS Pieter Stokkink @forkerino Apr 23 2017 09:39 UTC @a27-suryansh what question do you have? Keon Samuel @keonsam Apr 23 2017 09:39 UTC sure @a27-suryansh a27-suryansh @a27-suryansh Apr 23 2017 09:40 UTC @forkerino Still stucked on the same challenge We have an array of objects representing different people in our contacts lists. A lookUpProfile function that takes firstName and a property (prop) as arguments has been pre-written for you. The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact. If both are true, then return the "value" of that property. If firstName does not correspond to any contacts then return "No such contact" If prop does not correspond to any valid properties then return "No such property" Johnny @JohnnyBizzel Apr 23 2017 09:40 UTC @forkerino Is that Stephen Grider's course? Lookup profile is back Yasser Hussain @yasserhussain1110 Apr 23 2017 09:41 UTC can you post what you have tried so far @a27-suryansh ? Johnny @JohnnyBizzel Apr 23 2017 09:41 UTC You are never far away from a lookup profile problem... Dev44 @Dev44 Apr 23 2017 09:41 UTC @TajoLin use only case"bob": for ur first exemple Yasser Hussain @yasserhussain1110 Apr 23 2017 09:41 UTC true that @JohnnyBizzel Pieter Stokkink @forkerino Apr 23 2017 09:41 UTC @JohnnyBizzel yes, indeed. Modern React with Redux. He's a great teacher. Johnny @JohnnyBizzel Apr 23 2017 09:41 UTC @forkerino We have based our Night life app on that. (and a couple of other courses) Pieter Stokkink @forkerino Apr 23 2017 09:42 UTC shows the things that generally can go wrong and explains why, rather than showing the one true path. a27-suryansh @a27-suryansh Apr 23 2017 09:42 UTC  //Setup var contacts = [ { "firstName": "Akira", "lastName": "Laine", "number": "0543236543", "likes": ["Pizza", "Coding", "Brownie Points"] }, { "firstName": "Harry", "lastName": "Potter", "number": "0994372684", "likes": ["Hogwarts", "Magic", "Hagrid"] }, { "firstName": "Sherlock", "lastName": "Holmes", "number": "0487345643", "likes": ["Intriguing Cases", "Violin"] }, { "firstName": "Kristian", "lastName": "Vos", "number": "unknown", "likes": ["Javascript", "Gaming", "Foxes"] } ]; function lookUpProfile(firstName, prop){ // Only change code below this line for (var i=0; i < contacts.length; i++) { for (var j=0; j< contacts[i].length; j++) { firstName = contacts[i][j]; } } // Only change code above this line } // Change these values to test your function lookUpProfile("Akira", "likes"); @JohnnyBizzel Tau Lin @TajoLin Apr 23 2017 09:42 UTC @forkerino Thank you! CamperBot @camperbot Apr 23 2017 09:42 UTC tajolin sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles: :star2: 1871 | @forkerino |http://www.freecodecamp.com/forkerino Pieter Stokkink @forkerino Apr 23 2017 09:42 UTC @a27-suryansh you only need one loop. contacts is an array, but inside it are objects, for which you have to use something other than a loop. Use if / else inside the loop @TajoLin :+1: Johnny @JohnnyBizzel Apr 23 2017 09:43 UTC @a27-suryansh .hasOwnProperty will check for the existence of a property Stephen James @sjames1958gm Apr 23 2017 09:43 UTC @a27-suryansh if firstName is an actual contact's firstName this implies that you need an if check of the parameter firstName vs. the property and the given property (prop) is a property of that contact. and you should check that prop exists on the contact Pieter Stokkink @forkerino Apr 23 2017 09:43 UTC @sjames1958gm oh my, do you ever sleep? you seem to be always here Keon Samuel @keonsam Apr 23 2017 09:44 UTC do any of you guys ever sleep? Stephen James @sjames1958gm Apr 23 2017 09:44 UTC Damn dogs keep barking early in the morning Pieter Stokkink @forkerino Apr 23 2017 09:44 UTC :wroof: what time is it there? Stephen James @sjames1958gm Apr 23 2017 09:44 UTC 4:44 am Pieter Stokkink @forkerino Apr 23 2017 09:44 UTC ouch Keon Samuel @keonsam Apr 23 2017 09:44 UTC 4.44 lol @sjames1958gm is in the cool zone. Stephen James @sjames1958gm Apr 23 2017 09:45 UTC Hmm, not sure about that one Keon Samuel @keonsam Apr 23 2017 09:46 UTC best time zone on the planet. Pieter Stokkink @forkerino Apr 23 2017 09:47 UTC @sjames1958gm at least you got a head start, maybe you'll hit 7k today Stephen James @sjames1958gm Apr 23 2017 09:47 UTC lol Pieter Stokkink @forkerino Apr 23 2017 09:47 UTC about @sjames1958gm CamperBot @camperbot Apr 23 2017 09:47 UTC :star2: 6900 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm Pieter Stokkink @forkerino Apr 23 2017 09:48 UTC doable, but it'll be a long day Johnny @JohnnyBizzel Apr 23 2017 09:48 UTC lol Man needs to enjoy Sunday! Keon Samuel @keonsam Apr 23 2017 09:49 UTC anyone have a good tic tac toe AI I can copy? Pieter Stokkink @forkerino Apr 23 2017 09:50 UTC why would you do that? Johnny @JohnnyBizzel Apr 23 2017 09:50 UTC @keonsam Mine (also copied) :P Stephen James @sjames1958gm Apr 23 2017 09:51 UTC @keonsam Mine was simple enough. 1. take center square if empty 2. Win if possible 3. Block if needed 4. random move Pieter Stokkink @forkerino Apr 23 2017 09:51 UTC I started in a corner and had some initial logic but after pretty much followed steps 2-4 Johnny @JohnnyBizzel Apr 23 2017 09:52 UTC @keonsam This is the one I "borrowed" from http://codepen.io/parmsang/pen/LRBKYV It uses the Mini max algo. Pieter Stokkink @forkerino Apr 23 2017 09:53 UTC I couldn't beat the computer Mihai Caraghiorghe @mihaicaraghiorghe Apr 23 2017 09:53 UTC hello guys could you help me out to find where is the problem in the next code please function caseInSwitch(val) { var answer = ""; // Only change code below this line switch(val){ case val === 1 : answer = "alpha"; break; case val === 2: answer = "beta"; break; case val === 3: answer="gamma"; break; case val === 4: answer="delta"; break; } // Only change code above this line return answer; } // Change this value to test caseInSwitch(1); Pieter Stokkink @forkerino Apr 23 2017 09:55 UTC @mihaicaraghiorghe don't compare in your cases, just do case 1: the last break; is not needed, btw Mihai Caraghiorghe @mihaicaraghiorghe Apr 23 2017 09:55 UTC thanks! Pieter Stokkink @forkerino Apr 23 2017 09:56 UTC @mihaicaraghiorghe the switch automatically compares the argument to all the cases. Keon Samuel @keonsam Apr 23 2017 09:58 UTC how do you target an id that is stored in variable with Jquery? Pieter Stokkink @forkerino Apr 23 2017 09:59 UTC @keonsam the id of an element? or what? Keon Samuel @keonsam Apr 23 2017 10:00 UTC var test = "text"; if($("#"+test+"").html() =="hello"){
console.log(win);
}
like that.
Darth Skywalker
@adityaparab
Apr 23 2017 10:00 UTC
@keonsam wrap win in quotes
Keon Samuel
@keonsam
Apr 23 2017 10:01 UTC
oh thanks @adityaparab
CamperBot
@camperbot
Apr 23 2017 10:01 UTC
keonsam sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1023 | @adityaparab |http://www.freecodecamp.com/adityaparab
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 10:01 UTC

@keonsam


var test = $("#text"); if(test.html() =="hello"){ console.log(win); } why not do this instead? Mihai Caraghiorghe @mihaicaraghiorghe Apr 23 2017 10:01 UTC it s pretty awesome with this chat Pieter Stokkink @forkerino Apr 23 2017 10:01 UTC @HeebieGeeBee Hello! Darth Skywalker @adityaparab Apr 23 2017 10:01 UTC @keonsam $("#"+test+"") is exactly as same as \$("#"+test)
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 10:02 UTC
@forkerino yo
btw im not too sure test.html() will ever be "hello"
you might mean innerHTML or summin
Darth Skywalker
@adityaparab
Apr 23 2017 10:03 UTC
in that case, you should use .text() instead of .html()
HeebieGeeBee
@HeebieGeeBee
Apr 23 2017 10:04 UTC
or that
flansolo
@flansolo
Apr 23 2017 10:10 UTC
hi @forkerino hows that mongodb course going?
not that i know, i'm psychic
flansolo
@flansolo
Apr 23 2017 10:15 UTC
much quicker to go through to just go through beta fcc for basics. use mlab instead of setting up a local mongodb (though it is fun, but takes up a bit of root/ram)
you prob already know
Pieter Stokkink
@forkerino
Apr 23 2017 10:17 UTC
@flansolo yeah, I know how to use mLab, and have been using it for my backend projects, but wanted to know more about the inner workings, so started the course. It is great, but this week is a tough week. I think the amount of lecture time is at least 4 times that of the last few weeks. But I'm learning a ton.
flansolo
@flansolo
Apr 23 2017 10:18 UTC
while i'm here i'll ask again anyone know the details of dns.lookup() or nodejs? i can't get the http(s) protocol being put as args for host without getting an err
awesome @forkerino
again using dns.lookup and works for www but not for http(s) protocol url's
spradooooo
@spradooooo
Apr 23 2017 10:19 UTC
can't figure out tis challenge
Escape Sequences in Strings
flansolo
@flansolo
Apr 23 2017 10:19 UTC
i'm getting err returned in the function callback
Pieter Stokkink
@forkerino
Apr 23 2017 10:19 UTC
@flansolo Your problem doesn't ring a bell for me, is it a certain exercise on FCC?
@spradooooo what did you try?
Stephen James
@sjames1958gm
Apr 23 2017 10:20 UTC
@spradooooo Show your attempt
flansolo
@flansolo
Apr 23 2017 10:20 UTC
yeah @forkerino the url shortener microservice
spradooooo
@spradooooo
Apr 23 2017 10:20 UTC
@flansolo spradooooo
flansolo
@flansolo
Apr 23 2017 10:20 UTC
maybe i'm missing something but the example they have on beta can take http(s)
Stephen James
@sjames1958gm
Apr 23 2017 10:20 UTC
@flansolo dns.lookup?
spradooooo
@spradooooo
Apr 23 2017 10:20 UTC
var myStr; "FirstLine\n\SecondLine\ \rThirdLine";
Stephen James
@sjames1958gm
Apr 23 2017 10:21 UTC
@spradooooo You have to assign to myStr and remove all spaces
flansolo
@flansolo
Apr 23 2017 10:21 UTC
weird because it returns invalid url for www, etc. but only returns valid if using http(s) protocol
spradooooo
@spradooooo
Apr 23 2017 10:21 UTC
man i am so stupid
flansolo
@flansolo
Apr 23 2017 10:22 UTC
no you aren't
spradooooo
@spradooooo
Apr 23 2017 10:22 UTC
@spradooooo thanks alot
CamperBot
@camperbot
Apr 23 2017 10:22 UTC
sorry spradooooo, you can't send brownie points to yourself! :sparkles: :sparkles:
flansolo
@flansolo
Apr 23 2017 10:22 UTC
you're so spardooooo
spradooooo
@spradooooo
Apr 23 2017 10:22 UTC
@ flansolo hahahahah
Stephen James
@sjames1958gm
Apr 23 2017 10:22 UTC
@spradooooo More practice and some things you forget now will become second nature
Pieter Stokkink
@forkerino
Apr 23 2017 10:23 UTC
@flansolo can you show the code you have for checking the url?
Stephen James
@sjames1958gm
Apr 23 2017 10:23 UTC
@flansolo can you show some examples of what you mean?
flansolo
@flansolo
Apr 23 2017 10:23 UTC
yeah
spradooooo
@spradooooo
Apr 23 2017 10:23 UTC
@sjames1958gm i will try to focus more
flansolo
@flansolo
Apr 23 2017 10:23 UTC
app.post('/api/shorturl/new', function(req, res) {

dns.lookup(req.body.url, function(err, addr, fam) {
if(err) { res.json({ error: err }); }
else {
res.json({ original_url: req.body.url });
}
});
});
this is just the beginning of course
testing what gets returned
using node, express, obv
Stephen James
@sjames1958gm
Apr 23 2017 10:25 UTC
@flansolo do you have examples of what you pass to dns.lookup - that pass and fail? console.log(req.body.url)?
@spradooooo :+1:
flansolo
@flansolo
Apr 23 2017 10:26 UTC
well the form and an example of what it would post would be here:
https://thread-paper.glitch.me/
mine hasn't been setup, though i can set it up real quick like give me a min
Pieter Stokkink
@forkerino
Apr 23 2017 10:29 UTC
@flansolo it looks very much like what I have. I did a .trim on the url before passing it to dns.lookup, but other than that only the body of the callback function is different, cause I returned a boolean.
flansolo
@flansolo
Apr 23 2017 10:31 UTC
okay i was thinking of doing something along those lines @forkerino ty
CamperBot
@camperbot
Apr 23 2017 10:31 UTC
flansolo sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1873 | @forkerino |http://www.freecodecamp.com/forkerino
Stephen James
@sjames1958gm
Apr 23 2017 10:31 UTC
@flansolo what strings passed to dns.lookup pass - which fail?
flansolo
@flansolo
Apr 23 2017 10:32 UTC
well if you go there and submit a url with http(s) it will return an object with error key and values
otherwise www returns an object i set up just fine
Stephen James
@sjames1958gm
Apr 23 2017 10:33 UTC
@flansolo dns.lookup requires a hostname which www.something.com is but http://www.hostname.com is not a valid input into dns.lookup
flansolo
@flansolo
Apr 23 2017 10:33 UTC
yeah thats what i was getting from the testing i did @sjames1958gm ty
CamperBot
@camperbot
Apr 23 2017 10:33 UTC
flansolo sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6901 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
flansolo
@flansolo
Apr 23 2017 10:34 UTC
so basically like @forkerino said and do some trimming off of the protocol?
Stephen James
@sjames1958gm
Apr 23 2017 10:34 UTC
@flansolo Yep
flansolo
@flansolo
Apr 23 2017 10:35 UTC
okay then thats what the example app fcc posted must be doing, ty @forkerino @sjames1958gm
CamperBot
@camperbot
Apr 23 2017 10:35 UTC
flansolo sends brownie points to @forkerino and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: flansolo already gave forkerino points
:warning: flansolo already gave sjames1958gm points
Pieter Stokkink
@forkerino
Apr 23 2017 10:35 UTC
@flansolo @sjames1958gm I don't think I trimmed of the http(s):// I just did let url = String(req.body.url).trim()
flansolo
@flansolo
Apr 23 2017 10:36 UTC
i'm not seeing how that removes the protocol part
i was thinking maybe regex
Pieter Stokkink
@forkerino
Apr 23 2017 10:36 UTC
me neither, but it works for http/https
flansolo
@flansolo
Apr 23 2017 10:36 UTC
okay cool
Spyrantis Theodoros
@thodorisanta
Apr 23 2017 10:39 UTC

why is my page loading and never actually opens :/

http://codepen.io/oshikurou/pen/RVRqLM?editors=1011

Pieter Stokkink
@forkerino
Apr 23 2017 10:42 UTC
@thodorisanta not sure this is it, but you got an unexpected end of input error in your js, you probably need to close some code-block/function
a27-suryansh
@a27-suryansh
Apr 23 2017 10:43 UTC
@forkerino I think i am very close to the answer now

function lookUpProfile(firstName, prop){
// Only change code below this line
var result = false;
var value= "changed";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
result =true;
if (contacts[i].hasOwnProperty(prop) === true) {
value = contacts[i][prop];
}
}
else {
value ="No such property";
}
if (result === false) {
value ="No such contact";
}
return value;
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@forkerino
What am i doing wrong now
Pieter Stokkink
@forkerino
Apr 23 2017 10:44 UTC
@a27-suryansh don't return inside your loop. Also, the no such contact part is too early. You want to look at all contacts before deciding whether or not you have such a contact.
Mo Zargham
@Mozar10
Apr 23 2017 10:44 UTC
Ahh the old gitter chat. Used to come on here quite a lot
Good times
a27-suryansh
@a27-suryansh
Apr 23 2017 10:45 UTC

//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
var result = false;
var value= "changed";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
result =true;
if (contacts[i].hasOwnProperty(prop) === true) {
value = contacts[i][prop];
}
}
else {
value ="No such property";
}

}
if (result === false) {
value ="No such contact";
}
return value;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@forkerino is it okay now?
Pieter Stokkink
@forkerino
Apr 23 2017 10:46 UTC
I think your else needs to be after the second if, not after the first.
a27-suryansh
@a27-suryansh
Apr 23 2017 10:47 UTC
ok
Pieter Stokkink
@forkerino
Apr 23 2017 10:48 UTC
@a27-suryansh it was a little hard to spot because of the indentation.
a27-suryansh
@a27-suryansh
Apr 23 2017 10:48 UTC
Finally it is working now @forkerino
Pieter Stokkink
@forkerino
Apr 23 2017 10:48 UTC
great@!
Mo Zargham
@Mozar10
Apr 23 2017 10:48 UTC
@a27-suryansh GOOD JOB !!!!
Pieter Stokkink
@forkerino
Apr 23 2017 10:48 UTC
@a27-suryansh there's still several ways to improve your code a bit, if you're up to that.
a27-suryansh
@a27-suryansh
Apr 23 2017 10:48 UTC
I don't know how i solved it seems like a fluke @forkerino @Mozar10
Mo Zargham
@Mozar10
Apr 23 2017 10:49 UTC
Hey man if you got the check mark ;) But always good to dig deep and understand why its working
Pieter Stokkink
@forkerino
Apr 23 2017 10:49 UTC
@a27-suryansh definitely understand why it works before going further
it will be super helpful down the road
Mo Zargham
@Mozar10
Apr 23 2017 10:50 UTC
True ^
a27-suryansh
@a27-suryansh
Apr 23 2017 10:50 UTC
Thanks for your advice :) @Mozar10 @forkerino
CamperBot
@camperbot
Apr 23 2017 10:50 UTC
a27-suryansh sends brownie points to @mozar10 and @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1874 | @forkerino |http://www.freecodecamp.com/forkerino
:cookie: 345 | @mozar10 |http://www.freecodecamp.com/mozar10
Mo Zargham
@Mozar10
Apr 23 2017 10:50 UTC
YAY free brownies :D
Pieter Stokkink
@forkerino
Apr 23 2017 10:51 UTC
I got a two line solution for profile lookup if anyone's interested.... :P
Aniculaesei
@Aniculaesei
Apr 23 2017 10:52 UTC
Hello guys!Can you help me a little bit pls?Thank you:

function titleCase(str) {
var newstr = [];
newstr = str.toLowerCase().split(" ");
for( x = 0;x <= newstr.length;x++){
newstr[x].push(newstr[x][0].toUpperCase() + newstr[x].slice(1));

}

return newstr;
}

titleCase("I'm a little tea pot");
a27-suryansh
@a27-suryansh
Apr 23 2017 10:52 UTC
@forkerino seriously ?
Pieter Stokkink
@forkerino
Apr 23 2017 10:52 UTC
@Aniculaesei the condition of your for loop is wrong,
@a27-suryansh yes
a27-suryansh
@a27-suryansh
Apr 23 2017 10:52 UTC
Please show me @forkerino
Pieter Stokkink
@forkerino
Apr 23 2017 10:52 UTC
@a27-suryansh it's something I came up with once I learned more.
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 10:52 UTC
hi all
Pieter Stokkink
@forkerino
Apr 23 2017 10:53 UTC
function lookUpProfile(firstName, prop){
let found = contacts.find(v => v.firstName == firstName);
return found ? found[prop] || "No such property" : "No such contact";
}
Mo Zargham
@Mozar10
Apr 23 2017 10:53 UTC
whoa @forkerino that's nice
Pieter Stokkink
@forkerino
Apr 23 2017 10:53 UTC
@Aniculaesei it will go up to newstr.length, but that is out of bounds on the array you have
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 10:53 UTC

in challenge "Testing Objects for Properties" the instruntions was this:

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

a27-suryansh
@a27-suryansh
Apr 23 2017 10:53 UTC
Didn't understood a word, you are a genius! wish i could be a great programmer just like you one day :)
Pieter Stokkink
@forkerino
Apr 23 2017 10:54 UTC
@Mozar10 thanks
CamperBot
@camperbot
Apr 23 2017 10:54 UTC
forkerino sends brownie points to @mozar10 :sparkles: :thumbsup: :sparkles:
:cookie: 346 | @mozar10 |http://www.freecodecamp.com/mozar10
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 10:54 UTC

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

function checkObj(checkProp) {
// Your Code Here

return myObj.hasOwnProperty(checkProp);
}

// Test your code by modifying these values
checkObj("gift");

Pieter Stokkink
@forkerino
Apr 23 2017 10:54 UTC
@a27-suryansh I started learning 5 months ago. You can achieve this too, all it takes is time and dedication and an experimental mindset.
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 10:54 UTC
what i did wrong?
Mo Zargham
@Mozar10
Apr 23 2017 10:54 UTC
It's super ES6 ee
:D
Jor
@joreyesl
Apr 23 2017 10:54 UTC
i need a one liner
Pieter Stokkink
@forkerino
Apr 23 2017 10:54 UTC
@joreyesl lol
Aniculaesei
@Aniculaesei
Apr 23 2017 10:55 UTC
@forkerino .I dont understand.Sorry :(
a27-suryansh
@a27-suryansh
Apr 23 2017 10:55 UTC
Really 5 Months and so much progress @forkerino did you know any other language before practicing JS here?
Pieter Stokkink
@forkerino
Apr 23 2017 10:55 UTC
@Aniculaesei x < newstr.length, not <=
heroiczero
@heroiczero
Apr 23 2017 10:55 UTC
@lazarocastro use a if statement to check if it has the code and return the code i think
Pieter Stokkink
@forkerino
Apr 23 2017 10:55 UTC
@a27-suryansh I read a bit here and there, so didn't start from 0, but never got into the habit of writing code before that.
Aniculaesei
@Aniculaesei
Apr 23 2017 10:56 UTC
But why not with =?Because starts with 0? @forkerino
a27-suryansh
@a27-suryansh
Apr 23 2017 10:56 UTC
@forkerino Great! You have inspired me today!
Pieter Stokkink
@forkerino
Apr 23 2017 10:56 UTC
@Aniculaesei the loop will run until the condition is false. When x == newstr.length, you cannot read that index in the array, because that doesn't exist.
Mo Zargham
@Mozar10
Apr 23 2017 10:57 UTC
@forkerino I had never checked out array.find() .. reading on it now.. pretty cool!
a27-suryansh
@a27-suryansh
Apr 23 2017 10:57 UTC
What all languages have you learned till now in this 5 months @forkerino
Jor
@joreyesl
Apr 23 2017 10:57 UTC
@forkerino is a very dedicated person. Every time I see him, he is working on learning something new.
a27-suryansh
@a27-suryansh
Apr 23 2017 10:57 UTC
@joreyesl I don't doubt it he is always available here to help :)
Pieter Stokkink
@forkerino
Apr 23 2017 10:58 UTC
@a27-suryansh mostly JS, but I've learned a little bit of C, Java, Python and Elixir, because I want to broaden my scope. But JS is a huge topic once you get into Node.js and some of the frameworks. Still learning, every single day.
a27-suryansh
@a27-suryansh
Apr 23 2017 10:59 UTC
ok
CodeGeek3
@codeGeek3
Apr 23 2017 10:59 UTC
I am back
Kleiton1998
@Kleiton1998
Apr 23 2017 10:59 UTC
hi
CodeGeek3
@codeGeek3
Apr 23 2017 10:59 UTC
can I write code like this 'case 1, 3, 4: statement; break;' ?
Pieter Stokkink
@forkerino
Apr 23 2017 10:59 UTC
@codeGeek3 no
Aniculaesei
@Aniculaesei
Apr 23 2017 10:59 UTC
@forkerino thank you
CamperBot
@camperbot
Apr 23 2017 10:59 UTC
aniculaesei sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1875 | @forkerino |http://www.freecodecamp.com/forkerino
CodeGeek3
@codeGeek3
Apr 23 2017 11:00 UTC
ok
Pieter Stokkink
@forkerino
Apr 23 2017 11:00 UTC
you have to do
case 1:
case 3:
case 4:
statement;
break;
@Aniculaesei you're welcome. Everything clear now?
amitp540
@amitp540
Apr 23 2017 11:02 UTC
trueOrFalse(true) should return "Yes, that was true"
how do i get this
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 11:03 UTC
@heroiczero Yeah, dude!!! I missing the "if" condition
Aniculaesei
@Aniculaesei
Apr 23 2017 11:03 UTC
@forkerino Almost....still have to find out how to rebuilt the string .... :(
Pieter Stokkink
@forkerino
Apr 23 2017 11:03 UTC
@a27-suryansh btw, don't get discouraged if you get stuck. This is the hardest part. I get stuck all the time. It is an opportunity to learn more, to dive deeper. Getting stuck is not a sign of being dumb or something, but a sign that you are breaking through a boundary on the way to more knowledge and understanding.
@Aniculaesei what is the opposite of .split()?
Aniculaesei
@Aniculaesei
Apr 23 2017 11:04 UTC

function titleCase(str) {
var newstr = [];
newstr = str.toLowerCase().split(" ");
for( x = 0;x < newstr.length;x++){
newstr[x] = newstr[x][0].toUpperCase() + newstr[x].slice(1);
newstr.push(newstr[x]);
}

return newstr;
}

titleCase("I'm a little tea pot");
Mo Zargham
@Mozar10
Apr 23 2017 11:04 UTC
.join()!!!!!!!!!
loool
Aniculaesei
@Aniculaesei
Apr 23 2017 11:04 UTC
.join @forkerino no?
Mo Zargham
@Mozar10
Apr 23 2017 11:04 UTC
I hope all of you do well on your journeys and reach success. KEEEEEP GOING!!!
Pieter Stokkink
@forkerino
Apr 23 2017 11:04 UTC
@Aniculaesei you don't need to both assign and push to the newstr array. and yes, join is useful.
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 11:05 UTC
@heroiczero I did:
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}
return "Not Found";
Khoa Le
@Zacele
Apr 23 2017 11:05 UTC
hi guys
Lázaro Avelino Santos de Castro
@lazarocastro
Apr 23 2017 11:05 UTC
@heroiczero It's works. Thanks!
CamperBot
@camperbot
Apr 23 2017 11:05 UTC
lazarocastro sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:star2: 1178 | @heroiczero |http://www.freecodecamp.com/heroiczero
Pieter Stokkink
@forkerino
Apr 23 2017 11:05 UTC
@Zacele good day!
Khoa Le
@Zacele
Apr 23 2017 11:05 UTC
in the Where do I belong challenge
Aniculaesei
@Aniculaesei
Apr 23 2017 11:05 UTC
@forkerino So I have to try only with .join?With no push service?
Pieter Stokkink
@forkerino
Apr 23 2017 11:06 UTC
@Aniculaesei yes, but .join after your loop
Khoa Le
@Zacele
Apr 23 2017 11:06 UTC
the sort() mention in the instruction is supposed to sort from lowest to the highest
or just the simple arr.sort();
Pieter Stokkink
@forkerino
Apr 23 2017 11:06 UTC
@Zacele it depends, with numbers you have to pass in a function to make it work properly.
Aniculaesei
@Aniculaesei
Apr 23 2017 11:06 UTC
@forkerino ok..I wil try ....
Khoa Le
@Zacele
Apr 23 2017 11:07 UTC
getIndexToIns([40, 60], 50) should return 1.
that example is really comfused me
Pieter Stokkink
@forkerino
Apr 23 2017 11:08 UTC
@Zacele if you have a sorted array of all the numbers [40,50,60], the index of the second argument 50 is 1
Aniculaesei
@Aniculaesei
Apr 23 2017 11:09 UTC
@forkerino this is not good :(
newstr = newstr[x].join(" ");
}
Pieter Stokkink
@forkerino
Apr 23 2017 11:10 UTC
@Aniculaesei nope. after your loop simply .join newstr (no x)
Aniculaesei
@Aniculaesei
Apr 23 2017 11:12 UTC
@forkerino thank you man.I dont know why I can't resolve theese problems myself.It's very hard :(
CamperBot
@camperbot
Apr 23 2017 11:12 UTC
aniculaesei sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: aniculaesei already gave forkerino points
a27-suryansh
@a27-suryansh
Apr 23 2017 11:15 UTC
What happens if we nest an if statement in an if statement ?
Pieter Stokkink
@forkerino
Apr 23 2017 11:16 UTC
@Aniculaesei I did most of them myself, because I don't like admitting I don't understand something. :) The way I did it was to learn how to debug, read the documentation over at MDN (sometimes multiple times for the same method), use a tool like pythontutor.com to visualize code execution and read everything again and again. Sometimes it is easier to ask for help, but if you do, make sure you understand everything before you move on. It is also good to periodically go back to an exercise you had problems with, reset the code and rewrite everything without asking for help. This will cement the knowledge and make you learn a lot.
@a27-suryansh what do you expect to happen?
forkerino @forkerino is having lunch, see you later!
a27-suryansh
@a27-suryansh
Apr 23 2017 11:18 UTC
if (4>2) { console.log ("Hi");
if (6>3) { console.log ("Bye"); } }
Bye won't be printed if i change the first "if" statement "condition" is false right?
Aniculaesei
@Aniculaesei
Apr 23 2017 11:19 UTC
@forkerino the problem is I can't resolve any algoritm problem without help :(
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:21 UTC
@a27-suryansh yes both will not print, if first one gets false !
a27-suryansh
@a27-suryansh
Apr 23 2017 11:22 UTC
@forkerino
Here is my working but i am experimenting with it

function lookUpProfile(firstName, prop){
// Only change code below this line
var result = false;
var value= "changed";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
result =true;
if (contacts[i].hasOwnProperty(prop) === true) {
value = contacts[i][prop];

}
else {
value ="No such property";
}
}

}
if (result === false) {
value ="No such contact";
}
return value;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
So suppose @forwebtech why does it not work if i modify my code to this

function lookUpProfile(firstName, prop){
// Only change code below this line
var result = false;
var value= "changed";
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName) {
result =true;
if (contacts[i].hasOwnProperty(prop) === true) {
value = contacts[i][prop];

}
}
else {
value ="No such property";
}

}
if (result === false) {
value ="No such contact";
}
return value;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@forwebtech i have moved else statement outside the main if statement
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:25 UTC
@a27-suryansh because, if firstName will not find then it should return no such property, instead then it should return no such contact
by your code !
rugano
@rugano
Apr 23 2017 11:28 UTC
function lookUpProfile(firstName,prop){
//Only change code below this line.
if(firstName === firstName && firstName === prop){
output = "lastName";
}else{
output = "No such property";
}if(firstName != firstName){
output = "No such contact";
}return output;
//only change code above this line
}

//Change these values to test your function
lookUpProfile("Akira","likes");
What is wrong with this code?
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:29 UTC
@a27-suryansh you can look at this for improvement !
function lookUpProfile(firstName, prop){
// Only change code below this line
var str;

for ( i = 0 ;i < contacts.length; i++ ) {

// checking firstName from our data
if (firstName == contacts[i].firstName) {

/* checking whther our profiles have
that property or not  */
if(contacts[i].hasOwnProperty(prop)) {

return contacts[i][prop];

} else {
return 'No such property';
}

}

}

return 'No such contact';

// Only change code above this line
}
a27-suryansh
@a27-suryansh
Apr 23 2017 11:30 UTC
Got it Thanks @forwebtech
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:30 UTC
@rugano it only check one time but you have more than one profiles !
rugano
@rugano
Apr 23 2017 11:35 UTC
@forwebtech ok,so how should i correct that?
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:35 UTC
@rugano also your conditional statement is wrong because you are required to check into object, for that we do that,

if ( first name argument  equal to  the first name in your contacts
&&
prop argument equal to the property in your contacts )

Mostafa Hesham
@mhesham32
Apr 23 2017 11:36 UTC
please help me understanding indexOf()
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:36 UTC
@rugano try to use loop
@mhesham32 Index Of
Ramesh Mahajan Remi
@remimahajan
Apr 23 2017 11:38 UTC
Please help me with this
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:39 UTC
@rugano try to make that :smile:
function lookUpProfile(firstName, prop){

for ( i = 0 ;i < contacts.length; i++ ) {
// checking firstName from our data
if (firstName == firstName in your contacts object) {

// checking whther our profiles have that property or not
if( prop is equal to the property in your contacts object ) {
return that property from your object;
} else {
return 'No such property';
}
}
}
return 'No such contact';
}
Ramesh Mahajan Remi
@remimahajan
Apr 23 2017 11:40 UTC
why?
My code is wrong?
anyone please help me
Khoa Le
@Zacele
Apr 23 2017 11:43 UTC
hey guys
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:44 UTC
@remimahajan your code is almost fine ! but you have to put return 'no such contact' out of the loop !
Khoa Le
@Zacele
Apr 23 2017 11:44 UTC
what is the difference between 2 of these versions of the code

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var newArr= arr.push(num);
return newArr;
}
and this
Pieter Stokkink
@forkerino
Apr 23 2017 11:44 UTC
hello
Khoa Le
@Zacele
Apr 23 2017 11:45 UTC

function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.push(num);
var newArr =arr ;
return newArr;
}

getIndexToIns([10, 20, 30, 40, 50], 30);
why the first one return newArr as like arr.push(num).length();
and the second one return a new Arr with the new item
Pieter Stokkink
@forkerino
Apr 23 2017 11:46 UTC
@Zacele the first one puts a number in newArr (.push returns a number), the second puts a reference to the array in newArr
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:46 UTC
@Zacele first one is fine, but in second one you are not getting new array, because array.push(num) returns the new array, don't change the existing once !
Ramesh Mahajan Remi
@remimahajan
Apr 23 2017 11:46 UTC
ah ok got it thanks @forwebtech
CamperBot
@camperbot
Apr 23 2017 11:46 UTC
remimahajan sends brownie points to @forwebtech :sparkles: :thumbsup: :sparkles:
:cookie: 312 | @forwebtech |http://www.freecodecamp.com/forwebtech
Aizaz Shahid
@aizazshahid
Apr 23 2017 11:48 UTC
@forkerino i told something wrong please correct me ??