These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Apr 2016
Alex Boquist
@aplchian
Apr 05 2016 00:02
hi, im working on the react recipe app and im having a little trouble
could someone check out my code and see why the jquery .val function isn't populating the fields when a user edits an existing recipe
bitgrower
@bitgrower
Apr 05 2016 00:02
you might have better luck checking in in the backend room, @aplchian ...
help room
CamperBot
@camperbot
Apr 05 2016 00:02
its a front end app @bitgrower
bitgrower
@bitgrower
Apr 05 2016 00:03
okay ... well, react isn't covered in the FCC front end cert stuff ...
Alex Boquist
@aplchian
Apr 05 2016 00:03
oops.. wrong one^^
gotchya
ill try there
do you know how i find that room?
bitgrower
@bitgrower
Apr 05 2016 00:04
this room is mostly oriented around the FCC front end js challenges
scroll up ...
Elijah
@Elijahhh
Apr 05 2016 00:11
This message was deleted
Coy Sanders
@coymeetsworld
Apr 05 2016 00:19
@aplchian click on the world icon top right corner, that will show you all the FCC rooms
Hussein Zaki
@Hussein90
Apr 05 2016 00:22
please help me
i stock in Stand in Line
i solved it
Jeremy Benson
@jb840w
Apr 05 2016 00:37
hey all, just finished my diff two arrays challenge. My solution worked but I can't help but feel like I should have been able to shorten it. I would love your thoughts
function diff(arr1, arr2) {
  var newArr = [];

  // Same, same; but different.

  for (i = 0; i < arr2.length; i++) {
    if (arr1.indexOf(arr2[i]) == -1) {
        newArr.push(arr2[i]);
        }
  }
  for (i = 0; i < arr1.length; i++) {
    if (arr2.indexOf(arr1[i]) == -1) {
        newArr.push(arr1[i]);
        }
  }

  return newArr;
}

diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Coy Sanders
@coymeetsworld
Apr 05 2016 00:43
try using the Array.reduce function @jb840w
Erin Heard
@ufi16
Apr 05 2016 00:44
i'm confused on the escape sequence in strings challenge. i can't figure out the format
Coy Sanders
@coymeetsworld
Apr 05 2016 00:49
what part you having problems with @ufi16 ?
Daniel Gonzales
@choppd
Apr 05 2016 00:49
@ufi16 Can you be a little more specific?
Jeremy Benson
@jb840w
Apr 05 2016 00:50
ooooh, I will try that. Thanks @coymeetsworld
CamperBot
@camperbot
Apr 05 2016 00:50
jb840w sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 458 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Erin Heard
@ufi16
Apr 05 2016 00:50
it's asking to use escape sequences to produce 'backslash tab tab carriage-return new-line' wishing a string
Coy Sanders
@coymeetsworld
Apr 05 2016 00:51
look at the table above @ufi16
basically you're replacing the word with the code
so instead of backslash, you would put "\\" in your string, tab would be \t
Will
@wroetzheim
Apr 05 2016 00:52
I all - I’m working on the FCC challenge to build a weather app - I am attempting to output the sunrise and sunset values which are returned as timestamps - I am failing to output the sunrise and sunset values correctly as hh:mm tt though - anyone know much about dates in JS?
Erin Heard
@ufi16
Apr 05 2016 00:53
so do i need to use single or double quotes or no quotes needed @coymeetsworld
Alex N.
@N0bl3
Apr 05 2016 00:54
@wroetzheim there is a specific Date constructor which you can call using new Date();
You can have a look at mdn knowing this :) goo d night
Coy Sanders
@coymeetsworld
Apr 05 2016 00:55
either/or @ufi16
as long as you use it in a pair, so don't start with a single quote and end with a double
clockwhys
@clockwhys
Apr 05 2016 00:56
I'm on the Understanding Case Sensitivity in Variables in JavaScript and I've used camelCase as described, but when I run the test it doesn't show that I've properly edited the studlyCapVar in both the declarations and assignments.
Erin Heard
@ufi16
Apr 05 2016 00:56
so do both quotes go around the first backslash like this '
'\'t
or this '\t'
clockwhys
@clockwhys
Apr 05 2016 00:56

// Declarations
var studlyCapVaR;
var properCamelCase;
var titleCaseOver;

// Assignments
studlyCapVar = 10;
properCamelCase = "A String";
titleCaseOver = 9000;

Daniel Gonzales
@choppd
Apr 05 2016 00:56
@ufi16 Like this '\ \t'
Coy Sanders
@coymeetsworld
Apr 05 2016 00:56
everything in between the quotes
Will
@wroetzheim
Apr 05 2016 00:57
I tried doing var sunset = New Date(response.sys.sunset);
but then it converts it to the user’s timezone, I think… do I just need to look up the user’s timezone and offset the response.sys.sunset to feed it that value to the date? Is there anyway to just disabled the client from converting when working with JS dates?
MrSkyWanker
@MrSkyWanker
Apr 05 2016 00:58

Greetings.
I'm trying to validate the Palindrome function. Here is my code :

function palindrome(str)
  {
    var strPurified = str.toLowerCase().replace(/[^a-z]/g,'');
    return strPurified === strPurified.split('').reverse().join('');
  }

palindrome("Eye, eye");

Howerver, "palindrome("1 eye for of 1 eye.") should return false." can't validate. Any hints?

Coy Sanders
@coymeetsworld
Apr 05 2016 00:58
:) @MrSkyWanker
you're not checking for digits
remember?
MrSkyWanker
@MrSkyWanker
Apr 05 2016 00:59
n_n
Coy Sanders
@coymeetsworld
Apr 05 2016 01:00
ignoring the digits gets you this: (eyeforofeye) which is a palindrome
(1eyeforof1eye) is not
MrSkyWanker
@MrSkyWanker
Apr 05 2016 01:00
See, /[^a-z] seems to get rid of ANYHTING that is not between a & z
Mark Perez
@Marky1019
Apr 05 2016 01:00
i don't understand what they are asking in Finding a Remainder in Javascript.
MrSkyWanker
@MrSkyWanker
Apr 05 2016 01:00
hence the ^
Coy Sanders
@coymeetsworld
Apr 05 2016 01:00
yes that is correct @MrSkyWanker
Erin Heard
@ufi16
Apr 05 2016 01:00
i'm still not getting it right. so if it was just a tab string it would look like this var myStr = "'\t'"; @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 01:00
but you don't want to just preserve a-z
@ufi16 just one pair of quotes
myStr = "\t";

or

myStr = '\t';
@MrSkyWanker you want to keep digits too
Erin Heard
@ufi16
Apr 05 2016 01:02
ok so if i need multiple escape routes would i still only need one pair
Coy Sanders
@coymeetsworld
Apr 05 2016 01:02
correct
Daniel Gonzales
@choppd
Apr 05 2016 01:02
@ufi16 backslash tab tab = "\ \t \t"
Coy Sanders
@coymeetsworld
Apr 05 2016 01:02
just put all the escape characters between the quotes
Erin Heard
@ufi16
Apr 05 2016 01:03
so it would look like this myStr = '\' '\t';
Coy Sanders
@coymeetsworld
Apr 05 2016 01:03
no just one pair of quotes
you should only have 2 total
and everything in between them
Erin Heard
@ufi16
Apr 05 2016 01:04
thank you @choppd
CamperBot
@camperbot
Apr 05 2016 01:04
ufi16 sends brownie points to @choppd :sparkles: :thumbsup: :sparkles:
:star: 269 | @choppd | http://www.freecodecamp.com/choppd
Coy Sanders
@coymeetsworld
Apr 05 2016 01:04
yeah @choppd has it right
tjhpae
@tjhpae
Apr 05 2016 01:17
can somebody help me break down the nested for loops lesson?
i just don't get it
i'm staring at the code and the solution and it doesn't make any sense to me at all

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++)
product *= (arr[i][j]);
}
// Only change code above this line
return product;
}

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

Coy Sanders
@coymeetsworld
Apr 05 2016 01:23
which part @tjhpae ?
tjhpae
@tjhpae
Apr 05 2016 01:24
can we go from outer to inner loop? @coymeetsworld
for (var i = 0; i<arr.length; i++)
arr.length = 3 right?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:24
yep
tjhpae
@tjhpae
Apr 05 2016 01:24
but when arr[i].length runs, what is it counting?
and why is "i" an array now?
harpoon747
@harpoon747
Apr 05 2016 01:24
Can someone please help with the code, it fails for the given condition below
function truncateString(str, num) {
  // Clear out that junk in your trunk
  if(num>3)
    return str.slice(0, num -3) + "...";
  else
    return str.slice(0, num) + "...";

}

truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2);
Coy Sanders
@coymeetsworld
Apr 05 2016 01:24
the array inside the array
so arr[0] = [1,2]
arr1 = [3,4]
arr[2] = [5,6,7]
Darrel Adams
@dadams-510
Apr 05 2016 01:26
@morrowr08 Thankis for your help, but I was referring about "nested arrays" within an array.
tjhpae
@tjhpae
Apr 05 2016 01:26
so "j<arr[i]" means that j<3?
Darrel Adams
@dadams-510
Apr 05 2016 01:26
I actually need to "unnest" arrays into just one array. @morrowr08
Daniel Gonzales
@choppd
Apr 05 2016 01:26

@tjhpae
Basically, you are looping through the inner for loop first (j) and the outer for loop second(i), and the function is complete when the outer for loop reaches i = length of your array.

So, when you look at your inner loop on the First iteration, j=0 and i =0, therefore you are multiplying the product by the 0th position of arr and the 0th position of the array inside that. And this pattern continues until you've satisfied your condition of i<arr.length

Coy Sanders
@coymeetsworld
Apr 05 2016 01:27
think you mean j < arr[i].length @tjhpae
tjhpae
@tjhpae
Apr 05 2016 01:27
yes i do @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 01:27
in which case when i is 0, arr[i].length is 2
tjhpae
@tjhpae
Apr 05 2016 01:28
and i'm still confused @choppd sorry
Coy Sanders
@coymeetsworld
Apr 05 2016 01:28
i is 1, arr[i].length is 2
i is 2, arr[i].length is 3 (it has [5,6,7])
tjhpae
@tjhpae
Apr 05 2016 01:28
oh ok that makes some sense. let me try to wrap my head around this
Coy Sanders
@coymeetsworld
Apr 05 2016 01:29
yeah its just a way for you to be able to access the numbers in nested arrays
tjhpae
@tjhpae
Apr 05 2016 01:30
if i is 0, arr[i].length is 2?
@coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 01:30
yes
arr[0] is [1,2], [1,2] has 2 elements so the length of the array is 2
César
@ICesarI
Apr 05 2016 01:30
@harpoon747, ...basket".length + 2); look at the end of your code. You don't need to truncate a text that has a length lower than num. In simple words, your code needs some additional condition for special cases, when str is very short and when is not necessary to truncate.
tjhpae
@tjhpae
Apr 05 2016 01:31

ok so

product = product * (arr[i][j]);

this is such a headache
Coy Sanders
@coymeetsworld
Apr 05 2016 01:32
yes thats what you put in between the arrays
tjhpae
@tjhpae
Apr 05 2016 01:32
is there a resource anyone is aware of that can explain this concept?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:32
or shorthand, product *= arr[i][j]
which part?
tjhpae
@tjhpae
Apr 05 2016 01:32
the product line
Coy Sanders
@coymeetsworld
Apr 05 2016 01:32
that shouldve been covered in an earlier challenge
Assignment with times equals
tjhpae
@tjhpae
Apr 05 2016 01:33
i understand the lessons coming up to it but now i'm just confused when it gets to this harder version of it
no, i get the shorthand
but how the code is running is where i get lost
Coy Sanders
@coymeetsworld
Apr 05 2016 01:33
....which doesn't exist anymore wtf?
César
@ICesarI
Apr 05 2016 01:34
@tjhpae can you show me your code again?
tjhpae
@tjhpae
Apr 05 2016 01:34

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i<arr.length; i++) {
for (var j = 0; j<arr[i].length; j++)
product *= (arr[i][j]);
}
// Only change code above this line
return product;
}

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

Coy Sanders
@coymeetsworld
Apr 05 2016 01:34
the code is not the problem @ICesarI
tjhpae
@tjhpae
Apr 05 2016 01:34
yes, it's not the code
Coy Sanders
@coymeetsworld
Apr 05 2016 01:34
he is having trouble understanding the concept
tjhpae
@tjhpae
Apr 05 2016 01:34
i just don't conceptually understand it
yes ^
Coy Sanders
@coymeetsworld
Apr 05 2016 01:35
helps to break it up into parts
César
@ICesarI
Apr 05 2016 01:35
I think it's because you have two loops, right?
tjhpae
@tjhpae
Apr 05 2016 01:35
yes, that's the lesson
right, i'm trying to @coymeetsworld
so the product line
could you help me break that line down?
product *= (arr[i][j]);
how is this calculating and executing the values?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:35
you are trying to calculate the product of all the numerical values found in those arrays
you have 1-7, so your answer should be 1*2*3*4*5*6*7
César
@ICesarI
Apr 05 2016 01:36
Think your first loop is a black box. And only when everything inside finish the task it's going to iterate again.
Rex Smith Jr.
@rsmith731
Apr 05 2016 01:36
is ember hard to learn?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:37
thats where the product *= comes into play
@ICesarI huh?
tjhpae
@tjhpae
Apr 05 2016 01:37
the code is fine @ICesarI
Coy Sanders
@coymeetsworld
Apr 05 2016 01:38
does my explanation make sense @tjhpae ?
César
@ICesarI
Apr 05 2016 01:39
I know, that's why you need some barebones. If your barebones are weak, everything you learn is weak.
tjhpae
@tjhpae
Apr 05 2016 01:39
@coymeetsworld i think you explained it well but i'm just really not getting it
thanks you though @coymeetsworld
CamperBot
@camperbot
Apr 05 2016 01:39
tjhpae sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 459 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
abhi-1995
@abhi-1995
Apr 05 2016 01:39
please help me to solve the celcius - fahreheit conversion test
César
@ICesarI
Apr 05 2016 01:40
That's why I'm telling you in another words, when there's one iteration in your loop, forget about that loop, and only think in the inner conditions, and do it. One way is with a paper typyng every event in your code.
Coy Sanders
@coymeetsworld
Apr 05 2016 01:40
ok @tjhpae well PM me if you want to talk about it further we can go over it
Daniel Gonzales
@choppd
Apr 05 2016 01:42
@abhi-1995 Can you post your code or what you're having trouble with?
tjhpae
@tjhpae
Apr 05 2016 01:43
@coymeetsworld thank you very much. i'm trying to go over all of the previous loop exercises and google for loops to see if i can get a better grasp of it first
CamperBot
@camperbot
Apr 05 2016 01:43
tjhpae sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: tjhpae already gave coymeetsworld points
tjhpae
@tjhpae
Apr 05 2016 01:43
the problem is that i understand all the lessons leading up to it
but the for loop concept is really throwing me off due to the arrays
Coy Sanders
@coymeetsworld
Apr 05 2016 01:44
just think of the first loop going through an array with 3 values: [1,2], [3,4], [5,6,7]
the second loop goes through each one of those arrays to access the numbers
tjhpae
@tjhpae
Apr 05 2016 01:45
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
console.log(arr[i]);
}
does this print out "5"?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:45
no that will print out
10
9
8
7
6
console.log(arr[i].length) would print out 5
tjhpae
@tjhpae
Apr 05 2016 01:46
gotcha
Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1.
what does this paragraph mean?
Coy Sanders
@coymeetsworld
Apr 05 2016 01:47
it means that indexing starts at 0
not 1
so the first element of an array you would access it by typing arr[0], not arr[1]
arr.length is 5, but you don't write i <= arr.length because the loop would iterate 6 times then
because i starts at 0, then it would go 1, 2, 3, 4, 5
Erin Heard
@ufi16
Apr 05 2016 01:48
i can't figure out what's wrong with my var set up it's supposed to be all together in one sentence. This is what I put: var wordBlanks = "'My ' + myAdjective + myNoun + myAdverb + myVerb + ' . '";
Coy Sanders
@coymeetsworld
Apr 05 2016 01:49
but you want to stop after 4, because there is no arr[5] entry
tjhpae
@tjhpae
Apr 05 2016 01:49
gotcha
makes sense
thanks again
Coy Sanders
@coymeetsworld
Apr 05 2016 01:49
remove the double quotes @ufi16
yeah, np @tjhpae
myAdjective, myNoun, myAdverb, myVerb are variables, they shouldn't be in between quotes
tjhpae
@tjhpae
Apr 05 2016 01:50
do you have any other tips for picking up JS? @coymeetsworld
i'm also looking at khan academy vids
César
@ICesarI
Apr 05 2016 01:50
@tjhpae, the loops are trying to reach all the array. Imagine in this case is a two dimensional array. In a real world can be a paper, with X and Y. So you start from 0 (index 0), that means it's the beginning. The first loop take one digit in X (or Y) and then with the inner loop will catch all the values in Y (or X). So it's like getting one line every time till you fill all the paper (all the array in this case)
tjhpae
@tjhpae
Apr 05 2016 01:50
which have helped with earlier concepts like funcitons
but idk
Coy Sanders
@coymeetsworld
Apr 05 2016 01:51
hmm hard to say @tjhpae, i don't have anything i could refer you too
tjhpae
@tjhpae
Apr 05 2016 01:51
all good
Coy Sanders
@coymeetsworld
Apr 05 2016 01:51
I actually have a background in CS so I know these concepts from a while ago
César
@ICesarI
Apr 05 2016 01:51
@tjhpae, It sounds complicated, but if you try executing the code manually, it will help you a lot.
Coy Sanders
@coymeetsworld
Apr 05 2016 01:51
and I learned them from different languages, I'm just learning JS now
César
@ICesarI
Apr 05 2016 01:53
@tjhpae, I heard JS4Cats is a good start.
Erin Heard
@ufi16
Apr 05 2016 01:55
still not getting it @coymeetsworld var wordBlanks = "My " + myAdjective + myNoun + myAdverb + myVerb;
Coy Sanders
@coymeetsworld
Apr 05 2016 01:55
you may need to add spaces in between the variables @ufi16, like myAdjective + " " + myNoun + " "
what was the challenge name?
Erin Heard
@ufi16
Apr 05 2016 01:57
WordBlanks
@coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 01:59
yeah so at a minimum you want to put spaces between each of your variables in your string like I showed above
Erin Heard
@ufi16
Apr 05 2016 01:59
i did and it's still not showing a product
Coy Sanders
@coymeetsworld
Apr 05 2016 01:59
can you post your code?
Erin Heard
@ufi16
Apr 05 2016 02:00

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

var wordBlanks = "My " + myAdjective + " fat " + myNoun + " jumped too " + myAdverb + " to " + myVerb;
// Your code above this line
return result;
}

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

Coy Sanders
@coymeetsworld
Apr 05 2016 02:00
oh ok you're using a different variable name
Justin
@daemedeor
Apr 05 2016 02:00
@tjhpae just practice practice practice. Go to codewars
Coy Sanders
@coymeetsworld
Apr 05 2016 02:00
instead of creating wordBlanks
assign that string to result
your function is always going to return an empty string, do you see why?
Erin Heard
@ufi16
Apr 05 2016 02:01
no, i'm confused by what you're saying
Coy Sanders
@coymeetsworld
Apr 05 2016 02:01
so your function is returning result right?

and you define it above as an empty string:

result = "";

Erin Heard
@ufi16
Apr 05 2016 02:01
yeah
Coy Sanders
@coymeetsworld
Apr 05 2016 02:01
but you don't do anything else with it
you instead create a new variable called wordBlanks and make your string there
Erin Heard
@ufi16
Apr 05 2016 02:02
gotcha
Coy Sanders
@coymeetsworld
Apr 05 2016 02:02
but, your function is returning result, not wordBlanks
so what you should do is instead of creating that variable, assign your string to result
then return result, that should work
Erin Heard
@ufi16
Apr 05 2016 02:02
i get what you're saying thank you @coymeetsworld
CamperBot
@camperbot
Apr 05 2016 02:02
ufi16 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 460 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 02:02
awesome, np @ufi16 let me know if it doesn't work
César
@ICesarI
Apr 05 2016 02:13
@ufi16, "return" is like your output in your code. So you can add something after return "hello word!" as an output. It can be an string, a variable, or a function. However, check if that can give you a value or sth similar.
(
function(){
     var sth = 'Hello'; // Makes in memory a "Hello" and save the ref in sth.
     return sth; // The return is "Hello"
} )()
(
function(){
     return var sth = 'Hello';; // Makes in memory a "Hello" and save the ref in sth but return never gets anything and you will get an error for that.
} )()
Jocsan Romero
@romeroj13
Apr 05 2016 02:15
Hello I need help. I need to Add a new album to the myMusic JSON object. Add artist and title strings, release_year number, and a formats array of strings. This is all the code I have and I don't know what I am doing wrong.
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
myMusic = [
{
"artist": "Josh Groban",
"title": "You Raise Me Up",
"release_year": 2012,
"formats":[
"CD",
"MP3"]
}
];
Coy Sanders
@coymeetsworld
Apr 05 2016 02:17
@romeroj13 you don't want to replace myMusic variable with your entry yo u want to add to it i think
see where it says //Add record here? thats where you should put your object in
Jocsan Romero
@romeroj13
Apr 05 2016 02:17
@coymeetsworld how ? lol
Coy Sanders
@coymeetsworld
Apr 05 2016 02:18
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
{
"artist": "Josh Groban",
"title": "You Raise Me Up",
"release_year": 2012,
"formats": [
"CD",
"MP3"]
}
];
in your example you overwrote myMusic so the Billy Joel object was wiped
Jocsan Romero
@romeroj13
Apr 05 2016 02:20
oh shoot nice! ok thanks @coymeetsworld !!
CamperBot
@camperbot
Apr 05 2016 02:20
romeroj13 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 461 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 05 2016 02:20
np @romeroj13
didn't mind sharing the code you had the right idea
Jocsan Romero
@romeroj13
Apr 05 2016 02:22
one more question was I appending the artists and title and release year etc to the old or did it create double of artist title etc
"artist" : "Billy Joel", "Josh Groban" .. or "artist" : "Billy Joel", "artist" : "Josh Groban"
Coy Sanders
@coymeetsworld
Apr 05 2016 02:24
should just be append
or sorry no, its 2 objects
each with its own artist value
Jocsan Romero
@romeroj13
Apr 05 2016 02:25
ooooh makes sense now thanks @coymeetsworld !
CamperBot
@camperbot
Apr 05 2016 02:25
romeroj13 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: romeroj13 already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 05 2016 02:26
yeah np
Nicole S.
@nicolesteck
Apr 05 2016 02:38

Hey all, can anyone help me make sense of this?

var obj = {
a: "hello world",
b: 42
};

var b = "a";

obj[b]; // "hello world"
obj["b"]; // 42

Can you explain why referencing b as a string literal vs a variable makes a difference?
Coy Sanders
@coymeetsworld
Apr 05 2016 02:40
obj[b] means obj["a"] @nicolesteck , since b="a"
obj["b"] is just obj["b"], "b" is a string literal, that doesn't reference the b variable you created
Nicole S.
@nicolesteck
Apr 05 2016 02:42
whereas obj["b"] isn't using it as a variable, so it can't be used to reference b="a"
oh it doesn't reference the b variable at all?
Coy Sanders
@coymeetsworld
Apr 05 2016 02:42
yes anything between quotes is what you call a string literal, you literally get whats between there
nope
Nicole S.
@nicolesteck
Apr 05 2016 02:43
in that case, I'm a bit confused -- obj.b and obj["b"] both reference the property b within the object obj... but obj[b] is referencing the separately-created variable b
correct?
Malcolm
@noinkling
Apr 05 2016 02:43
correctomundo
Coy Sanders
@coymeetsworld
Apr 05 2016 02:43
yes
Nicole S.
@nicolesteck
Apr 05 2016 02:43
that.... well, that's confusing
Coy Sanders
@coymeetsworld
Apr 05 2016 02:44
lol yeah i can see that
Nicole S.
@nicolesteck
Apr 05 2016 02:44
:) thanks @coymeetsworld
CamperBot
@camperbot
Apr 05 2016 02:44
nicolesteck sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 463 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Malcolm
@noinkling
Apr 05 2016 02:44
think of dot notation as a shortcut for bracket notation
Coy Sanders
@coymeetsworld
Apr 05 2016 02:44
its confusing because you have b in two different places, its a property name for a object, AND a variable you declare
in code you read/write don't think you'll typically see that, this is just a tutorial to show the difference
yeah @noinkling
Nicole S.
@nicolesteck
Apr 05 2016 02:45
yep makes sense (it's weird tht an intro js book chose to do so!). thank you coy and @noinkling
CamperBot
@camperbot
Apr 05 2016 02:45
nicolesteck sends brownie points to @noinkling :sparkles: :thumbsup: :sparkles:
:star: 645 | @noinkling | http://www.freecodecamp.com/noinkling
Coy Sanders
@coymeetsworld
Apr 05 2016 02:45
yeah maybe it could be explained differently @nicolesteck
what book is it from?
Malcolm
@noinkling
Apr 05 2016 02:46

@nicolesteck Maybe it would make more sense if you realize that:

var obj = {
a: "hello world",
b: 42
};

is exactly equivalent to:

var obj = {
"a": "hello world",
"b": 42
};
object property keys are all strings
Sukhjinder Singh
@sssuk2
Apr 05 2016 02:47
hi , Can anybody please help me with Word blanks in JavaScript
I don't know how to approach it
Malcolm
@noinkling
Apr 05 2016 02:48
This message was deleted
Sukhjinder Singh
@sssuk2
Apr 05 2016 02:48

hi , Can anybody please help me with Word blanks in JavaScript

I don't know how to approach it

Nicole S.
@nicolesteck
Apr 05 2016 02:49
@coymeetsworld You Don't Know JS
Elbert Cortez
@trip16661
Apr 05 2016 02:50
@sssuk2 paste your code in the format and im sure someone can help
help format
CamperBot
@camperbot
Apr 05 2016 02:51

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Nicole S.
@nicolesteck
Apr 05 2016 02:52

var testObj= {
cat: "hat",
dog: "smog"
};

var dog = "cat";

testObj[dog];
console.log("testObj[dog] yields " + testObj[dog]); //hat
testObj.dog;
console.log("testObj.dog yields " + testObj.dog); //smog
testObj["dog"];
console.log("testObj[\"dog\"] yields " + testObj["dog"]); //smog

In this case, why does the bracket notation - simply a longer version of the dot notation - yield a different result? Is it because bracket notation clarifies (due to the absence of the possible quotation marks) that it is a variable and not a string? In both of the first two instances - bracket and dot - I would expect the system to interpret those as the variable dog, not Obj.dog....

Sukhjinder Singh
@sssuk2
Apr 05 2016 02:52

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

// Your code above this line
return result;
}

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

and these are the requirements

wordBlanks("","","","") should return a string.

wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).

wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed words separated by non-word characters (and any additional words in your madlib).

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

// Your code above this line
return result;
}

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

1
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {

2
var result = "";

3
// Your code below this line

4

5

6

7

8

9
// Your code above this line

10
return result;

11
}

12

13
// Change the words here to test your function

14
wordBlanks("dog", "big", "ran", "quickly");

15

Help JavaScript

Dustin
@Key-Banger
Apr 05 2016 02:52
@sssuk2 concatenation is your friend for that challenge.
Sukhjinder Singh
@sssuk2
Apr 05 2016 02:53
@Key-Banger I didn't get you , sorry .
Coy Sanders
@coymeetsworld
Apr 05 2016 02:54
@nicolesteck dog is not a variable in the object
its a property
in testObj there is a cat property and a dog property
you can access them with dot notation (testObj.dog) or bracket (testObj["dog"])
Nicole S.
@nicolesteck
Apr 05 2016 02:55
oh so testObj[dog] isn't a valid way to access a property
if you omit the quotation marks?
Dustin
@Key-Banger
Apr 05 2016 02:55
@sssuk2 You can concatenate your function arguments into a string . Something like.
return "I wrote a string with a "+variable+" inside of it.";
Coy Sanders
@coymeetsworld
Apr 05 2016 02:56
it could work
but dog now is a variable named dog
Nicole S.
@nicolesteck
Apr 05 2016 02:56
and general best practice states that you use quotation marks?
Coy Sanders
@coymeetsworld
Apr 05 2016 02:56
that variable is different that the property dog inside testObj
Nicole S.
@nicolesteck
Apr 05 2016 02:56
gotcha. thank you!
Coy Sanders
@coymeetsworld
Apr 05 2016 02:56
yeah not necessarily w/ the quotation marks
if you use w/o you are basically referencing a variable called dog
Nicole S.
@nicolesteck
Apr 05 2016 02:57
if there's no variable dog will it default to obj.dog?
Coy Sanders
@coymeetsworld
Apr 05 2016 02:57
if you don't define that variable (i.e. var dog ="something") then you'll get an error
Nicole S.
@nicolesteck
Apr 05 2016 02:57
ohhhh
Coy Sanders
@coymeetsworld
Apr 05 2016 02:57
nope, the code won't know what to do
so it will give you an error saying dog is undefined or something like that
Nicole S.
@nicolesteck
Apr 05 2016 02:58
hmm.. it's behaving the same way as it was before -- i removed var dog
Coy Sanders
@coymeetsworld
Apr 05 2016 02:59
is it?
Nicole S.
@nicolesteck
Apr 05 2016 02:59

var testObj= {
cat: "hat",
dog: "smog"
};

testObj[dog];
console.log("testObj[dog] yields " + testObj[dog]); //hat
testObj.dog;
console.log("testObj.dog yields " + testObj.dog); //smog
testObj["dog"];
console.log("testObj[\"dog\"] yields " + testObj["dog"]); //smog

yeah, unless i'm missing something?
Coy Sanders
@coymeetsworld
Apr 05 2016 02:59
you get 3 lines of output on that?
Nicole S.
@nicolesteck
Apr 05 2016 03:00
yep, testObj[dog] yields hat
testObj.dog yields smog
testObj["dog"] yields smog
using firebug
Coy Sanders
@coymeetsworld
Apr 05 2016 03:00
try refreshing your browser
or console i mean
i don't think that should work
Nicole S.
@nicolesteck
Apr 05 2016 03:01
hey! it must have been hanging out in my cache; i emptied it and that fixed it.
thank you @coymeetsworld!
CamperBot
@camperbot
Apr 05 2016 03:01
nicolesteck sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: nicolesteck already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Apr 05 2016 03:01
ah lol ok, thought i was giving bad information for a second lol
Nicole S.
@nicolesteck
Apr 05 2016 03:02
nope! new enough to js that i still keep forgetting about cached items messing the results up.
Coy Sanders
@coymeetsworld
Apr 05 2016 03:03
yeah happens to everyone, i forget to do that too sometimes :)
Malcolm
@noinkling
Apr 05 2016 03:30
@nicolesteck ctrl + F5 to refresh without using cache, in case you don't already know
in Chrome at least
on Windows :stuck_out_tongue:
Sukhjinder Singh
@sssuk2
Apr 05 2016 04:05
hii guys , I am not able to understand the Word blanks

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

result = "wordBlanks";

// Your code above this line
return result;
}

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

Elbert Cortez
@trip16661
Apr 05 2016 04:06
@sssuk2 the thing that is in the () on the first line are the arguments
is like a place holder for what you are going to introduce later
in this case myNoun is dog
myAdjective is big
so using this logic you need to build a sentence using the arguments
dwayneabutcher
@dwayneabutcher
Apr 05 2016 04:10

Hey guys, could anyone tell me why this doesn't pass . ```js
function myTest(val) {
if (val > 10) {
return "Greater than 10";
}

else if (val < 5) {
return "Smaller than 5";
}
else {
return "Between 5 and 10";
}

// Change this value to test
myTest(7);
```

Elbert Cortez
@trip16661
Apr 05 2016 04:10
the place holders in the functions are separated by commas and when you call the function they work the same way
dwayneabutcher
@dwayneabutcher
Apr 05 2016 04:12
function myTest(val) {
  if (val > 10) {
    return "Greater than 10";
  }

  else if (val < 5) {
    return "Smaller than 5";
  }
  else {
  return "Between 5 and 10";
}

// Change this value to test
myTest(7);
This is on "Introducing Else If Statements" It says I still need to use 2 else statements.
However all of the test pass except for that one.
Daniel Gonzales
@choppd
Apr 05 2016 04:14
@dwayneabutcher You're missing an closing bracket } after your last else statement
parvinder30
@parvinder30
Apr 05 2016 04:14

```// Only change code below this line

var remainder;
remainder=11;
remainder =remainder % 3;```

```// Only change code below this line

var remainder;
remainder=11;
remainder =remainder % 3;```

dwayneabutcher
@dwayneabutcher
Apr 05 2016 04:15
@choppd Thanks man, I've been staring at it for 10 minutes and never seen it lol
CamperBot
@camperbot
Apr 05 2016 04:15
dwayneabutcher sends brownie points to @choppd :sparkles: :thumbsup: :sparkles:
:star: 272 | @choppd | http://www.freecodecamp.com/choppd
Daniel Gonzales
@choppd
Apr 05 2016 04:15
@dwayneabutcher No prob!
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 04:15
@dwayneabutcher @choppd I just didnt see that : P
parvinder30
@parvinder30
Apr 05 2016 04:15
code formatting help
Malcolm
@noinkling
Apr 05 2016 04:15
help formatting
CamperBot
@camperbot
Apr 05 2016 04:15

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

parvinder30
@parvinder30
Apr 05 2016 04:17

```// Only change code below this line

var remainder;
remainder=11;
remainder =remainder % 3;```

Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 04:18
@parvinder30 make sure that the ``` have their own line
// Only change code below this line

var remainder;
remainder=11;
remainder =remainder % 3;
parvinder30
@parvinder30
Apr 05 2016 04:18
// Only change code below this line

var remainder;
remainder=11;
remainder =remainder % 3;
Got it.....!!!!!
I'm doing this exercise..but unable to complete this
please help me out
Jose Barakat
@JoseBarakat
Apr 05 2016 04:19
Hi, can someone help me with "Exact Change"? I've been stuck for almost 4 days..
tupelo87
@tupelo87
Apr 05 2016 04:22
hi can someone help with profile lookup been stuck for a while and code doing something wierd
Jose Barakat
@JoseBarakat
Apr 05 2016 04:25
Hi @tupelo87 , I already did "Profile Lookup". What do you need?
tupelo87
@tupelo87
Apr 05 2016 04:25
i have if's inside for loop (tried while same thing) but if i put another if with != firstname i only get second if
for (var i=0; i < contacts.length; i++) {
if (contacts[i].firstName == firstName && contacts[i][prop] == prop){
return contacts[i][prop];
} else if (contacts[i].firstName != firstName){
return "No such contact";
}
}
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 04:26
@parvinder30 try remainder = 11 % 3. If it works, i dont know whats wrong
tupelo87
@tupelo87
Apr 05 2016 04:26
thats what i was trying first if works but when second is added it defaults to second
Jose Barakat
@JoseBarakat
Apr 05 2016 04:27
ok, let me take a look at it
tupelo87
@tupelo87
Apr 05 2016 04:27
ok thanks
Jose Barakat
@JoseBarakat
Apr 05 2016 04:29
try this aproach:
function lookUp(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++){
    if (firstName === contacts[i].firstName) {
      if (contacts[i][prop]) {
        return contacts[i][prop];
      } else {
          return "No such property";
        }
    }
  }
  return "No such contact";

// Only change code above this line
}
tupelo87
@tupelo87
Apr 05 2016 04:32
think that makes sence now thanks @JoseBarakat
CamperBot
@camperbot
Apr 05 2016 04:32
tupelo87 sends brownie points to @josebarakat :sparkles: :thumbsup: :sparkles:
dwayneabutcher
@dwayneabutcher
Apr 05 2016 04:32
This isn't running at all. What did I do wrong? What I wrote looks just like the examples to me. .
CamperBot
@camperbot
Apr 05 2016 04:32
:star: 318 | @josebarakat | http://www.freecodecamp.com/josebarakat
dwayneabutcher
@dwayneabutcher
Apr 05 2016 04:32
function myTest(num) {
  // Only change code below this line
  if (num < 5) {
    return "Tiny";
  }
  else if (num < 10) {
    return"Small";
  }
  else if (num < 15) {
    return"Medium";
  }
  else if (num < 20) {
    return"Large";
  }
  else (num >= 20){
    return"Huge";
  }

  // Only change code above this line
}

// Change this value to test
myTest(7);
This is for "Chaining If Else Statements"
Jose Barakat
@JoseBarakat
Apr 05 2016 04:35
Hi @dwayneabutcher
tupelo87
@tupelo87
Apr 05 2016 04:36
the else just has a return nothing else
else { return something; }
Daniel Gonzales
@choppd
Apr 05 2016 04:39
@dwayneabutcher You're last else statement isn't an else if statement, therefore, you don't need any conditions
else if (num >= 20) {
return "Huge";
} else {
return "Change Me"
}
Jose Barakat
@JoseBarakat
Apr 05 2016 04:39
Try this aproach:
Pseudocode:
  • If number is smaller than 5 -> Tiny
  • If number is between 5 and 10 ->Small
  • If number is between 10 and 15 -> Medium
  • If number is between 15 and 20 -> Large
  • If number is larger than 20 -> Huge
You can combine two conditions with "&&" operator
Daniel Gonzales
@choppd
Apr 05 2016 04:41
return "Change Me";     //added the semi-colon
Jose Barakat
@JoseBarakat
Apr 05 2016 04:45
Hi, has someone finished the "Exact Change" Algorithm Challenge?
tupelo87
@tupelo87
Apr 05 2016 04:47
i am no where near that i think i am just working through in order
Saturnino Abril
@saturninoabril
Apr 05 2016 04:56
@JoseBarakat I did
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 04:59
Hi guys
I am stuck at check for palindromes

function palindrome(str) {
// Good luck!
var strrev;

str=str.replace(/(?:[^/sa-zA-z0-9:_/(/)//\])/gi,'');
str=str.toLowerCase();
var arr=str.split("");
arr=arr.reverse();
strrev=arr.join("");
if (str===strrev)
return true;
else
return false;
}

palindrome("eye");

Every case except the last one is passing
Saturnino Abril
@saturninoabril
Apr 05 2016 05:05
@sudeepnarkar you need to change your regex and it will pass
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 05:05
Yes. Can you suggest how?
Saturnino Abril
@saturninoabril
Apr 05 2016 05:06
you may try like this
str=str.replace(/\W|_/g,'');
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 05:07
That worked
Thanks
I understand W
Can you explain the regex after that ?
Saturnino Abril
@saturninoabril
Apr 05 2016 05:09
"|" means logical or
"_" underscore (or under bar)
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 05:10
W already includes "_" right ?
Juan L
@rustyflakes
Apr 05 2016 05:10
need help
function lookUp(firstName, prop){
// Only change code below this line
var answer=[];//create array to store answer
for (var i=0; i < contacts.length; i++){
      if (contacts[i].firstName === firstName){//check for first name
         answer.push(contacts[i].firstName);//push firstname's value to answer array.
                                            //return answer; till this point will give me
                                      //array with the first name.
        if (contacts[i].hasOwnProperty(prop)){// evaluate if contacts in position i
                                              // hasOwnProperty of prop.
          answer.push(contacts[i].prop);      // push prop's value to answer array
          return answer;
        }

        else{
            return "no such property";
        }


      } 
  else {
        return "No such contact";
      }
}
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 05:10
\w means [a-zA-Z0-9_]
correct me if I am wrong
Juan L
@rustyflakes
Apr 05 2016 05:11
im stuck on contacts[i].hasOwnProperty(prop) i don't know if that statement gives me a true or false.
Saturnino Abril
@saturninoabril
Apr 05 2016 05:12
@sudeepnarkar yes, you're correct... actually you don't need that and it will pass
str=str.replace(/\W/g,'');
Camoen
@Camoen
Apr 05 2016 05:14
my weather API won't refresh the data when I page refresh. Is there a way for me to do that? http://codepen.io/Camoen/pen/EKbyNx?editors=1010
Juan L
@rustyflakes
Apr 05 2016 05:14
anyone?
Saturnino Abril
@saturninoabril
Apr 05 2016 05:15
@rustyflakes it will return true if such contact (of [i]) has property 'prop'
Sudeep Narkar
@sudeepnarkar
Apr 05 2016 05:15

@rustyflakes Try this
function lookUp(firstName, prop){
// Only change code below this line
for(i = 0; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName){ // name exsits - good!
if (contacts[i][prop]) // property exists - good !
return contacts[i][prop]; // return values you need
else
return "No such property"; // if name exists and property doesnt, return appropriate comment (prop not exists)
}

}
return "No such contact"; // return what didnt meet the conditions (no such firstname)

// Only change code above this line
}
// Change these values to test your function
lookUp("Akira", "likes");

Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:16
@Camoen Its working.
Apoorve
@apugoneappu
Apr 05 2016 05:16
<link rel="stylesheet" href="animate.min.css">
<link rel="stylesheet" href="style.css">
<p id="p1">Hello</p>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <script>
  $(document).ready(function() {
    $("#p1").addClass("animated infinite bounce");
  });
  </script>
Why is the p element not shaking?
Camoen
@Camoen
Apr 05 2016 05:17
@rithvikvibhu Is it showing the temperature for you in browser? it has been showing me the same temperature all day
seems like it should have changed by now
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:17
@apugoneappu if you want to 'shake' the <p>, then try 'shake' class instead of 'bounce'
Apoorve
@apugoneappu
Apr 05 2016 05:18
@rithvikvibhu I'm sorry, what I meant to ask was why the animation was not working?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:19
@Camoen Check Open Weather Map for the temp. If its the same, its working
Camoen
@Camoen
Apr 05 2016 05:20
it's 15C instead of 27
27 was accurate when I first got it running this afternoon
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:21
@apugoneappu Your code seems to be working here: https://jsfiddle.net/t2oxjr1y/
@Camoen Try reloading with clear cache (Ctrl + F5)
Camoen
@Camoen
Apr 05 2016 05:22
@rithvikvibhu Same problem for some reason
Apoorve
@apugoneappu
Apr 05 2016 05:25
@rithvikvibhu But when I save the same code in Sublime Text as shake.html and open it in Chrome, it isn't working?!
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:25
@Camoen Is the js geolocation working? I get location as Earth (lol)
@apugoneappu press F12 to open up Dev Console and see if there are any errors
Camoen
@Camoen
Apr 05 2016 05:26
@rithvikvibhu It should be, it loads the co-ordinates for me, I just have to let my browser give location
Jose
@sauronsocuro
Apr 05 2016 05:26
Hi everybody, its first time i ask for help, so if i have to do something first (apart from search the web...) please tell me
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:26
@Camoen i meant that it wasnt asking for mine. Is the location accurate for you?
Apoorve
@apugoneappu
Apr 05 2016 05:27
@rithvikvibhu Yes, these are the errors that are showing:
Camoen
@Camoen
Apr 05 2016 05:28
@rithvikvibhu It says "Earth" before it loads my co-ordinates, but even earlier when it seemed to be working it said "Earth" in the data that the json returned
Saturnino Abril
@saturninoabril
Apr 05 2016 05:28
@Camoen I'm here in Korea and it's not showing correct location, it onle stated "Earth"
*only
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:29
@Camoen That means that the browser mostly isnt giving the lat and lng
something with the navigation. code
Camoen
@Camoen
Apr 05 2016 05:29
It's strange because it shows the latitude and longitude and was working earlier, I'm not sure what changed
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:29
@apugoneappu What are the errors?
Apoorve
@apugoneappu
Apr 05 2016 05:29
@rithvikvibhu These are the errors:
Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///C:/Users/Apoorve/Desktop/animate.min.css Failed to load resource: net::ERR_FILE_NOT_FOUND
shake.html:8 Uncaught SyntaxError: missing ) after argument list
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:30
One prob at a time
where is animate.css located?
Apoorve
@apugoneappu
Apr 05 2016 05:31
On my desktop
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:31
is it named animate.css or animate.min.css?
Apoorve
@apugoneappu
Apr 05 2016 05:32
It was animate.css but I renamed it to animate.min.css, still the error shows up!
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:32
@apugoneappu replace animate.min.css in your code with https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css
Apoorve
@apugoneappu
Apr 05 2016 05:33
@rithvikvibhu Same prob with style.css
What's the link for that?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:34
@Camoen I replaced the latitude and longitude variables in the api with my coordinates and it works
@apugoneappu style.css is a file that you created containing css. If you didnt, remove the line 2 of your code
@sauronsocuro whats the problem?
Camoen
@Camoen
Apr 05 2016 05:36
@rithvikvibhu Alright, thanks, yeah I think the problem is that the lat and long aren't getting passed to the variables I set up. not entirely sure why.
CamperBot
@camperbot
Apr 05 2016 05:36
camoen sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:star: 280 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Coryphaeus
@cvdeby
Apr 05 2016 05:39
Why did I get empty string?
    this.getRandomQuote = function () {
      var $quote = "";
      $.getJSON("http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=", function(data) {
        $quote = data[0].content;
      });
      return $quote;
    };
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:39
@Camoen It looks like navigator.geolocation.getCurrentPosition() is not running at all
Apoorve
@apugoneappu
Apr 05 2016 05:40
@rithvikvibhu The last error is a syntax error. It means that I've missed something in my code, right?
thanks @rithvikvibhu
CamperBot
@camperbot
Apr 05 2016 05:40
apugoneappu sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:star: 281 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Camoen
@Camoen
Apr 05 2016 05:42
$(document).ready(function(){
  //Get location data
  var latitude = 0;
  var longitude = 0;

  //Geolocation
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function(position) {
      $("#location").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
      latitude = position.coords.latitude;
      longitude = position.coords.longitude;
      console.log(latitude);
      console.log(longitude);
    });
  }

  console.log(latitude);
When I console.log(latitude) from inside the function, it returns the correct value. The console.log(latitude) outside the function returns 0. Also worth noting that console.log(latitude) outside of the function shows up in the log first.
Apoorve
@apugoneappu
Apr 05 2016 05:43
@rithvikvibhu How do I rectify the syntax problem?
Emil Aasa
@emilaasa
Apr 05 2016 05:43
@Camoen Are you asking or explaining to someone? =)
Camoen
@Camoen
Apr 05 2016 05:44
@emilaasa Asking. :P Not sure why latitude doesn't update considering it's a global variable
Emil Aasa
@emilaasa
Apr 05 2016 05:44
Ah, because .ready runs when everything is loaded
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:45
@cvdeby The api you used is over http and is being blocked as codepen.io is over HTTPS
Camoen
@Camoen
Apr 05 2016 05:45
@emilaasa is it possible to get my if loop to run first?
Emil Aasa
@emilaasa
Apr 05 2016 05:45
Before what?
Camoen
@Camoen
Apr 05 2016 05:46
So that the console.log(latitude) outside of the function will show up with the correct value instead of 0
(I'm using it in more code later on)
Coryphaeus
@cvdeby
Apr 05 2016 05:46
@rithvikvibhu But I got data. And I can use this data. Why am I cannot put this data into global variable?
Emil Aasa
@emilaasa
Apr 05 2016 05:47
@Camoen You are defining the variables inside the function
Markus Kiili
@Masd925
Apr 05 2016 05:48
@cvdeby The callback function executes after that return $quote.
Emil Aasa
@emilaasa
Apr 05 2016 05:48
So they are accessible inside that function scope
Elbert Cortez
@trip16661
Apr 05 2016 05:49
i hate my life :D
Coryphaeus
@cvdeby
Apr 05 2016 05:49
@Masd925 Ou, interesting)
@Masd925 How could I return data from $.getJSON directly, I think about some tricks with .call() function, but didn't get it.
Camoen
@Camoen
Apr 05 2016 05:50
@emilaasa It looks like they are initialized outside the scope of the geolocation function, so shouldn't they be global?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:50
@cvdeby Found the error!
@cvdeby CORS is not enabled by the api provider
@cvdeby
XMLHttpRequest cannot load http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://fiddle.jshell.net' is therefore not allowed access.
@apugoneappu remove line 2 of your code
Emil Aasa
@emilaasa
Apr 05 2016 05:53
@Camoen I'm not that familiar with .ready() in jQuery, but I think that your console.log below it will be fired before it has run the code inside .ready()
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:54
@emilaasa .ready() is used for when the page is completely loaded
V Arun Kumar
@arunvkumr
Apr 05 2016 05:54
@Camoen navigator is an asynchronous. you will get value inside the navigator only.. you can call another function inside navigator using lat and long.
Elbert Cortez
@trip16661
Apr 05 2016 05:55
can anyone help me ? :D http://codepen.io/Trip1666/pen/wGrYgg
it was working yesterday now it's not D:
Camoen
@Camoen
Apr 05 2016 05:55
@arunkumrv So if I want to pull data from a weather API using latitude and longitude from the navigator, do I need to do it all within the navigator?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:56
@trip16661 whats the problem?
Elbert Cortez
@trip16661
Apr 05 2016 05:56
not loading the quotes
Saturnino Abril
@saturninoabril
Apr 05 2016 05:56
@Camoen I had the same problem before and instead of working with built-in navigator, I used an api like from "https://ip.nf/me.json"
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:56
@Camoen Thats what @arunkumrv says. It should work them
Markus Kiili
@Masd925
Apr 05 2016 05:56
@cvdeby Things that you wan't to happen after the successful ajax call, should be on the callback function. You can assign things on outer variables and run functions etc.
V Arun Kumar
@arunvkumr
Apr 05 2016 05:56
@Camoen yes.. that's how it works :grinning:
Camoen
@Camoen
Apr 05 2016 05:56
@arunkumrv thanks I'll give it a shot
CamperBot
@camperbot
Apr 05 2016 05:56
:star: 420 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
camoen sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
Camoen
@Camoen
Apr 05 2016 05:56
@saturninoabril ty I'll check that out too
V Arun Kumar
@arunvkumr
Apr 05 2016 05:57
or you can use a callback function inside navigator to call other function with args lat and long. @Camoen
Mohammedaadem As
@mohamma548
Apr 05 2016 05:58
hello guys I need help with this code
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:58
@trip16661 You have a CORS problem. Basically, the request made to apidomain.com is different from the requesting domain (codepen.com)
Mohammedaadem As
@mohamma548
Apr 05 2016 05:58

function destroyer(arr) {
// Remove all the values
var arr1=[];
for(var i=0; i<arr[0].length;i++){
for(var j=0;j<arr.length;j++){
if(arr[0][i]==arr[j++]){
delete arr[j++];
}
arr1.push(arr[0][i]);

}
}

return arr1;
}

Coryphaeus
@cvdeby
Apr 05 2016 05:58
@Masd925 @rithvikvibhu Thanks for help) https://en.wikipedia.org/wiki/Cross-origin_resource_sharing
CamperBot
@camperbot
Apr 05 2016 05:58
cvdeby sends brownie points to @masd925 and @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:star: 1303 | @masd925 | http://www.freecodecamp.com/masd925
:star: 282 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 05:59
@cvdeby @trip16661 both have the same issue :)
Camoen
@Camoen
Apr 05 2016 05:59
@arunkumrv well I just pasted all my code into the navigator and it immediately came up with my county, the temp outside, and "clear sky"
so I think that must've done it
Elbert Cortez
@trip16661
Apr 05 2016 05:59
@rithvikvibhu hhow can i fix it? D:
V Arun Kumar
@arunvkumr
Apr 05 2016 05:59
@Camoen that's how it works :grinning:
Camoen
@Camoen
Apr 05 2016 06:00
@arunkumrv would a callback function allow me to get the same results without keeping the rest of my code inside the navigator? Not that it's a problem, now that it works
Mohammedaadem As
@mohamma548
Apr 05 2016 06:00
hi guys I nn

hi guys i need help with this seek and destroy here is my code????function destroyer(arr) {
// Remove all the values
var arr1=[];
for(var i=0; i<arr[0].length;i++){
for(var j=0;j<arr.length;j++){
if(arr[0][i]==arr[j++]){
delete arr[j++];
}
arr1.push(arr[0][i]);

}
}

return arr1;
}

V Arun Kumar
@arunvkumr
Apr 05 2016 06:01
@Camoen if you are calling it inside the navigator yes it would.
Camoen
@Camoen
Apr 05 2016 06:01
@arunkumrv Ok, thanks. I'll have to look into that more
CamperBot
@camperbot
Apr 05 2016 06:01
camoen sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: camoen already gave arunkumrv points
V Arun Kumar
@arunvkumr
Apr 05 2016 06:02
:smile: :+1:
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 06:02
@trip16661 something wrong with crossorigin.me
@trip16661 You may have to use another api or use another service like crossorigin.me to bypass CORS
Mohammedaadem As
@mohamma548
Apr 05 2016 06:04
any one who has an idea???
V Arun Kumar
@arunvkumr
Apr 05 2016 06:05
@trip16661 put all your js variables inside ready function.
kirbyedy
@kirbyedy
Apr 05 2016 06:05
I have ideas
Camoen
@Camoen
Apr 05 2016 06:05
in real browser, gitter has problems
Alexander
@tarnaykin
Apr 05 2016 06:06
Hello everyone, I'm stuck on challenge#230, can't figure out how to make it return an array, can someone help?
function lookUp(firstName, prop) {
  var returnValue;
  for(var i=0; i<contacts.length; i++) {
   if(contacts[i].firstName==firstName && contacts[i].hasOwnProperty(prop))
    returnValue=contacts[i][prop];

   if(contacts[i].firstName!=firstName)
      returnValue="No such contact";

   if(!(contacts[i].hasOwnProperty(prop)))
      returnValue="No such property";
}
  return returnValue;
}
lookUp("Harry","likes");
kirbyedy
@kirbyedy
Apr 05 2016 06:08
@Camoen works here :thumbsup:
Camoen
@Camoen
Apr 05 2016 06:08
@kirbyedy good stuff, thanks
CamperBot
@camperbot
Apr 05 2016 06:08
camoen sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 802 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Apr 05 2016 06:08
dont forget about the weather icon
Camoen
@Camoen
Apr 05 2016 06:08
Yeah, I'll do that stuff tomorrow
that's the easy part :D
V Arun Kumar
@arunvkumr
Apr 05 2016 06:08
@Camoen working here as well :grinning: :+1:
Camoen
@Camoen
Apr 05 2016 06:09
hooray
V Arun Kumar
@arunvkumr
Apr 05 2016 06:12
@Camoen Small suggestion. try to make the temp clickable i know that it should get me value in °C and °F on click and it works. but most of the people would only think that it is showing only in °F. make it more interactive so that people would know that it is clickable.
Markus Kiili
@Masd925
Apr 05 2016 06:14
@tarnaykin Nothing wrong with the return value contacts[i][prop];. Other logic is the problem.
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 06:17
@tarnaykin you need to break; after successful returnValue assignment
like after returnValue = contacts[i][prop];
Markus Kiili
@Masd925
Apr 05 2016 06:25
@tarnaykin Easiest is if you make two nested if clauses. First for the firstname check and second for the property existence. Then just put the returns on correct spots.
Alexander
@tarnaykin
Apr 05 2016 06:27
@rithvikvibhu @Masd925 thanks!
CamperBot
@camperbot
Apr 05 2016 06:27
tarnaykin sends brownie points to @rithvikvibhu and @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1304 | @masd925 | http://www.freecodecamp.com/masd925
:star: 283 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
keenjus
@keenjus
Apr 05 2016 06:36
can i get banned?
Justin
@daemedeor
Apr 05 2016 06:37
@keenjus can you, yes
Olawale Akinseye
@brainyfarm
Apr 05 2016 06:38
@keenjus yes
explain conduct
CamperBot
@camperbot
Apr 05 2016 06:38

:point_right: code of conduct [wiki]

Free Code Camp is friendly place to learn to code. We're committed to keeping it that way.

All campers are required to agree with the following code of conduct. We'll enforce this code. We're expecting cooperation from all campers in ensuring a friendly environment for everybody.

In short: be nice to your fellow campers.

Remember these 3 things and your fellow campers will like you:

  • Compliment your fellow campers when they do good work. Congratulate them when they accomplish something (like completing one of our certifications or getting a job).
  • Critique the work, not the camper doing it.
  • Only argue about something if it's important to the greater discussion.

Free Code Camp should be a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, national origin, or religion (or lack thereof).

We do not tolerate harassment of campers in any form, anywhere on Free Code Camp's online media (Gitter, Twitch, Facebook, etc.) or during pair programming. Harassment includes sexual language and imagery, deliberate intimidation, stalking, unwelcome sexual attention, libel, and any malicious hacking or social engineering.

If a camper engages in harassing behavior, our team will take any action we deem appropriate, up to and including banning them from Free Code Camp.

No bots are allowed in any of the Official Chat Rooms without prior explicit permission from the FCC Core Team.

We want everyone to feel safe and respected. If you are being harassed or notice that someone else is being harassed, say something! Message @quincylarson, @berkeleytrue, @brianamarie and @codenonprofit in Gitter (preferably with a screen shot of the offending language) so we can take fast action.
:pencil: read more about code of conduct on the FCC Wiki

Olawale Akinseye
@brainyfarm
Apr 05 2016 06:38
@keenjus :point_up:
Jose
@sauronsocuro
Apr 05 2016 06:38
@rithvikvibhu thx for ur interest before, i finally ask a friend that could help me. THANKS A LOT!.
CamperBot
@camperbot
Apr 05 2016 06:38
sauronsocuro sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:star: 284 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 06:40
@sauronsocuro :) u can come here whenever you want
Jose
@sauronsocuro
Apr 05 2016 06:40
i dont know how to send the brownie points
V Arun Kumar
@arunvkumr
Apr 05 2016 06:41
wiki brownie
CamperBot
@camperbot
Apr 05 2016 06:41
no wiki entry for: brownies
V Arun Kumar
@arunvkumr
Apr 05 2016 06:41
wiki brownie
CamperBot
@camperbot
Apr 05 2016 06:41

:point_right: brownie points [wiki]

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are three ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Post relevant links on Camper News - you get 1 point for posting a link, and another point for each upvote your link gets
  3. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.
:pencil: read more about brownie points on the FCC Wiki

V Arun Kumar
@arunvkumr
Apr 05 2016 06:41
@sauronsocuro third point. :grinning:
Jose
@sauronsocuro
Apr 05 2016 06:41
thanks @rithvikvibhu
CamperBot
@camperbot
Apr 05 2016 06:41
sauronsocuro sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:warning: sauronsocuro already gave rithvikvibhu points
V Arun Kumar
@arunvkumr
Apr 05 2016 06:41
This message was deleted
Jose
@sauronsocuro
Apr 05 2016 06:41
ahh, i already did it
cool
thanks to all
ill be back tomorrow, see ya!!
Emil Aasa
@emilaasa
Apr 05 2016 06:42
thanks @Masd925 you are crushing the help channel again! :D
CamperBot
@camperbot
Apr 05 2016 06:42
emilaasa sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1305 | @masd925 | http://www.freecodecamp.com/masd925
Mohammedaadem As
@mohamma548
Apr 05 2016 06:49
whats wrong with my code?

function destroyer(arr) {
// Remove all the values
var arr1=[];
for(var i=0; i<arr[0].length;i++){
for(var j=0;j<arr.length;j++){
if(arr[0][i]==arr[j++]){
delete arr[j++];
}
arr1.push(arr[0][i]);

}
}

return arr1;
}

Markus Kiili
@Masd925
Apr 05 2016 06:50
@mohamma548 The parameter arr only catches the first passed argument (the array).
Mohammedaadem As
@mohamma548
Apr 05 2016 06:51
@Masd925 I am trying to check arr[0] againest the rest of arrays?
Robert Uivarosi
@URobert
Apr 05 2016 06:52
@mohamma548 can you link the whole code?
also
explain format
CamperBot
@camperbot
Apr 05 2016 06:52

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Mohammedaadem As
@mohamma548
Apr 05 2016 06:53

@URobert function destroyer(arr) {
// Remove all the values
var arr1=[];
for(var i=0; i<arr[0].length;i++){
for(var j=0;j<arr.length;j++){
if(arr[0][i]==arr[j++]){
delete arr[j++];
}
arr1.push(arr[0][i]);

}
}

return arr1;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);

Markus Kiili
@Masd925
Apr 05 2016 06:55
@mohamma548 The arr is just [1, 2, 3, 1, 2, 3].
@mohamma548 You need to use arguments object for those extra arguments.
lockee14
@lockee14
Apr 05 2016 06:56
[1,2,3,1,2,3] > array
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 06:56
@mohamma548 please format your code by adding ``` at the beginning and end of code
lockee14
@lockee14
Apr 05 2016 06:56
2 & 3 argument[0] & argument1
1
O_o
argument[1] argument [ --1---]
Danish Khan
@Dkhan2
Apr 05 2016 07:00

// Initialize these three variables
var a = 5;
var b = 10;
var c = "I am a ";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

What is missing?
Robert Uivarosi
@URobert
Apr 05 2016 07:00
for(var i=0; i<arr[0].length;i++){ this loop is no good for a start, as it was mentioned above arr is just [1,2,3,1,2,3] and has nothing to do with the rest of the arguments. with arr[0] you are targeting the value 1
Jalay
@JalaySimaria
Apr 05 2016 07:01
@Dkhan2 what is the error you're getting?
Robert Uivarosi
@URobert
Apr 05 2016 07:01
@Dkhan2 link the exercise, code seems fine...maybe the space is not needed after "I am a"?
Ken Truong
@kjjtruong
Apr 05 2016 07:02
hey everyone! I just completed the Find the Longest Word in a String bonfire challenge. I know there can be many ways to solve a problem. So I was just wondering if anyone could review my code and let me know what I could've done differently or how to improve. Challenge was to return the length of the longest word in a provided sentence.
function findLongestWord(str) {

  //split string into array

  var newArray = str.split(' ');

  //test array for longest property
  var longestStrLength = 0;

  for (var i = 1; i < newArray.length; i++) {

    if (newArray[i].length > longestStrLength) {
      longestStrLength = newArray[i].length;
    } 

  }

  return longestStrLength;
}

findLongestWord("May the force be with you");
Danish Khan
@Dkhan2
Apr 05 2016 07:05
@URobert Yeah i realized that , ty
Jalay
@JalaySimaria
Apr 05 2016 07:06
@kjjtruong is it working? I think your for loop will skip the first word
for (var i = 1; i < newArray.length; i++) {  // it should be var i=0
Robert Uivarosi
@URobert
Apr 05 2016 07:07
@Dkhan2 yw
V Arun Kumar
@arunvkumr
Apr 05 2016 07:09
@kjjtruong there is a bug in your code. if the first word is the longest word it would never get the length of first word. this is happening because of you i loop.
Ken Truong
@kjjtruong
Apr 05 2016 07:10
@JalaySimaria oh right sorry. I forgot to change that back to 0.
I had it at 1 earlier cause I was trying a different solution and forgot to change it back. Luckily i passed the challenge cause none of the first words in any of the provided sentences were the longest.
Coryphaeus
@cvdeby
Apr 05 2016 07:14
@Masd925 Does ajax method more preferable than getJSON? Can I use it synchronously?
Olawale Akinseye
@brainyfarm
Apr 05 2016 07:14
Nice suit @URobert :+1:
Robert Uivarosi
@URobert
Apr 05 2016 07:15
@brainyfarm thx :+1:
CamperBot
@camperbot
Apr 05 2016 07:15
urobert sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1768 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
usharya
@usharya
Apr 05 2016 07:15
what is wrong with my code?
var someAdjective = "fun";
var myStr+="Learning to code is " + someAdjective;
Markus Kiili
@Masd925
Apr 05 2016 07:16
@cvdeby getJSON is just a shortcut notation for JSON datatype ajax call. I believe it is possible to do synchronous but not a good idea for some reason.
usharya
@usharya
Apr 05 2016 07:16
It is showing me an error that I cannot use += together :(
Robert Uivarosi
@URobert
Apr 05 2016 07:16
@usharya why would you want to use it there ?
Coryphaeus
@cvdeby
Apr 05 2016 07:16
@kjjtruong Nice solution. You can get the same effect with Math.max() and reduce() methods.
Jalay
@JalaySimaria
Apr 05 2016 07:17
@usharya you cannot add multiple strings with +=, only one string after +=
usharya
@usharya
Apr 05 2016 07:17
I am doing lesson: Appending Variables to Strings
and it says I should use += operator
Robert Uivarosi
@URobert
Apr 05 2016 07:17
var myStr = "Learning to code is " + someAdjective; should do it
@usharya in that case you have to do it differently
usharya
@usharya
Apr 05 2016 07:17
how?
Jalay
@JalaySimaria
Apr 05 2016 07:18
@usharya this will work:
var someAdjective = "fun";
var myStr += "Learning to code is ";
var myStr += "someAdjective";
usharya
@usharya
Apr 05 2016 07:18
@JalaySimaria Thank you :D
CamperBot
@camperbot
Apr 05 2016 07:18
usharya sends brownie points to @jalaysimaria :sparkles: :thumbsup: :sparkles:
César
@ICesarI
Apr 05 2016 07:18
@usharya, because myStr didn't exist before. You are just creating the variable. Only use =
CamperBot
@camperbot
Apr 05 2016 07:18
:star: 182 | @jalaysimaria | http://www.freecodecamp.com/jalaysimaria
usharya
@usharya
Apr 05 2016 07:19
César
@ICesarI
Apr 05 2016 07:20
@usharya read :point_up: April 5, 2016 2:18 AM
Jalay
@JalaySimaria
Apr 05 2016 07:20
@usharya it's wrong:
first declare variable with var
then never use var to append string in it
V Arun Kumar
@arunvkumr
Apr 05 2016 07:20
@usharya
first assign "Learning to code is " to myStr and then use myStr += someAdjective;
César
@ICesarI
Apr 05 2016 07:22
-.-
V Arun Kumar
@arunvkumr
Apr 05 2016 07:22
@usharya you can't declare same variable again. and you don't have to declare it. declare once with string "Learning to code is " and then use +=.
Robert Uivarosi
@URobert
Apr 05 2016 07:22
@usharya just do it as in the example. Use declaration only twice, for myStr and someAdjective. On the last line you combine them with myStr += someAdjective;
Jalay
@JalaySimaria
Apr 05 2016 07:23
@usharya it should be something like this:
var myStr = "your string";
myStr += "append string"; // don't use var here
usharya
@usharya
Apr 05 2016 07:24
@JalaySimaria Thank you so much, I was not understanding, you comment made me understand :D
Thank you to you guys also @URobert @arunkumrv @ICesarI Thank you :D hehe
CamperBot
@camperbot
Apr 05 2016 07:24
usharya sends brownie points to @jalaysimaria and @urobert and @arunkumrv and @icesari :sparkles: :thumbsup: :sparkles:
:warning: usharya already gave jalaysimaria points
:star: 360 | @icesari | http://www.freecodecamp.com/icesari
:star: 762 | @urobert | http://www.freecodecamp.com/urobert
:star: 421 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Robert Uivarosi
@URobert
Apr 05 2016 07:25
@usharya yw, happy coding
Ken Truong
@kjjtruong
Apr 05 2016 07:26
@cvdeby thanks! i can see how I could've solved it with Math.max(). Not sure about reduce() though. But I'll look into it. Thanks for the suggestion!
CamperBot
@camperbot
Apr 05 2016 07:26
kjjtruong sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 293 | @cvdeby | http://www.freecodecamp.com/cvdeby
Coryphaeus
@cvdeby
Apr 05 2016 07:29
@kjjtruong Something like this
arr.reduce(function(previousValue, currentValue) {
  return Math.max(previousValue, currentValue.length);
}, arr[0].length);
ank999
@ank999
Apr 05 2016 07:30
need help with challenge name"ntroducing JavaScript Object Notation JSON";
Coryphaeus
@cvdeby
Apr 05 2016 07:32
@kjjtruong reduce() function is helpful when you need to grab one value from all array elements.
Ken Truong
@kjjtruong
Apr 05 2016 07:43
ohhhhhhh i get it now
thanks!
@cvdeby
Danilo
@sennator
Apr 05 2016 07:52
```
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var i = 0; i<multiplyAll.length ; i++){
    for(var j = 0; j<multiplyAll[i].length; j++){
    product = (arr[i][j] * product);
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Chris Cullen
@123xylem
Apr 05 2016 07:53
Danilo
@sennator
Apr 05 2016 07:53
can someone help?
Jovan Curayag
@curayagjovan
Apr 05 2016 07:54
This message was deleted
This message was deleted
Coryphaeus
@cvdeby
Apr 05 2016 07:55
@sennator What should you get in result?
Jovan Curayag
@curayagjovan
Apr 05 2016 07:56
This message was deleted
I'm stuck here. pls help.
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Danilo
@sennator
Apr 05 2016 07:57
Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Coryphaeus
@cvdeby
Apr 05 2016 07:57
@sennator I think multiplyAll should be replaced with arr, because arr is an argument and multiplyAll is a function name.
Danilo
@sennator
Apr 05 2016 07:58
@123xylem
var myStr="\\ \t \t \r \n";
@cvdeby yeah...thanks brother
CamperBot
@camperbot
Apr 05 2016 07:59
sennator sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 294 | @cvdeby | http://www.freecodecamp.com/cvdeby
Coryphaeus
@cvdeby
Apr 05 2016 08:01
@curayagjovan I don't see your code here.) What should you get?
Vukashin Pavlovic
@vukashinp
Apr 05 2016 08:05

function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);

i am stuck here, need to convert to fahrenheit
how to do that?
anyone? :D
Albin Karlsson
@AlbinKarlsson99
Apr 05 2016 08:07
a should be assigned to b with = HOW DO I DO THAT??
kirbyedy
@kirbyedy
Apr 05 2016 08:11
@vukashinp you ahve to find the formula for the converting celsius to fahrenheit... check on google
@AlbinKarlsson99 equal sign this one: = means assigning
Chris Cullen
@123xylem
Apr 05 2016 08:16
@sennator thankyou man... it said I had to escape the backslashes which mustve caused the confusion for me
Coy Sanders
@coymeetsworld
Apr 05 2016 08:25
@vukashinp T(°F) = T(°C) × 9/5 + 32
Saturnino Abril
@saturninoabril
Apr 05 2016 08:47
hi everyone! please see my wikipedia viewer. I'll appreciate your feedback here. Thanks! http://codepen.io/saturnino/pen/jqawbp
Hsin Chih Wang
@hsinwang5
Apr 05 2016 08:52
@123xylem You should post the code you wrote
well its just line so just write it heh
*one
@saturninoabril works fine for me
Doandes Razvan
@Fuzyon
Apr 05 2016 08:57
Hey guys, I'm having an error with the Smallest Common Multiple algorithm
function smallestCommons(arr) {
  arr.sort(function(a,b){
    return a-b;
  }); // sort arr ascending.

  var allNums = [];
  var firstScm = arr[1];
  var scmFound = "";

  for (i = arr[0]; i <= arr[1]; i++) {
    allNums.push(i);
  } // get all nums between the 2 indexes.

  function checker() {
    allNums.forEach(function(int) {
      if (firstScm % int === 0) {
        scmFound += "true";
      } else {
        scmFound += "false";
      }
    }); 

    if (scmFound.indexOf("false") >= 0) {
      firstScm++;
      scmFound = "";
      checker();
    } else {
      return;
    }
  }

  checker();
  return firstScm;

}

smallestCommons([13,1]);
So this is my code. It gives me the max call stack size exceeded, but it works for all the numbers up to 13. Maybe it's too much for FCC to handle? Here's the challenge page: https://www.freecodecamp.com/challenges/smallest-common-multiple
Saturnino Abril
@saturninoabril
Apr 05 2016 09:00
@hsinwang5 Thanks for checking!
CamperBot
@camperbot
Apr 05 2016 09:00
saturninoabril sends brownie points to @hsinwang5 :sparkles: :thumbsup: :sparkles:
:star: 198 | @hsinwang5 | http://www.freecodecamp.com/hsinwang5
faraz
@silentarrowz
Apr 05 2016 09:06
is anyone into algorithms here?? I am learning data structures and algorithms and thus writing code for quicksort. It's just that when I am recursively calling the quicksort function, it gets into an infinite loop. could you tell me what's wrong?? here's the link - http://codepen.io/silentarrowz/pen/PNJRJe
kwal0203
@kwal0203
Apr 05 2016 09:14
Hey guys, any tips on how I can toggle back and forth between Fahreinheit and degrees celsius for the weather app?
Hsin Chih Wang
@hsinwang5
Apr 05 2016 09:14
@Fuzyon I'm just guessing here, you're probably putting too many function calls to checker() on the stack, might work if you used an iterative solution?
@Fuzyon I refactored you code into an iterative solution

```function smallestCommons(arr) {
arr.sort(function(a,b){
return a-b;
}); // sort arr ascending.

var allNums = [];
var firstScm = arr1;
var scmFound = "false";

for (i = arr[0]; i <= arr1; i++) {
allNums.push(i);
} // get all nums between the 2 indexes.

while (scmFound.indexOf("false") >= 0) {
firstScm++;
scmFound = "";

allNums.forEach(function(int) {
if (firstScm % int === 0) {
scmFound += "true";
} else {
scmFound += "false";
}
});

}

return firstScm;

}

smallestCommons([13,1]);```

Doandes Razvan
@Fuzyon
Apr 05 2016 09:18
@hsinwang5 let's see what you got! :D
Hsin Chih Wang
@hsinwang5
Apr 05 2016 09:19
whoops
that works in the console so should work for FCC
function smallestCommons(arr) {
  arr.sort(function(a,b){
    return a-b;
  }); // sort arr ascending.

  var allNums = [];
  var firstScm = arr[1];
  var scmFound = "false";

  for (i = arr[0]; i <= arr[1]; i++) {
    allNums.push(i);
  } // get all nums between the 2 indexes.

while (scmFound.indexOf("false") >= 0) {
     firstScm++;
      scmFound = "";

allNums.forEach(function(int) {
      if (firstScm % int === 0) {
        scmFound += "true";
      } else {
        scmFound += "false";
      }
    }); 

    }
  return firstScm;

}

smallestCommons([13,1]);
Doandes Razvan
@Fuzyon
Apr 05 2016 09:22
@hsinwang5 thank you so much! It sucks that I can't use recursivity since I was quite proud of my solution :(
CamperBot
@camperbot
Apr 05 2016 09:22
fuzyon sends brownie points to @hsinwang5 :sparkles: :thumbsup: :sparkles:
:star: 199 | @hsinwang5 | http://www.freecodecamp.com/hsinwang5
Hsin Chih Wang
@hsinwang5
Apr 05 2016 09:23
@Fuzyon np :). IIRC function calls are inefficient in javascript so recursive solutions are usually slower
Markus Kiili
@Masd925
Apr 05 2016 09:24
@hsinwang5 Function calls are not inefficient, but JS handles recursion poorly.
davees
@davees
Apr 05 2016 09:24
function titleCase(str) {


  lc = str.toLowerCase();

  array = lc.split(" ");

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

   array[i][0].toUpperCase();

  }


  return array.join(" ");


}
any input guys?
Hsin Chih Wang
@hsinwang5
Apr 05 2016 09:27
@Masd925 Alright I stand corrected then
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 09:27
data.query.pages[0].extract doesnt work whereas data.query.pages["288379"].extract works
Markus Kiili
@Masd925
Apr 05 2016 09:35
@rithvikvibhu It is nested objects, so [0] makes no sense there (no key "0").
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 09:36
@Masd925 so how do i get it?
if there are more pages, i'll have to loop through each
Markus Kiili
@Masd925
Apr 05 2016 09:39
@rithvikvibhu You said data.query.pages["288379"].extract works. JSON doesn't have same key twice, so how are the pages there?
@rithvikvibhu With different id's like "288379"?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 09:40

@Masd925 check this: https://en.wikipedia.org/w/api.php?action=query&titles=lol&prop=extracts&section=0&redirects=1&format=jsonfm&callback=?

there could be many pages like pages["284749"] and pages["435474"]

I'm guessing there could be

huh. I guess not. There's always 1 under pages
but how do i get to it?
Markus Kiili
@Masd925
Apr 05 2016 09:44
@rithvikvibhu Do you mean, how to get the string when you don't know the id?
Blauelf
@Blauelf
Apr 05 2016 09:45
Maybe something like data.query.pages[Object.keys(data.query.pages)[0]].extract? Or loop:
for (id in data.query.pages) {
  console.log(data.query.pages[id].extract);
}
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 09:46
Oh @Blauelf thats perfect. I needed a loop anyways.
Thanks @Masd925 @Blauelf
CamperBot
@camperbot
Apr 05 2016 09:46
rithvikvibhu sends brownie points to @masd925 and @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1519 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 1306 | @masd925 | http://www.freecodecamp.com/masd925
Christian
@christianbrill
Apr 05 2016 09:47

guys, I need some help. I've been working on chapter 209 and I can't figure out what's wrong.

var count = 0;

function cc(card) {
  // Only change code below this line
   if (card >= 2 && card <= 6) {
     return "5 Bet";
  } else if (card >= 7 && card <= 9) {
    return "0 Hold";
  } else if ([3, 7, 'Q', 8, 'A'] && [3, 2, 'A', 10, 'K']) {
    return "-1 Hold";
  } else if ([10, 'J', 'Q', 'K', 'A']) {
    return "-5 Hold";
  } else if ([2, 'J', 9, 2, 7]) {
    return "1 Bet";
  }
  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(10); cc('J'); cc('Q'); cc('K'); cc('A');

Four out of seven conditions are fulfilled with this but I can't seem to get the other three to work.

Here's what I'm supposed to do:

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then 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.

The following are the conditions that should be met. The numbers in front of the items indicate that those have been met by my function:

  1. Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
  2. Cards Sequence 7, 8, 9 should return "0 Hold"
    Cards Sequence 10, J, Q, K, A should return "-5 Hold"
  3. Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
    Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"

I don't know how to continue from here. A little help would be greatly appreciated. Thanks in advance! :)
Cards Sequence 2, 2, 10 should return "1 Bet"

  1. Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
Brendan Kinahan
@BKinahan
Apr 05 2016 09:48
@Alnilam90 count changes between calls to the function, as new cards are dealt. you should decide how to bet based on the current value of count.
that ought to get you started in the right direction.
Blauelf
@Blauelf
Apr 05 2016 09:49
@Alnilam90 The problem consists of two parts: Depending on the value of card (you get one at a time), change (or not change) count. Then, depending on the then current value of count, return count and either "Bet" or "Hold".
You seem to try hard-coding test cases, which is not a good idea.
Christian
@christianbrill
Apr 05 2016 09:52
@Blauelf can I do that with a switch statement? I'm seriously confused here.
Blauelf
@Blauelf
Apr 05 2016 09:53
Switch or if-elseif both work fine here.
The second part should be a simple if-else or conditional operator ;)
Christian
@christianbrill
Apr 05 2016 09:58
@Blauelf could you maybe give me an example for like the first line to start me off? I've been trying things but all I get is question marks in my head.
Blauelf
@Blauelf
Apr 05 2016 09:59
Something like
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:  count++;
             break;
    case 10:
    case "J":
    ...
Christian
@christianbrill
Apr 05 2016 10:00
ohhh okay, thanks @Blauelf
CamperBot
@camperbot
Apr 05 2016 10:00
alnilam90 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1520 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Apr 05 2016 10:01
As you don't have to do something to 7-9, you don't have to include them in any way.
Geo Galagaran
@geeofree
Apr 05 2016 10:19
is anyone familiar with callbacks/higher-order functions here?
Markus Kiili
@Masd925
Apr 05 2016 10:19
@da7thsin Yes.
Geo Galagaran
@geeofree
Apr 05 2016 10:22
@Masd925 how would you recreate the array.reduce method?
I have this. But I'm trying to think of what I should put for prev and cur. Any Ideas?
function reduce(array,callback){
 var answer;

  //loop through array
  for(var i = 0; i < array.length; i++){
   //(callback, with placeholder args)
   answer = callback(prev, cur);
  }
  //return answer
  return answer;
}

console.log(reduce([1, 2, 3, 4],function(a,b){
    console.log("A:", a, "B:", b);
      return a + b;
}));
Markus Kiili
@Masd925
Apr 05 2016 10:27
@da7thsin Reduce method automatically iterates through the array and returns a value from the process. There is a running value that is updated at each element iterated. The callback function that you pass into the reduce method tells how to go from previous running value to the next using the current element being iterated. The return value is the next running value. You can specify an initial running value for reduce. If you don't, reduce will use the first two elements. The syntax is arr.reduce(callback,initialValue);
Geo Galagaran
@geeofree
Apr 05 2016 10:29
@Masd925 no no. What I'm trying to do is to recreate the method :p I know how Reduce works. Just that I want to build it from scratch.
Markus Kiili
@Masd925
Apr 05 2016 10:29
@da7thsin ok. What were you trying to do?
Geo Galagaran
@geeofree
Apr 05 2016 10:30
@Masd925 posted it above. I'm trying to think off how I what values I'm going to put into the callback.
Markus Kiili
@Masd925
Apr 05 2016 10:31
@da7thsin You are not using array reduce method at all there.
Geo Galagaran
@geeofree
Apr 05 2016 10:32
@Masd925 I'm not. :P I'm trying to build it. haha
Markus Kiili
@Masd925
Apr 05 2016 10:33
@da7thsin The syntax is like this:
function callback (prev, curr, index, array) {
    return prev + curr;
}

[1,2,3,4].reduce(callback,0); // Adds array numbers. Returns 10
E YG
@laed37
Apr 05 2016 10:46
Question: if I use the 'for loop' on an array with multiple sub arrays (and sub-sub arrays), do I need to make a series of the 'for loops' ? ex: var i=0, then next is var j=0, and next is var k=0.. and so forth for every available level? I may want to access the information in the 'bottom most level'
Chris Cullen
@123xylem
Apr 05 2016 10:48
Can some1 give me a hint with this one?
Im not sure what they want me to do
Markus Kiili
@Masd925
Apr 05 2016 10:48
@laed37 If you know the depth of sub-arraying, you can do nested loops. You can also use array iterator methods. If you don't know the depth, you can write a function that does what you wan't. For example getting all elements from all sub arrays etc.
Mariusz Kopeć
@silvermario
Apr 05 2016 10:54
I'm developping the Weather App challenge and I have 2 functions to retrieve the wheather data, either from the API, or from the SessionStorage. The question is where should I put the application logic and what are the common used strategies?
Should I use the async: false for the $.ajax call or ".done" triggers with listeners?
Blauelf
@Blauelf
Apr 05 2016 10:56
@123xylem You can use something like result = "My "+myAdjective+" "+myNoun+" yesterday "+... (important is that you use all four variables, and the result has those words separated from other words, so "bigdog" would match neither "big" nor "dog")
Chris Cullen
@123xylem
Apr 05 2016 10:58
not result ="myNoun"+"myAdjective"?
  • must be inside quotes?
+
Stephane
@overmelo
Apr 05 2016 11:00
anybody here has done the javascript task counting cards?
Chris Cullen
@123xylem
Apr 05 2016 11:02
@Blauelf thanks didn know that was how u add var... FCC never told us that
CamperBot
@camperbot
Apr 05 2016 11:02
123xylem sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1521 | @blauelf | http://www.freecodecamp.com/blauelf
lockee14
@lockee14
Apr 05 2016 11:03
hi fellow camper, i have an issue to get the json api for the wikipedia challenge, a fellow camper give me this http://crossorigin.me/ and it work well (it parse the json object through an other serveur, but the serveur is actually down, so....
lockee14
@lockee14
Apr 05 2016 11:05
$(document).ready(function() {
  function apiCall() {
    var url = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=info&titles=Albert+Einstein";
    $.getJSON(url, function(json) {
      $("#test").html(JSON.stringify(json));
    });
  };
});
my code in case i'have done a mistake
cannelflow
@cannelflow
Apr 05 2016 11:07
@LilitYeranyan and a number ===> push remove the first element of array===>shift
Chris Cullen
@123xylem
Apr 05 2016 11:07
@Blauelf thanks point proven :)
CamperBot
@camperbot
Apr 05 2016 11:07
123xylem sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: 123xylem already gave blauelf points
lockee14
@lockee14
Apr 05 2016 11:08
; (
LilitYeranyan
@LilitYeranyan
Apr 05 2016 11:08
@cannelflow the only question is "how to return removed value?"
cannelflow
@cannelflow
Apr 05 2016 11:09
two things @LilitYeranyan 1.Add the number to the end of the array,
Blauelf
@Blauelf
Apr 05 2016 11:09
@lockee14 Maybe you could try JSONP instead of JSON?
cannelflow
@cannelflow
Apr 05 2016 11:09
2.hen remove the first element of array. The queue function should then return the element that was removed. @LilitYeranyan
lockee14
@lockee14
Apr 05 2016 11:09
JSONP ?
MichaelTsang
@MichaelTsang
Apr 05 2016 11:10
need help
E YG
@laed37
Apr 05 2016 11:10
Hi, I am having trouble resolving my code, only "No such contact" appears and the other loops do not work.. this is the Profile Lookup waypoint
function lookUp(firstName, prop){
// Only change code below this line
  for (var i=0; i < contacts.length; i++) {
        if (contacts.hasOwnProperty(firstName)===false) {
          return "No such contact";
        } else if (contacts.hasOwnProperty(prop)===false) {
          return "No such property";
        } else {
          return contacts[i][prop];
        }
  }
// Only change code above this line
}
Mariusz Kopeć
@silvermario
Apr 05 2016 11:11
@LilitYeranyan: look up what the function shift() returns
Blauelf
@Blauelf
Apr 05 2016 11:11
@lockee14 I think it's done automatically if you add a &callback=? to your URL.
Markus Kiili
@Masd925
Apr 05 2016 11:11
@laed37 Contacts is an array, so contacts.hasOwnProperty(firstName) is not correct. Think first how to access one contact.
cBooM
@cBooM
Apr 05 2016 11:12

hi guys ...
Can you give me any hint on this one :(


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

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);


Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

MichaelTsang
@MichaelTsang
Apr 05 2016 11:12
'''javascript
CamperBot
@camperbot
Apr 05 2016 11:12
:bulb: to format code use backticks! ``` more info
lockee14
@lockee14
Apr 05 2016 11:12
@Blauelf i'm google it thanks for the tips
CamperBot
@camperbot
Apr 05 2016 11:12
lockee14 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
cBooM
@cBooM
Apr 05 2016 11:12
I just don't get it :(
CamperBot
@camperbot
Apr 05 2016 11:12
:star: 1522 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Apr 05 2016 11:13
@cBooM Between those two lines, add an if statement, checking whether a<0 or b<0, and if so, return. return; is same as return undefined;
Mariusz Kopeć
@silvermario
Apr 05 2016 11:13

@Masd925 maybe you could help me with this one:

I'm developping the Weather App website and I have 2 functions to retrieve the wheather data, either from the API, or from the SessionStorage. The question is where should I put the application logic and what are the common used strategies?
Should I use the async: false for the $.ajax call or ".done" triggers with listeners?

MichaelTsang
@MichaelTsang
Apr 05 2016 11:13

'''js
function findLongestWord(str) {
var splitStr = str.split(" ");
var temp=0;
var temp2=0;
for(var i=0,j=1;i<splitStr.length;i++,j++){

    temp = splitStr[i].split('').length;
    temp2 = splitStr[j].split('').length;
    if(temp < temp2){
      temp = temp2;
    }
}

return temp;
}

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

CamperBot
@camperbot
Apr 05 2016 11:13
:bulb: to format code use backticks! ``` more info
lockee14
@lockee14
Apr 05 2016 11:13
@Blauelf yup it work well thank a lot
CamperBot
@camperbot
Apr 05 2016 11:13
lockee14 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: lockee14 already gave blauelf points
MichaelTsang
@MichaelTsang
Apr 05 2016 11:14
error TypeError: Cannot read property 'split' of undefined
anybody help?
temp is OK but temp2 crash , i don't know why
cBooM
@cBooM
Apr 05 2016 11:15

@Blauelf

I tried like this, but it doesn't work ..


// Setup
function abTest(a, b) {
// Only change code below this line
if (a<0 && b<0) {
return undefined;
}

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);

Blauelf
@Blauelf
Apr 05 2016 11:15
@MichaelTsang Your algorithm is wrong. And it crashes as you try to split splitStr[splitStr.length], which is undefined.
cannelflow
@cannelflow
Apr 05 2016 11:15
if(a is less then 0 or b is less then 0) @cBooM
cBooM
@cBooM
Apr 05 2016 11:16
oooo
Blauelf
@Blauelf
Apr 05 2016 11:16
@cBooM & is called "ampersand", not "ampersor" :P
cBooM
@cBooM
Apr 05 2016 11:16
damm it
:) it worked
thanks guys ... I still have a loooong road ahead
LilitYeranyan
@LilitYeranyan
Apr 05 2016 11:17
@silvermario thanks, got it!!
CamperBot
@camperbot
Apr 05 2016 11:17
lilityeranyan sends brownie points to @silvermario :sparkles: :thumbsup: :sparkles:
:star: 280 | @silvermario | http://www.freecodecamp.com/silvermario
MichaelTsang
@MichaelTsang
Apr 05 2016 11:17

@Blauelf but temp works..
'''javascript
for(var i=0,j=1;i<splitStr.length;i++,j++){

    temp = splitStr[i].split('').length;

}

'''

CamperBot
@camperbot
Apr 05 2016 11:17
:bulb: to format code use backticks! ``` more info
MichaelTsang
@MichaelTsang
Apr 05 2016 11:17
result is 3
Blauelf
@Blauelf
Apr 05 2016 11:20
@MichaelTsang Sure, but j is always i+1, so it will crash. And your comparison is wrong. Don't compare an element's length with the next (the .split('') does not help at all, as strings already have a length property), but an element's length with the so-far largest word length.
Coryphaeus
@cvdeby
Apr 05 2016 11:21
Could somebody help with animation http://codepen.io/Coryph/pen/GZONZg
Mariusz Kopeć
@silvermario
Apr 05 2016 11:21
@MichaelTsang First this "j" iterator has no sense.
Coryphaeus
@cvdeby
Apr 05 2016 11:21
Sometimes animation doesn't work.
MichaelTsang
@MichaelTsang
Apr 05 2016 11:21
@silvermario sure i know
really confuse
what's the right way
i wanna seperate sentence into words and compare the words' length
Mariusz Kopeć
@silvermario
Apr 05 2016 11:22
@MichaelTsang I solved this challende with the use of reduce() function and I would recommend you the same. I splitted the words into an array and then compared one to another.
MichaelTsang
@MichaelTsang
Apr 05 2016 11:24
@Blauelf thank u , i got it
CamperBot
@camperbot
Apr 05 2016 11:24
michaeltsang sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1523 | @blauelf | http://www.freecodecamp.com/blauelf
Mariusz Kopeć
@silvermario
Apr 05 2016 11:25
@MichaelTsang and it does the same what you wanted to do, but it's written in 3 lines of code
Blauelf
@Blauelf
Apr 05 2016 11:29
There is also the split/map/Math.max method :)
MichaelTsang
@MichaelTsang
Apr 05 2016 11:30
.. i seems that i choose the wrongest way .. i will try! @Blauelf @silvermario
Acmer77
@Acmer77
Apr 05 2016 11:30
ehh... what am I supposed to do in Word Blanks? the madlibs -style game...
Helicondeco
@Helicondeco
Apr 05 2016 11:30
```

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

// Only change code below this line
var gloveBoxContents = myStorage.inside["glove box"]; // Change this line

whats wrong?
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:31

@Helicondeco the ``` and the code should be in the same message.

Shift+Enter gives multiline message

Helicondeco
@Helicondeco
Apr 05 2016 11:32
// Setup
var myStorage = {
  "car": {
    "inside": {
      "glove box": "maps",
      "passenger seat": "crumbs"
     },
    "outside": {
      "trunk": "jack"
    }
  }
};

// Only change code below this line
var gloveBoxContents = myStorage.inside["glove box"]; // Change this line
thanks @rithvikvibhu
CamperBot
@camperbot
Apr 05 2016 11:32
helicondeco sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:star: 286 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Coryphaeus
@cvdeby
Apr 05 2016 11:33
Ou I got it, why animation doesn't work sometimes, It's because of http connection ping's delay))
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:34
@Helicondeco you missed car. myStorage.car.inside
Helicondeco
@Helicondeco
Apr 05 2016 11:34
oh...blind me
D
ty
Coryphaeus
@cvdeby
Apr 05 2016 11:36
Or maybe not...
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:38
Hello :) Is there anyone who can help me with the "Falsy Bouncer" challenge. I can't get rid of the null values..
Brendan Kinahan
@BKinahan
Apr 05 2016 11:39
@aguyfromdenmark are you using filter?
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:40
Yes @BKinahan, I will try to figure out how to post my code here...
Brendan Kinahan
@BKinahan
Apr 05 2016 11:40
@aguyfromdenmark
```js
your code here
```
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:40
```js

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

for ( var i = 0; i < arr.length; i++) {
if (arr[i] === null) {
arr[i] = "removeThis";
} else {
switch (arr[i]) {
case false:
case 0:
case "":
case undefined:
case NaN:
arr.splice(i,1,"removeThis");
break;
}
}
}

return arr.filter(function(i) {
return i != "removeThis";
});
} ```

Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:41
wiki code formatting
CamperBot
@camperbot
Apr 05 2016 11:41

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Brendan Kinahan
@BKinahan
Apr 05 2016 11:41
shift+enter after the first line to go to a new line without sending the message
Alex N.
@N0bl3
Apr 05 2016 11:41
@aguyfromdenmark you have all shortcuts on the m icon right hannd side of where you write :)
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:41
Yeah @N0bl3 , the shortcut doesnt really work for me? :)
Alex N.
@N0bl3
Apr 05 2016 11:41
@aguyfromdenmark you have to jump on next line after `
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:41
```js
om*.. 2 sec
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:42
u pressed enter. instead use shift+enter
Brendan Kinahan
@BKinahan
Apr 05 2016 11:42
also you can edit your previous message instead of sending a new one ;) @aguyfromdenmark
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:42
function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  for ( var i = 0; i < arr.length; i++) {
    if (arr[i] === null) {
      arr[i] = "removeThis";
    } else {
      switch (arr[i]) { 
      case false:
      case 0:
      case "":
      case undefined:
      case NaN:
          arr.splice(i,1,"removeThis");
          break;
      }
    }
  }

  return arr.filter(function(i) {
    return i != "removeThis";
  });
}
Brendan Kinahan
@BKinahan
Apr 05 2016 11:42
there ya go :D
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:42
Yeah :) So far, I get rid of everything, except the NULL values, I have also tried to include the NULLs in the switch statement...
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:43
add another case case null:
or case NULL:
dont remember which one
Blauelf
@Blauelf
Apr 05 2016 11:43
@aguyfromdenmark It's not null that creates problems, it's NaN, which is just falsely displayed as null. You cannot compare to NaN, nothing equals NaN, not even NaN itself. You can actually use that, as val==val for anything but NaN.
Alex N.
@N0bl3
Apr 05 2016 11:44
return i != "removeThis"; should be return i !== "removeThis";
use strict equality except taht specifically the behaviour you want
@rithvikvibhu it case (null)
Brendan Kinahan
@BKinahan
Apr 05 2016 11:44
@aguyfromdenmark NaN == NaN -> false :)
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:45
@aguyfromdenmark Instead of this long switch, try using Array.filter()
Alex N.
@N0bl3
Apr 05 2016 11:45
@aguyfromdenmark you can use filter to remove all fals-y values!
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:46
Yeah, okay @rithvikvibhu @N0bl3 . I will try to figure out how to use filter to do it then. It seems like the best solution :) Thanks :)
CamperBot
@camperbot
Apr 05 2016 11:46
aguyfromdenmark sends brownie points to @rithvikvibhu and @n0bl3 :sparkles: :thumbsup: :sparkles:
:star: 238 | @n0bl3 | http://www.freecodecamp.com/n0bl3
:star: 287 | @rithvikvibhu | http://www.freecodecamp.com/rithvikvibhu
Blauelf
@Blauelf
Apr 05 2016 11:46
Nice thing is that Array.filter copies the values that the callback function returns a truthy value for, and omits those with a falsy callback return value. So filter with the identity function (function(x){return x;}) works :D
Alex N.
@N0bl3
Apr 05 2016 11:47
@Blauelf however isnt NaN == true?
Blauelf
@Blauelf
Apr 05 2016 11:47
NaN equals nothing. It is a very special value (and even though it is "Not a Number", it is of type "number")
Brendan Kinahan
@BKinahan
Apr 05 2016 11:47
@N0bl3 NaN is falsy
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:47
or:
newArr = arr.filter(Boolean);
return newArr;
Brendan Kinahan
@BKinahan
Apr 05 2016 11:48
@N0bl3 along with null,undefined,"", and 0
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:50
@rithvikvibhu Your last solution worked, but can you tell me a bit about how/why? :)
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:54
@aguyfromdenmark arr.filter(function(val) )passes each value of the array to a function with val as argument. In this case the val is passed to Boolean which returns if that val is true or false. Thats the same as what a function would return in this case.
Andreas Kristensen
@aguyfromdenmark
Apr 05 2016 11:55
Okay, thanks @rithvikvibhu , I think it get it now :)
CamperBot
@camperbot
Apr 05 2016 11:55
aguyfromdenmark sends brownie points to @rithvikvibhu :sparkles: :thumbsup: :sparkles:
:warning: aguyfromdenmark already gave rithvikvibhu points
Rithvik Vibhu
@rithvikvibhu
Apr 05 2016 11:55
:)
Mariusz Kopeć
@silvermario
Apr 05 2016 11:57

@Blauelf maybe you can help me?

I'm developping the Weather App website and I have 2 functions to retrieve the wheather data, either from the API, or from the SessionStorage. The question is where should I put the application logic and what are the common used strategies?
Should I use the async: false for the $.ajax call or ".done" triggers with listeners?
I must either wait for the resposne of the $.ajax() call and then evaluate the remaining functions, or evaluate them right away after fetching the data from the SessionStorage variable. In my opinion it would be a bad code if I put the application logic in the $.ajax() "success" callback function.

This message was deleted
Alex N.
@N0bl3
Apr 05 2016 12:05
@silvermario dont use async as it will block your browser until it gets a response from the server
@silvermario why would it be a bad code in your opinion,
Mariusz Kopeć
@silvermario
Apr 05 2016 12:06
@N0bl3 you're right, i tried it but it's not a good solution
@N0bl3 because of the DRY principle
Alex N.
@N0bl3
Apr 05 2016 12:08
@silvermario you could define functions outside of the callback then call them in the callback
Mariusz Kopeć
@silvermario
Apr 05 2016 12:09
@N0bl3 I would have the same code ( or trigger the same functions ) in the success callback as outside when I'm using the SessionStorage
Alex N.
@N0bl3
Apr 05 2016 12:10
@silvermario yes you don't have to repeat the actual block of code so this is not really repeating i guess?
Mariusz Kopeć
@silvermario
Apr 05 2016 12:12
@N0bl3 yes, i Could do it in this way, but IMHO it will be still not so good. Imagine I would develop this app further and change or add functions. I would have to do this in the success callback and outside.
@N0bl3 the best way would be to have a function which retrieves the data from either the API response or the SessionStorage and then a main function block which deals with the data. I'm comming from the backend development world, so maybe it's not the best choice in frontend programming and I'm missing something
Mariusz Kopeć
@silvermario
Apr 05 2016 12:18
This message was deleted
@MichaelTsang here, a hint how your code could work properly:
var max = 0;
for(var i=1;i<splitStr.length;i++){

    prev = splitStr[i-1].length;
    cur = splitStr[i].length;
// compare the words to themselves and to the max variable
}
Click Next Quote.
JL GARZA
@Garza0783
Apr 05 2016 12:21
i need help with Finding a Remainder. maybe i havent done this stuff in so that now im stuck!!
Brendan Kinahan
@BKinahan
Apr 05 2016 12:22
What have you got so far @Garza0783 ?
JL GARZA
@Garza0783
Apr 05 2016 12:22
a whole bunch of nothing.. i cleared it and started over..
Instructions
Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.
Coryphaeus
@cvdeby
Apr 05 2016 12:23
@MichaelTsang I prepare to make this task with reduce() and Math.max() - very simple and fast solution.
Jan Nissi Harrison
@NissiHarrison
Apr 05 2016 12:24
'''
CamperBot
@camperbot
Apr 05 2016 12:24
:bulb: to format code use backticks! ``` more info
Ryan
@NotSoV
Apr 05 2016 12:24

I am currently finishing up my quote generator. I am trying to use Twitter API to POST my quote, however, I receive a cross origin error. Is it possible to ajax post from codepen?

XMLHttpRequest cannot load http://css-tricks.com/. Origin http://s.codepen.io is not allowed by Access-Control-Allow-Origin.

Brendan Kinahan
@BKinahan
Apr 05 2016 12:25
@Garza0783 It's very similar to the exercises before it, but with a different operator (% instead of * or /)
@Garza0783 review those exercises before it on the map and see if that helps :)
JL GARZA
@Garza0783
Apr 05 2016 12:25
got it. thank you!
Brendan Kinahan
@BKinahan
Apr 05 2016 12:27
@NotSoV If you simply want to prompt the user to send a tweet from their account, it's much simpler to use the tweet intent: https://dev.twitter.com/web/tweet-button/web-intent
@NotSoV I think POST might require the user to authenticate / authorize first
Kristoforus Rua
@kru
Apr 05 2016 12:29
var test  = 231;