These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Mar 2017
DavHobbs
@DavHobbs
Mar 05 2017 00:03

function mutation(arr) {
var test = arr[1].toLowerCase();
var target = arr[0].toLowerCase();
for (var i=0;i<test.length;i++) {
if (target.indexOf(test[i]) < 0)
return false;
}
return true;
}
mutation(["hello", "Hello"]);


what is the test[i] set to when this program runs? is it 0, and then increments to five?

Jor
@joreyesl
Mar 05 2017 00:06
@replymedia i starts at 0 and increments to 5. Then that means test[i] will iterate through H, e, l, l, o.
DavHobbs
@DavHobbs
Mar 05 2017 00:07
@joreyesl Thank you. I think I dont quite understand how test[i] works very well
CamperBot
@camperbot
Mar 05 2017 00:07
replymedia sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 562 | @joreyesl |http://www.freecodecamp.com/joreyesl
DavHobbs
@DavHobbs
Mar 05 2017 00:07
is there a way I can console.log it to see whats happening? I have the code here
Jor
@joreyesl
Mar 05 2017 00:10

yes you can see what test[i] is at each iteration.

function mutation(arr) {
 var test = arr[1].toLowerCase();
 var target = arr[0].toLowerCase();
 for (var i=0;i<test.length;i++) {
  console.log(test[i]);
  if (target.indexOf(test[i]) < 0)
  return false;
 }
 return true;
}
mutation(["hello", "Hello"]);

basically you are accessing the string like you would an array. i is being used as an index to get the character at that position. Then you are checking to see if that characters is in the string target.

DavHobbs
@DavHobbs
Mar 05 2017 00:13
@joreyesl thank you for this. I can see where I got stuck. What if test = ['String1', 'String2'] how would test[i] behave under this circumstance. I was seeing test[i] where i=0 set to the whole string of 'Hello' and not the individual letters. I am still not seeing 100% how it is moving through each letter
CamperBot
@camperbot
Mar 05 2017 00:13
replymedia sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: replymedia already gave joreyesl points
Moisés Man
@moigithub
Mar 05 2017 00:14
input always return string AFAIK @SkyCoder01
Cedric Thibault
@Ccthibault
Mar 05 2017 00:16
How do you assign a number to a variable inside a function (with the use of var)
(without*)
Moisés Man
@moigithub
Mar 05 2017 00:17
how u do USING var ??
then just remove var
Jor
@joreyesl
Mar 05 2017 00:17

@replymedia well then test isn't an individual string anymore, then it becomes an array and you are accessing elements.
Here i am accessing the character at index 0

var test = "Hello";
var  x = test[0];
console.log(x); // "H"

Here i am accessing the element at index 0

var test = ['String1', 'String2']
var  x = test[0];
console.log(x); // "String1"
DavHobbs
@DavHobbs
Mar 05 2017 00:18
Ah ok, I see the difference
Thank you @joreyesl
CamperBot
@camperbot
Mar 05 2017 00:18
replymedia sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:warning: replymedia already gave joreyesl points
Cedric Thibault
@Ccthibault
Mar 05 2017 00:18
@moigithub thank you for the anwser
CamperBot
@camperbot
Mar 05 2017 00:18
ccthibault sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2788 | @moigithub |http://www.freecodecamp.com/moigithub
Gulsvi
@gulsvi
Mar 05 2017 00:20
@moigithub Thanks. I couldn't get typeOf to work as a string either. This worked though: /^\d+$/.test(element.value))
CamperBot
@camperbot
Mar 05 2017 00:20
skycoder01 sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2789 | @moigithub |http://www.freecodecamp.com/moigithub
Gulsvi
@gulsvi
Mar 05 2017 00:21
Uggh, but that's going to fail for exponents...
Conor Murphy
@cmurphy580
Mar 05 2017 00:22
I'm working on the tic tac toe challenge? I was wondering if anyone had any good resources for implementing the Minimax algorithm? Or is it better practice to just use the pseudo code and figure it out from there?
Timothy Lehner
@TimLehner
Mar 05 2017 00:24
Hey guys, I'd love some feedback on my Calculator! http://codepen.io/TimLehner/full/dvXJeZ/
Simon
@smnshulgan
Mar 05 2017 00:28
guys can you tell me where my error is please

function chunkArrayInGroups(arr, size)
{
var newarr =[];
for(var i = 0; i < size; i++)
{
for(var j = 0; j < size; j++)
{
newarr[i][j].push(arr[i]);
}
}
return newarr;
}

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

Greg Duncan
@GregatGit
Mar 05 2017 00:29
@smnshulgan for(var j = 0; j < size; j++) i dont think j and i should both equal size
Simon
@smnshulgan
Mar 05 2017 00:29
@GregatGit why
Lucas Scalzo
@Lu314
Mar 05 2017 00:29
I need help with #143
var myStr= "FirstLine\n\SecondLine\r\ThirdLine;"
Greg Duncan
@GregatGit
Mar 05 2017 00:30
@smnshulgan one should be < arr.length
jSwtch
@jSwtch
Mar 05 2017 00:30
hey why is the console.log () on line 41 giving me output from every element in the loop - I just want the final output.
https://codepen.io/jswtch/pen/jBqYaO?editors=1011
Simon
@smnshulgan
Mar 05 2017 00:30
@GregatGit is it the i one
yeah it is
Lucas Scalzo
@Lu314
Mar 05 2017 00:31
idk which is the proper escape sequence for the string
Gulsvi
@gulsvi
Mar 05 2017 00:35
@jswtch === instead of =
john94
@lpy1994
Mar 05 2017 00:38
function mutation(arr) {
    var arr0, arr1;
  arr0 = arr[0].toLowerCase();
  arr1 = arr[1].toLowerCase();
  for(var i = 0; i < arr1.length; i++){
   if(arr0.indexOf(arr1[i]) > -1){
      return true;
    }
    return false;
  }
}

mutation(["hello", "hey"]);
anything thing wrong with this code? it still return true.
Jor
@joreyesl
Mar 05 2017 00:40
@Lu314 remove the ;from inside the string. ; are used at the end of a line.
Lucas Scalzo
@Lu314
Mar 05 2017 00:40
thanx
Kenneth
@aspire4higher
Mar 05 2017 00:44
blob
is there something wrong with this code?
am I on the right track?
john94
@lpy1994
Mar 05 2017 00:45
@aspire4higher return string?
Kenneth
@aspire4higher
Mar 05 2017 00:45
yeah I was going to change that. But am I on the right track otherwise?
Jor
@joreyesl
Mar 05 2017 00:45
@aspire4higher yep, no you need an if statement after that to check count and return the appropriate result.
john94
@lpy1994
Mar 05 2017 00:46
@joreyesl take a look at mine, whats wrong with mine?
Jor
@joreyesl
Mar 05 2017 00:48
@lpy1994 when the code hits a return the function execution ends. So right now your loop is only iterating once. I would suggest you tweak your if statement to check when a character is not found and return false inside the if statement, and move the return true to outside the loop.
Simon
@smnshulgan
Mar 05 2017 00:51
can you use .toLowerCase () on an array
john94
@lpy1994
Mar 05 2017 00:51
@joreyesl thx ! just realized that loop only iterating once.
CamperBot
@camperbot
Mar 05 2017 00:51
lpy1994 sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 563 | @joreyesl |http://www.freecodecamp.com/joreyesl
Jor
@joreyesl
Mar 05 2017 00:51
@smnshulgan no, that is a string method
Simon
@smnshulgan
Mar 05 2017 00:51
@joreyesl k thanks
CamperBot
@camperbot
Mar 05 2017 00:51
smnshulgan sends brownie points to @joreyesl :sparkles: :thumbsup: :sparkles:
:cookie: 564 | @joreyesl |http://www.freecodecamp.com/joreyesl
Simon
@smnshulgan
Mar 05 2017 00:56
whats wrong with this, it says arr[0].split is not a function
arr[0] = arr[0].split("").toLowerCase().join("");
john94
@lpy1994
Mar 05 2017 00:56
@smnshulgan arr[0].split(“) is a array
Gulsvi
@gulsvi
Mar 05 2017 00:56
@smnshulgan .split() is for strings
Jor
@joreyesl
Mar 05 2017 00:57
@smnshulgan well toLowerCase() is not an array method. When you .split you created an array.
You can instead change the order, arr[0].toLowerCase().split('')
Simon
@smnshulgan
Mar 05 2017 00:57
what method should i use to "split" the arr[0] into a string
ok i dont get why the indexOf isnt working, it says its not a function

function mutation(arr)
{
var arr0 = arr[0];
arr[0] = arr0.toLowerCase;
var arr1 = arr[1];
arr[1] = arr1.toLowerCase;
var array = arr[1].indexOf(arr[0]);
if(array === 0)
{
return true;
}
else
{
return false;
}
}

mutation(["hello", "Hello"]);

john94
@lpy1994
Mar 05 2017 01:00
@smnshulgan from @joreyesl to me: when the code hits a return the function execution ends. So right now your loop is only iterating once. I would suggest you tweak your if statement to check when a character is not found and return false inside the if statement, and move the return true to outside the loop.
Simon
@smnshulgan
Mar 05 2017 01:01
@lpy1994 i dont have a loop
john94
@lpy1994
Mar 05 2017 01:01
@smnshulgan you might need one..
Simon
@smnshulgan
Mar 05 2017 01:01
@lpy1994 why
Jor
@joreyesl
Mar 05 2017 01:01
@smnshulgan arr[0] = arr0.toLowerCase; you are setting it to a function. You need to actually call the function to get the returned value. You need the (), arr[0] = arr0.toLowerCase()
Simon
@smnshulgan
Mar 05 2017 01:02
@joreyesl can you explain that
Jor
@joreyesl
Mar 05 2017 01:04
toLowerCase is a string method/function. In JS you can assign functions to variables. That is what you are doing when you don't use (). But when you actually want to use a function you add the () at the end.
function func() {
  return 'hello';
}


var a = func; // here i am assigning the actual function
var b = func(); // here i am calling the function

console.log(a); // [function: func]
console.log(b); // "hello"
Richard Walker
@RichWalker3
Mar 05 2017 01:05
Hey guys. I'm stuck on Global Scope and Functions in the javascript track. I have no idea how to give oopsGlobal a value of 5
Simon
@smnshulgan
Mar 05 2017 01:06
oh ok @joreyesl sorry that slipped my eye
why isnt it returing true

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

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

john94
@lpy1994
Mar 05 2017 01:07
@joreyesl this guy professional ;)
Emre
@emretinaz
Mar 05 2017 01:08
Hi guys, I am stuck on “Escape Sequences in Strings“ can anyone help for var myStr=“emre\n \tinaz\ \rnaber”; is giving error.
john94
@lpy1994
Mar 05 2017 01:08
@smnshulgan I used a for loop tho.
Moisés Man
@moigithub
Mar 05 2017 01:09
@smnshulgan u need to check if EACH character of second word
is on first word
john94
@lpy1994
Mar 05 2017 01:10
@smnshulgan notice that some characters aren’t stick together, thats why you need a loop to look for each character in the second value.
Jor
@joreyesl
Mar 05 2017 01:10
@smnshulgan as @lpy1994 pointed out, you will need a loop that iterates through arr[1] and you will be checking the indexOf of each characters. If at any point you get an index of -1 then return false, otherwise at the end of the loop you can return true.
Joseph
@revisualize
Mar 05 2017 01:11
hello.
john94
@lpy1994
Mar 05 2017 01:13
@emretinaz look closely. you will get it ;)
Richard Walker
@RichWalker3
Mar 05 2017 01:16
Hey guys. I'm stuck on Global Scope and Functions. I don't know where to start to assign a value of 5 to oopsGlobal
john94
@lpy1994
Mar 05 2017 01:20

@darthy0da Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword

@darthy0da do exactly as instructions say.
Mustapha
@krypticYB
Mar 05 2017 01:30

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

arr = testArr.push(10); 

item = testArr.shift();

return item; // Change this line
}

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

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

Please something seems to be missing in my code can anyone help out?

Nayenne Abgail
@Nayenne
Mar 05 2017 01:33

http://codepen.io/NayNay_s2/pen/NdzLxo?editors=1010

i need some help with my quote genarator pls.
how do i make the OKAY text disapear after i click to generate the first quote?

Realtorevanpan
@Realtorevanpan
Mar 05 2017 01:40

Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

var myStr = "FirstLine\n\SecondLine\\rThridLine";
myStr should have encoded text with the proper escape sequences and no spacing.
Nayenne Abgail
@Nayenne
Mar 05 2017 01:41
@Realtorevanpan is this for me?
Realtorevanpan
@Realtorevanpan
Mar 05 2017 01:41
Nope, is there any one can help?
Ken Haduch
@khaduch
Mar 05 2017 01:44
@Nayenne - y ou should just be able to write an an empty string to those two divs, like $('quoteBox1').text(''); the first time you are updating it? Set a flag to let you know that it was done (and didn't need to be done again?)
@Nayenne - oh, you're not using jQuery, I forgot. Just write a blank string to them in place of what is already there?
Ken Haduch
@khaduch
Mar 05 2017 01:52
@Realtorevanpan - check the spelling of the "ThirdLine" for one thing - maybe that will fix it?
Nayenne Abgail
@Nayenne
Mar 05 2017 01:55
@khaduch done! thanks =]
CamperBot
@camperbot
Mar 05 2017 01:55
nayenne sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2576 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Mar 05 2017 01:56
@Nayenne :+1:
Mustapha
@krypticYB
Mar 05 2017 01:56
i could use the help please, been stuck on this challenge for a while

can i please know whats missing in this code

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

arr = testArr.push(10); 

item = testArr.shift();

return item; // Change this line
}

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

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

Nayenne Abgail
@Nayenne
Mar 05 2017 01:57
@khaduch i was wondering what is agood way of containing my quote in the black cloud without changing the size ofthe cloud so much?
I mean it is ok with a smallquote but on the large ones it doesnt fit all the text, i tried using container class but it mess the cloud toomuch
Mustapha
@krypticYB
Mar 05 2017 01:58
anybody??
Ken Haduch
@khaduch
Mar 05 2017 01:58
@Realtorevanpan - it is hard to tell if you have the escaping done properly unless you enclose your code excerpt in single backquotes like `code` which will be rendered as code
Realtorevanpan
@Realtorevanpan
Mar 05 2017 01:58
@khaduch Thank you very much!
CamperBot
@camperbot
Mar 05 2017 01:58
realtorevanpan sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2577 | @khaduch |http://www.freecodecamp.com/khaduch
thisisandi
@thisisandi
Mar 05 2017 01:58
Hi
is there a more succinct way of solving Profile Lookup waypoint?
I resorted to a for loop + switch/case
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i=0; i<contacts.length; i++){
if (contacts[i].firstName==firstName) {
switch(prop){
case "firstName":
return contacts[i].firstName;
case "lastName":
return contacts[i].lastName;
case "number":
return contacts[i].number;
case "likes":
return contacts[i].likes;
default:
return "No such property";
}
}
}
return "No such contact";
}
Mustapha
@krypticYB
Mar 05 2017 01:59
no one? okay
andaddis
@andaddis
Mar 05 2017 02:00
I am having trouble with "Stand in Line." I don't understand how to change the queue
Ken Haduch
@khaduch
Mar 05 2017 02:00
@Nayenne - it's k ind of tough to do that when you have a special way of setting up the background - I wonder what would work - what did the container do?
Nayenne Abgail
@Nayenne
Mar 05 2017 02:01
it changes the height and weidth of the black cloud according to the size of the text and the setting of the padding for the quote id
@khaduch it changes the height and weidth of the black cloud according to the size of the text and the setting of the padding for the quote id
Ken Haduch
@khaduch
Mar 05 2017 02:04
@Nayenne - well, it looks better if the cloud isn't jumping around - it looks like there is more room on top of the black cloud, where you could push the text up a bit? Maybe get a line or two out of it?
like maybe take that padding-top off of #quoteBox1? It works for the long quote that I'm seeing now.
Ken Haduch
@khaduch
Mar 05 2017 02:11
@Nayenne - maybe setting up a flexbox element there that would keep the quote centered vertically within the cloud area would be a good way to do it? That way it would be more-or-less self-adjusting?
Mustapha
@krypticYB
Mar 05 2017 02:11
someone please reply me
Ken Haduch
@khaduch
Mar 05 2017 02:12
@krypticYB @krypticYB - you should only be using the function arguments arr where you want to operate on the array (the .push() and .shift() and use item for the thing that you are going to push.
Nayenne Abgail
@Nayenne
Mar 05 2017 02:13
@khaduch thanks that what i wanted cuz the larger text is fine now, but the smaller is right at the top,i will try and do what you suggested ;]
CamperBot
@camperbot
Mar 05 2017 02:13
nayenne sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: nayenne already gave khaduch points
Mustapha
@krypticYB
Mar 05 2017 02:14
@khaduch ok thank you
Ken Haduch
@khaduch
Mar 05 2017 02:17
@Nayenne - if you need that padding-top to start with, you could probably also remove it using the style object on that first div where you have the OKAY? at the start? I don't know how to work with flexbox elements all that well, but you can set it up for vertical and horizontal centering. Maybe you can make one div that encompasses all of the bumps in your cloud and then have the paragraph element layered on top of that? or within it? I'd have to try and experiment with it to see how it would potentially work.
Nayenne Abgail
@Nayenne
Mar 05 2017 02:28
@khaduch i will work on it
RandomJackie
@RandomJackie
Mar 05 2017 02:30
Hi everyone. I'm working on the addTogether program. I'm not understanding how to return a function when theres an argument missing. Any advice?
Ken Haduch
@khaduch
Mar 05 2017 02:36
@RandomJackie - use the arguments.length of the arguments object to determine if there are one or two arguments, and then act accordingly. If two arguments, check, add them and return. If one argument, return a function.
RandomJackie
@RandomJackie
Mar 05 2017 02:37
Ok. That's kind of what I'm trying to do. But am I returning a whole new function? And what does the function return?
Ken Haduch
@khaduch
Mar 05 2017 02:38
@RandomJackie - do you have a good understanding of closures? The function is going to use that principle to enclose the value of the first argument, and then return a function that will receive the second argument, add it to the first and return the result.
RandomJackie
@RandomJackie
Mar 05 2017 02:44
No closures kind of confuses me. But ok that makes sense. I guess I'm confused as to how it translates to code. I'll try a few things. Thanks
Ken Haduch
@khaduch
Mar 05 2017 02:49
@RandomJackie - I could post an example of a simple use of closures that I wrote when I was trying to get a better understanding of it. It applies nicely to this project, because that's what I was trying to figure out...
@Nayenne - I did get something using flexbox that works to large extent on your project - seems to get the quotes nicely centered in the cloud - I'll keep it in case you need to see it...
Pranjal Singi
@pranjalsingi
Mar 05 2017 02:53
I would need some help with regex. My string is "not a palindrome" and my regex expression is /\w+/ but its only matching 'not'. Why is it not matching for the whole string.
For a string like "hell%$#ohe^&llo" it matches "hellohello". Please help.
Johnny
@jtan3
Mar 05 2017 03:01
@pranjalsingi /\w+/ looks for any word character
@pranjalsingi http://regexr.com/ try this for regex
badalsaibo
@heyDante
Mar 05 2017 03:06
@jtan3 thanks for the tool !
Johnny
@jtan3
Mar 05 2017 03:08
there's a video in the help section too @heyDante
badalsaibo
@heyDante
Mar 05 2017 03:08
just seen that
james umali
@indefinite0212
Mar 05 2017 03:15
 ``` 
// Declare your variable here
var myGlobal = 10;

function fun1(oopsGlobal) {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5 ;
console.log(oopsGlobal);
}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
// oopsGlobal should have a value of 5
/*Using var, declare a global variable myGlobal outside of any function. Initialize it with a value of 10.

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.*/
```
I need help with that
Pranjal Singi
@pranjalsingi
Mar 05 2017 03:20
@jtan3 \w also matches underscore thats why I was getting a problem. Solved it by [^\W_]
RandomJackie
@RandomJackie
Mar 05 2017 03:23
Hey @khaduch sorry was trying some things out. Yea that would be great to see.
Andrew Shieh
@andrewlikes
Mar 05 2017 03:24
@indefinite0212 delete space after 5
Ken Haduch
@khaduch
Mar 05 2017 03:25
@RandomJackie - okay, I just popped it into a gist, probably needs a little cleanup, but the basic idea is there. Here is the link - see if it gives you some basics on the use of a function and closure.
Nayenne Abgail
@Nayenne
Mar 05 2017 03:31
@khaduch i am not able to use flexbox, really got stuck with it.
But i was thinking, is it possible for me somehow just to call out the 4th quote inJS code and change the padding only on that quote when it shows?
Ken Haduch
@khaduch
Mar 05 2017 03:34
@Nayenne - well, that would be a little awkward to do that - maybe you can check the length of the quote and make that modification, that way, if you add another long quote, you can have it more-or-less automatically do the alternate? I can share what I did in my quick test of doing the flexbox and you can see how it works out and if you would like to pursue it?
Here is the link to my fork of your project - it still needs a bit of tweaking, but you can see what it's doing...
Nayenne Abgail
@Nayenne
Mar 05 2017 03:36
@khaduch i will check it out now ;]
Mark
@vinarius
Mar 05 2017 03:36

Anyone up for some algorithm help? I'm digging into the 'Search and Replace' challenge on the intermediate front end level. I can't figure out specifically why str[i] == before /Sleeping == Sleeping / returns false. Any ideas? It passes two of the user stories so far but man I am stumped on this one.

function myReplace(str, before, after) {

//str = str.replace(/before/i, after);

//take a string
//split it into an array by spaces .split(' ');
//match the before and str by comparing the array elements str[i] with the before string
//replace what returns true from filter with after using .splice
//if str[i] == before then str[i] = before
// join the array together back into a string using .join(' ');

str = str.split(' '); //['let', 'us', 'go', 'to', 'the', 'store']
console.log(str);

for(var i = 0; i < str.length; i++){
console.log(i + ' ' + str[i]);
console.log(i + ' ' + before);
if(str[i] == before){
str[i] = before;
}

}

str = str.join(' ');

return str;
}

myReplace("He is Sleeping on the couch", "Sleeping", "sitting");

hcheung01
@hcheung01
Mar 05 2017 03:36
hey guys I kinda need help PLEASE

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

return item; // Change this line
}

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

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

RandomJackie
@RandomJackie
Mar 05 2017 03:36
@khaduch Thanks again! Gonna take a look at that right now :D
CamperBot
@camperbot
Mar 05 2017 03:36
randomjackie sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2578 | @khaduch |http://www.freecodecamp.com/khaduch
hcheung01
@hcheung01
Mar 05 2017 03:36
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10

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

return item; // Change this line
}

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

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

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

return item; // Change this line
}

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

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

RandomJackie
@RandomJackie
Mar 05 2017 03:38
thanks @khaduch
CamperBot
@camperbot
Mar 05 2017 03:38
randomjackie sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:warning: randomjackie already gave khaduch points
hcheung01
@hcheung01
Mar 05 2017 03:38
how can I add new items in the back of the queue and old items are taken off from the front of the queue
abstract Data Structure
Ken Haduch
@khaduch
Mar 05 2017 03:39
@hcheung01 - how is the queue being implemented?
hcheung01
@hcheung01
Mar 05 2017 03:41
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
and this is the code so far

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

return item; // Change this line
}

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

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

grrrr
related to .shift?
Nayenne Abgail
@Nayenne
Mar 05 2017 03:42
@khaduch oh i see what you did there! so much easier to understand when i see an example =] i will tweak it from there. once again, thank you!
CamperBot
@camperbot
Mar 05 2017 03:42
:star2: 2579 | @khaduch |http://www.freecodecamp.com/khaduch
nayenne sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
hcheung01
@hcheung01
Mar 05 2017 03:42

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

Ayush Bahuguna
@relentless-coder
Mar 05 2017 03:43
@hcheung01 you need to use array methods push, pop, shift, unshift. you can look 'em up on google. they are easy to implement. all the best :)
hcheung01
@hcheung01
Mar 05 2017 03:43
just as suspected
thank ya
Ken Haduch
@khaduch
Mar 05 2017 03:45
@Nayenne - yeah, just a little shuffling of the HTML elements and assigning the flex properties. As I said, I'm not an expert at flex, but I've done a few tutorials and lessons and tried it here and there... hope it works!
Ayush Bahuguna
@relentless-coder
Mar 05 2017 03:46
flexbox is awesome. :+1:
like magic.
beautiful mobile optimised landing pages get done within an hour.
rsenter1993
@rsenter1993
Mar 05 2017 03:58
Hey all
What is a escape quotes?
Ken Haduch
@khaduch
Mar 05 2017 04:08

@rsenter1993 - "escaping" characters refers to using the backslash character - \ preceding another character to 'hide' it's normal meaning from the javascript processing code. Normally when you use quotes, it is a delimiter for a string, something like:
var myStr = "This is a string";

If you wanted to have some quotes inside that string, you could not just add them into the string as you might in a normal written sentence: var myStr = "This is a "strange" place!"; - you would get some misinterpretation from javascript as it processed the code. You have to use "escaping" - writing the quotation marks for the internal part of the string, as \".
So your final string for my example: var myStr = "This is a \"strange\" place!";
The internal quotation marks would be ignored by the javascript processing and would remain in place within the string as actual quotation marks. Outputting that string to console.log(myStr); should give the output This is a "strange" place!

Kent Saeteurn
@sansae
Mar 05 2017 04:10

Hi all, I have a general question regarding binding events in javascript/jquery.

I'm just trying to get a better understanding overall. Any help would be greatly appreciated. Here is the code:

document.onkeydown = myFunction;

function myFunction(evt) {
   etc.
}

In the first line with ".onkeydown", is it correct for me to say that I am performing an "event binding"?

If I am correct, event binding occurs when we tell the browser that when a certain event happens in our DOM (in this case, the event is "onkeydown"), run this function (in this case, the function being ran is myFunction).

Can someone chime in and help clarify some things for me? thanks in advance.

hcheung01
@hcheung01
Mar 05 2017 04:15
sorry to bother y'all all I am still very stuck. I know it is related to manipulating arrays with .shift .pop etc but Im not getting the results

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

return item; // Change this line
}

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

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

In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

and this is what Im suppose to achieve
nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10
hugo
@hramos0910
Mar 05 2017 04:20
hello?
Gulsvi
@gulsvi
Mar 05 2017 04:20
@sansae That example isn't a binding, from my unerstanding. You are adding an keyDown event listener. You can then bind specific events (like the Enter key) to a function.
hugo
@hramos0910
Mar 05 2017 04:21
im trying to assign a to b with a = sign what am i doing wrong?
// Only change code below this line
var a = 7;
var b = 7;
var a = b;
Gulsvi
@gulsvi
Mar 05 2017 04:21
But in general, I guess it would be called 'event binding'
Kent Saeteurn
@sansae
Mar 05 2017 04:21
@SkyCoder01 Hey Sky, thank you for the response. I figured it wasn't an example of binding, especially when considering I'm not using the keyword "bind".
CamperBot
@camperbot
Mar 05 2017 04:21
sansae sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 441 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Gulsvi
@gulsvi
Mar 05 2017 04:21
@hramos0910 That looks right to me
@sansae I recently read that .bind() was removed from the recent versions of jQuery, in favor of .on() - I can dig up a link that talks more about it
Kent Saeteurn
@sansae
Mar 05 2017 04:22
@SkyCoder01 no worries about the link, Sky. I can def google that one
Moisés Man
@moigithub
Mar 05 2017 04:23
@hramos0910 once the variable is declared/created using var u no longer need var again.. just the variable name
Gulsvi
@gulsvi
Mar 05 2017 04:23
kk
Kent Saeteurn
@sansae
Mar 05 2017 04:23
@SkyCoder01 I'm actually still seeing a lot of folks using "bind" in their code examples (dates as early as 2016)
Gulsvi
@gulsvi
Mar 05 2017 04:24
@sansae I don't know when jQuery 3.0 was released, but .bind() is now in the deprecated 3.0 section of the documents: http://api.jquery.com/bind/
Alex Harrison
@alexharrison-js
Mar 05 2017 04:24
Hello Everyone
Gulsvi
@gulsvi
Mar 05 2017 04:24
Hello
Alex Harrison
@alexharrison-js
Mar 05 2017 04:25
I am having difficulty wrapping my head around accessing variable properties in JS
Kent Saeteurn
@sansae
Mar 05 2017 04:25
@SkyCoder01 gotcha
Alex Harrison
@alexharrison-js
Mar 05 2017 04:25
I don't understand why my code isn't working
Gulsvi
@gulsvi
Mar 05 2017 04:27
can you post your code? maybe we can help
Alex Harrison
@alexharrison-js
Mar 05 2017 04:28
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = Number (testObj.Montana);       // Change this Line
var player = String(testObj[playerNumber]); // Change this Line
I'm working through the exercise in freecodecamp.com
titled "
Accessing Objects Properties with Variables"
Kent Saeteurn
@sansae
Mar 05 2017 04:29

@sansae I recently read that .bind() was removed from the recent versions of jQuery, in favor of .on() - I can dig up a link that talks more about it
@SkyCoder01 hahaha, well, the key word ".onkeydown" does have the word ".on", so I guess it is binding;

nice chatting with you sky; i appreciate your time, and thank you for the link

CamperBot
@camperbot
Mar 05 2017 04:29
sansae sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:warning: sansae already gave skycoder01 points
Alex Harrison
@alexharrison-js
Mar 05 2017 04:29
and I can't figure out why I need to put Number and String in there to make it recognize them as a Number and a String respectively
Gulsvi
@gulsvi
Mar 05 2017 04:30
lol :) probably semantics, event handling and binding :) you too @sansae
Ken Haduch
@khaduch
Mar 05 2017 04:30
@alexharrisonmusic - playerNumber should just be a number. Like the property that will get you to "Montana". Then player might work as you have it, but you don't really need the String and the parentheses.
Alex Harrison
@alexharrison-js
Mar 05 2017 04:32
Thanks!
I was overthinking it
Thanks @khaduch
CamperBot
@camperbot
Mar 05 2017 04:32
alexharrisonmusic sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 2580 | @khaduch |http://www.freecodecamp.com/khaduch
Ken Haduch
@khaduch
Mar 05 2017 04:38
@alexharrisonmusic - you're welcome. A good thing to do with that particular lesson, once it is solved, is to look at the test information - the results, what they are expecting, and try to correlate it to the code that was written. Many times the clues that you can glean from the description + the test results can really help a lot. It is somewhat related to "test driven design", although they don't really present it that way. It is good to use all of the clues you can get!
Nayenne Abgail
@Nayenne
Mar 05 2017 04:39
http://codepen.io/NayNay_s2/pen/NdzLxo?editors=1000 for some reson my twiiter share button stopped working, can anyone help pls?
core
@core668
Mar 05 2017 04:41
    function getMaxOfArray(numArray) {
        return Math.max.apply(null, numArray);
    }

    function getMinOfArray(numArray) {
        return Math.min.apply(null, numArray);
    }


    function sumAll(arr) {
        var min = getMinOfArray(arr);
        var max = getMaxOfArray(arr);
        var newArray = [];
        for (var i = min; i <= max; i++) {
            newArray.push(i);
        }
        var sum = newArray.reduce(function(acc,val){
            return acc + val;
        });
        return sum;
    }

    sumAll([1, 4]);//1+2+3+4 = 10
have more simple method?
Chuck Taylor
@cbtaylor2
Mar 05 2017 04:49
var myStr = "First\tline\n\"Second\tline\"\rThird\tline";
Please help. Totally lost.
Escape Sequences In Strings
Manish Giri
@Manish-Giri
Mar 05 2017 04:50
@core668 this return Math.max.apply(null, numArray); can be replaced with return Math.max(...numArray);
heroiczero
@heroiczero
Mar 05 2017 04:51
@cbtaylor2 did you see how it was supposed to look like? you just have to use the \newline and \return-carriage and escape your \
Ken Haduch
@khaduch
Mar 05 2017 04:57
@Nayenne - I just tried it, it seems to be working? Did you fix something since your post?
Nayenne Abgail
@Nayenne
Mar 05 2017 04:58
@khaduch yes i did ;]
core
@core668
Mar 05 2017 04:58
this topic have more simple method?
Ken Haduch
@khaduch
Mar 05 2017 05:00
@Nayenne - good - good work there...
Chuck Taylor
@cbtaylor2
Mar 05 2017 05:04
@heroiczero. Yes I did and I'm still stuck. One incorrect red x. I have 3 out of 4 green correct check marks. The incorrect red x says myStr should have encoded text with the proper escape sequences and no spaces.
heroiczero
@heroiczero
Mar 05 2017 05:05
@cbtaylor2 did you do FirstLine capital L
badalsaibo
@heyDante
Mar 05 2017 05:06
Whats the difference b/w JSON, jQuery and JS?
heroiczero
@heroiczero
Mar 05 2017 05:06
@cbtaylor2 in the direction it does not ask you to tab so i don't know why you are using \t
@heyDante JSON is javascript Object notation, jQuery is a javascript library making it easier to script things into websites and Javascript is just a programming language that runs client side.
Chuck Taylor
@cbtaylor2
Mar 05 2017 05:11
trying now
DmtElfs
@DmtElfs
Mar 05 2017 05:12
"In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue." could someone better explain that concept?
Seth Church
@iEnder
Mar 05 2017 05:14
say you have a line of people trying to get into a store. people can join the back of the line but only 1 person can go into the store from the front of the line at a time. that's what a queue is like you can only add 1 person/item to the end and take 1 off the front at a time @DmtElfs
so in javascript it would be like having an array which you can only use .shift and .push on
Mokkants
@Mokkants
Mar 05 2017 05:18
hey guys I need some help, this should be really simple stuff but it doesn't work as I'd anticipated, I'm doing the twitch api thingy and I append a list item to the list for every item in the array, then I wrap the name of the streamer in an <a>, referencing that stream's url
DmtElfs
@DmtElfs
Mar 05 2017 05:18
Thank you @pkmn9060
CamperBot
@camperbot
Mar 05 2017 05:18
dmtelfs sends brownie points to @pkmn9060 :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @pkmn9060 |http://www.freecodecamp.com/pkmn9060
Mokkants
@Mokkants
Mar 05 2017 05:18

$(document).ready(function(){
var streams=["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
var online;
var url;
function getStreamData(i){
$.getJSON(' https://wind-bow.gomix.me/twitch-api/streams/'+streams[i]+'?callback=?', function(data) {
console.log(streams[i]);
online=data.stream === null ? false : true;
url="https://www.twitch.tv/"+streams[i];
$("#channels").append('<li><a href="'+url+'" target="_blank"><div class="streamer">'+streams[i]+'</div></a><div class="online">'+(online ? "Online" : "Offline")+'</div></li>');

});
}

for(var i=0;i<streams.length;i++){
getStreamData(i);
}
});

Seth Church
@iEnder
Mar 05 2017 05:19
@Mokkants put ``` before and after your code so its formatted
Mokkants
@Mokkants
Mar 05 2017 05:19
woops, i have no idea how to send this in compose mode... anyhow
Ayush Bahuguna
@relentless-coder
Mar 05 2017 05:19
so, I can change the object that a function's prototype points then what happens to the object instances that inherited from that object before pointing to a different object?
Mokkants
@Mokkants
Mar 05 2017 05:19
ah ok i thought i´d just have to switch to compose mode and send it
Gulsvi
@gulsvi
Mar 05 2017 05:20
@Mokkants Change var to let here: for(var i=0;i<streams.length;i++){
Ayush Bahuguna
@relentless-coder
Mar 05 2017 05:20
@Mokkants
step 1: type three backticks. this is a backtick `
step 2: paste your code in a new line below the backticks
step 3: then type three backticks in a new line below your code
Seth Church
@iEnder
Mar 05 2017 05:20
@relentless-coder you mean if you change a single instances prototype?
what happends to the others?
Gulsvi
@gulsvi
Mar 05 2017 05:21
```
your code
```
Mokkants
@Mokkants
Mar 05 2017 05:21
the code works fine, it does what I want it to
but when I click on the links
it doesn't load up
it just loads a blank page with the correct url
Gulsvi
@gulsvi
Mar 05 2017 05:22
usually running a function in a for loop is bad
badalsaibo
@heyDante
Mar 05 2017 05:22
@heroiczero All comes under JS right?
Mokkants
@Mokkants
Mar 05 2017 05:22
if I take the url and copy-paste it in another tab it loads and works
heroiczero
@heroiczero
Mar 05 2017 05:22
@heyDante yes basically they are all javascript
Mokkants
@Mokkants
Mar 05 2017 05:22
but if i just keep refreshing the loaded page it's blank, any idea why that's happening? I've never met this issue
Gulsvi
@gulsvi
Mar 05 2017 05:23
@Mokkants That happens in everyone's Twitch projects. Click the "Change View" button, top, right-hand corner, then open "Debug Mode" and try it. The problem goes away. It has something to do with opening flash from inside an iFrame (like codepen's editor view)
Ayush Bahuguna
@relentless-coder
Mar 05 2017 05:23
say, I have a function constructor, and obviously it has a prototype object from which all the object instances created using the function constructor inherit. and I create a few instances. and their proto object references to the prototype object of the function constructor. Now let's say I change the function's prototype to a new object. But the old instances' proto object still points to the old prototype object. Why? I thought they were all references.
@pkmn9060
Mokkants
@Mokkants
Mar 05 2017 05:24
@SkyCoder01 usually it is but i see no other way around this, how would i make an ajax call to every item in the array at once?
Gulsvi
@gulsvi
Mar 05 2017 05:25
@Mokkants Use the .forEach() method, it includes a callback for handling async functions
You can also get fancy and push all your getJSON calls into an array and then call them with $.when
Mokkants
@Mokkants
Mar 05 2017 05:26
you learn something every day huh
@SkyCoder01 thanks a lot!
CamperBot
@camperbot
Mar 05 2017 05:26
mokkants sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 445 | @skycoder01 |http://www.freecodecamp.com/skycoder01
Seth Church
@iEnder
Mar 05 2017 05:27
once they have been created yes they inherit the props given to them at that time and are given the prototype but they are still individuals pointing to the same prototype not the constructor the constructor function prototype can be changed to a different object which is changing its reference not editing the current prototype which they are all pointing too which is why adding to the prototype changes it for all your not breaking the reference
Gulsvi
@gulsvi
Mar 05 2017 05:27
@Mokkants No problem. Twitch taught me a lot!
Seth Church
@iEnder
Mar 05 2017 05:30
its like if you had two variables assigned to an object you can edit that object and it would make those props/methods available to both but if you reassign one of those variables its no longer pointing to the same object but it doesn't affect what the other variable is pointing to
@relentless-coder
jeevanach
@jeevanach
Mar 05 2017 05:33
plz help
Seth Church
@iEnder
Mar 05 2017 05:33
?
jeevanach
@jeevanach
Mar 05 2017 05:33

var myStr="I am a \"double quoted\" string inside\"double quotes\".";// Change this line

var myStr="I am a \"double quoted\" string inside\"double quotes\".";// Change this line

Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".
h1tag
@h1tag
Mar 05 2017 05:34
@jeevanach what's the challenge name?
jeevanach
@jeevanach
Mar 05 2017 05:35
Quotes in Strings
Seth Church
@iEnder
Mar 05 2017 05:35
your missing a space between inside\" and double
@jeevanach
Joseph
@revisualize
Mar 05 2017 05:36
@jeevanach You're missing a space
@jeevanach de\"do needs a space
@jeevanach inside\"double <-- add space
Seth Church
@iEnder
Mar 05 2017 05:36
lol
jeevanach
@jeevanach
Mar 05 2017 05:36
@pkmn9060 thank you
CamperBot
@camperbot
Mar 05 2017 05:36
:cookie: 317 | @pkmn9060 |http://www.freecodecamp.com/pkmn9060
jeevanach sends brownie points to @pkmn9060 :sparkles: :thumbsup: :sparkles:
jeevanach
@jeevanach
Mar 05 2017 05:37
@revisualize thank you
CamperBot
@camperbot
Mar 05 2017 05:37
jeevanach sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3422 | @revisualize |http://www.freecodecamp.com/revisualize
DmtElfs
@DmtElfs
Mar 05 2017 05:38

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

return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I'm lost this is related to the question i asked before.

heroiczero
@heroiczero
Mar 05 2017 05:38
@DmtElfs review how to Manipulate arrays ... in Free code camp
DmtElfs
@DmtElfs
Mar 05 2017 05:39
Stand in Line
@heroiczero Thank you
CamperBot
@camperbot
Mar 05 2017 05:40
dmtelfs sends brownie points to @heroiczero :sparkles: :thumbsup: :sparkles:
:cookie: 928 | @heroiczero |http://www.freecodecamp.com/heroiczero
icodeyouso
@icodeyouso
Mar 05 2017 05:40

so am i supposed to write a second wordBlanks fucntion using the cat set?

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


function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "the" +  " " + "big" + " " +  "dog" + "," + "ran" + " " + "quickly";
  // 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");
heroiczero
@heroiczero
Mar 05 2017 05:42
@icodeyouso gotta use the parameters of the function which are myNoun, myAdjective, myVerb, myAdverb
for your result="some string "+ noun +...
Bryan Reese
@breese8009
Mar 05 2017 05:52
@DmtElfs the first thing u need to do is push item peram into the array
Xi
@yuman959
Mar 05 2017 05:52
Hi! I’m on the Weather API project. I’m using this API https://openweathermap.org/current Question is how can I output the weather icon as a graphic element rather than just the weather icon id (data.weather[0].icon)? Thanks!
Bryan Reese
@breese8009
Mar 05 2017 05:53
@DmtElfs After you push the item into the array u then want to use the shift method, if you dont know what that is, then you can look it up on MDN or wherever...
@yuman959 u want to know how to put the api url together?
Xi
@yuman959
Mar 05 2017 05:54
@breese8009 I want to have a weather icon rather than just the icon id
Seth Church
@iEnder
Mar 05 2017 05:55
@yuman959 youll want a way to set an elements image depending on what the id is
icodeyouso
@icodeyouso
Mar 05 2017 05:59
alt
Gulsvi
@gulsvi
Mar 05 2017 06:02
@yuman959 This page shows you how to do it: https://openweathermap.org/weather-conditions
Basically http://openweathermap.org/img/w/<<<<weather-icon-id>>>.png
Xi
@yuman959
Mar 05 2017 06:03
@SkyCoder01 this is super helpful! How did you navigate to this page from homepage?
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 05 2017 06:03
how do i split a Var by spaces with the .split assignment
Shivani Makwana
@ShivaniMakwana
Mar 05 2017 06:04
hey....my task is:Quoting Strings with Single Quotes
but i cant understand what it is asking
var myStr = "'<a href=\"http://www.example.com\" target=\"_blank\">Link</a>'";
Gulsvi
@gulsvi
Mar 05 2017 06:04
@yuman959 I found it a long time ago, but don't remember how. I searched google for openweathermap icons and it was the first result
Shivani Makwana
@ShivaniMakwana
Mar 05 2017 06:04
error:Remove all the backslashes ()
You should have two single quotes ' and four double quotes "
Only remove the backslashes \ used to escape quotes.
Seth Church
@iEnder
Mar 05 2017 06:05
@ShivaniMakwana change all the " to ' and get rid of the \
only inside the outside " though
Shivani Makwana
@ShivaniMakwana
Mar 05 2017 06:05
still i am getting error....
if u dont mind can you plz write full code?? plz
Gulsvi
@gulsvi
Mar 05 2017 06:06
@yuman959 If you go to: https://openweathermap.org/current, The link is in the section titled "List of weather condition codes"
Xi
@yuman959
Mar 05 2017 06:08
Ah Gotcha! Thanks! @SkyCoder01
CamperBot
@camperbot
Mar 05 2017 06:08
yuman959 sends brownie points to @skycoder01 :sparkles: :thumbsup: :sparkles:
:cookie: 446 | @skycoder01 |http://www.freecodecamp.com/skycoder01
h1tag
@h1tag
Mar 05 2017 06:08
@icodeyouso keep in mind that your function won't be passed the same strings evrytime
Shusil Banjade
@shusil123
Mar 05 2017 06:12
@TheTRUEHoohah , Like this: var_name.split(" ");.
Zachary Orona-Calvert
@TheTRUEHoohah
Mar 05 2017 06:12
thanks @shusil123
CamperBot
@camperbot
Mar 05 2017 06:12
thetruehoohah sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 766 | @shusil123 |http://www.freecodecamp.com/shusil123
Tanner Jack
@Knifetanner2
Mar 05 2017 06:12

Been having some problems with this and can't figure it out. Can whoever helps me out also explain it?
var myStr; '"FirstLine" \n \SecondLine\ \r ThirdLine'
Here's the instrutions: Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine \SecondLine\ ThirdLine
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLine newline backslash SecondLine backslash carriage-return ThirdLine

h1tag
@h1tag
Mar 05 2017 06:19
@Knifetanner2 first, it doesn't ask you to put quotes around FirstLine
and this is not how you assign a string to a variable var myStr; '"FirstLine" \n \SecondLine\ \r ThirdLine'
Tanner Jack
@Knifetanner2
Mar 05 2017 06:20
Thats not what I have... What I have is a mess that just keeps on confusing me more
h1tag
@h1tag
Mar 05 2017 06:21
where did that (var myStr; '"FirstLine" \n \SecondLine\ \r ThirdLine') come from then? I don't see it on the challenge page
Tanner Jack
@Knifetanner2
Mar 05 2017 06:22
Hmm idk might be one of my earlier attempts. I've tried this like 30 times
h1tag
@h1tag
Mar 05 2017 06:22
@Knifetanner2 can you show your final attempt then?
Tanner Jack
@Knifetanner2
Mar 05 2017 06:23
Oh I just reset it
@fortMaximus
h1tag
@h1tag
Mar 05 2017 06:24
@Knifetanner2 ok, try to read it and write the code for it again, and let's see your code
Tanner Jack
@Knifetanner2
Mar 05 2017 06:24
okay gimme a couple of minutes
Tanner Jack
@Knifetanner2
Mar 05 2017 06:33
var myStr= // Change this line "FirstLine \n \\SecondLine\\ \r ThirdLine" ; Got it! :smile: Just have to figure out spacing
Joseph
@revisualize
Mar 05 2017 06:34
@Knifetanner2 You just remove the spaces
@Knifetanner2 having // Change .... makes everything after the // a comment.
Tanner Jack
@Knifetanner2
Mar 05 2017 06:35
nice it worked @revisualize whys it look so bad :/
Joseph
@revisualize
Mar 05 2017 06:35

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

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

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

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

I strongly feel that a lot of people are just trying to complete lessons and not trying to figure out what the lesson is actually trying to teach them. Because what the lesson is trying to teach is FAR more important of a concept than getting the lesson correct.

Tanner Jack
@Knifetanner2
Mar 05 2017 06:36
thanks @revisualize
CamperBot
@camperbot
Mar 05 2017 06:36
knifetanner2 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 3423 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Mar 05 2017 06:37

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

Here's an example of this:

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

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

icodeyouso
@icodeyouso
Mar 05 2017 06:38
@fortMaximus can you say that again not sure it made sense
Tanner Jack
@Knifetanner2
Mar 05 2017 06:38
@revisualize so what this lesson is trying to teach is how to escape sequences? or what
Joseph
@revisualize
Mar 05 2017 06:39
@Knifetanner2 Did you not read what I just wrote?
Tanner Jack
@Knifetanner2
Mar 05 2017 06:39
I did but little confused
Joseph
@revisualize
Mar 05 2017 06:41
@Knifetanner2 How about you just slow down and re-read it.
h1tag
@h1tag
Mar 05 2017 06:43
@icodeyouso look at Joseph's message to you, he explains it better
Nataly C.
@cstpk
Mar 05 2017 06:44
help with Factorialize a Number challenge anyone?
Tanner Jack
@Knifetanner2
Mar 05 2017 06:46
@revisualize So escaping a string just means to make it so it is able to be read so in `var myStr = 'Pi="3.14" ' it will be read as Pi= "3.14" with 3.14 in the quotes correct? But what is the escaping the line and carriage return do? What is the escaping actually doing? Oh wait so /n means it makes a new line ?
Joseph
@revisualize
Mar 05 2017 06:47
@Knifetanner2 No \n means new line
@Knifetanner2 What happens when you instantiate your string with double quotes? var myStr = "Pi is \"3.14159265359\"";
icodeyouso
@icodeyouso
Mar 05 2017 06:53
@revisualize this may be my own doing but im kinda lost ..i got the first and third task to pass on the word blanks lesson so i thought i was onto something but the explanation seems a bit diffferent then how i got my answer
Tanner Jack
@Knifetanner2
Mar 05 2017 06:59
@revisualize It wouldn't work correct? It would need to be var myStr = 'Pi is \"3.14159265359\"'; so that you are able to use the variable?
Joseph
@revisualize
Mar 05 2017 06:59
@Knifetanner2 What?
badalsaibo
@heyDante
Mar 05 2017 06:59
@natalyscosta you tried?
Joseph
@revisualize
Mar 05 2017 07:00
@Knifetanner2 You use \" to escape quotes when you instantiate a string with double quotes.
@Knifetanner2 What I wrote is correct.
Tanner Jack
@Knifetanner2
Mar 05 2017 07:00
oh okay so it will say pi is "3.14"
Joseph
@revisualize
Mar 05 2017 07:01
No.
var myStr = "Pi is \"3.14159265359\""; the value of myStr is a string that reads Pi is "3.14159265359"
Tanner Jack
@Knifetanner2
Mar 05 2017 07:02
yeah I was just shortening it
okay I think I understand now thanks @revisualize
CamperBot
@camperbot
Mar 05 2017 07:02
knifetanner2 sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: knifetanner2 already gave revisualize points
Nataly C.
@cstpk
Mar 05 2017 07:03
@heyDante I can't figure out how to approach it
badalsaibo
@heyDante
Mar 05 2017 07:04
@natalyscosta you could use loop for that
eliecerthoms
@eliecerthoms
Mar 05 2017 07:14
hey guys :D
weird question but... is there a way to grab an if statement inside a variable?
like, I have a lot of functions that need an if(err){return err} and was just wondering
You know with all the Don't Repeat Yourself fad...
DmtElfs
@DmtElfs
Mar 05 2017 07:16
Could someone walk me through the
"Stand in line" challenge
Nataly C.
@cstpk
Mar 05 2017 07:17
@heyDante thanks
CamperBot
@camperbot
Mar 05 2017 07:17
natalyscosta sends brownie points to @heydante :sparkles: :thumbsup: :sparkles:
:cookie: 519 | @heydante |http://www.freecodecamp.com/heydante
Xi
@yuman959
Mar 05 2017 07:19
Hi, I have a simple question: when I use slash in http:// in my code, I always comment out the rest of the code because of the slashes. How can I make sure I don’t comment out the code with the slash?
eliecerthoms
@eliecerthoms
Mar 05 2017 07:22
@yuman959 have it inside quotes
either single ' or double "
if you don't the engine will read http://whatever.com as a variable and your code will not work anyway
Johnny
@jtan3
Mar 05 2017 07:24
@DmtElfs try using array.pop() .shift() .unshift() or .push()
Xi
@yuman959
Mar 05 2017 07:24
@eliecerthoms I’m still on the weather API weather icon exercise. I have weather icon ID. Now in my javascript, I want to put the code like this: $(“h1”).html(“<img src=“http://openweathermap.org/img/w/“ + data.weather.icon + “.png>” “) But the // always comment out the rest of the code
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:25
@eliecerthoms yes there's a way
eliecerthoms
@eliecerthoms
Mar 05 2017 07:26
@yuman959 $(“h1”).html(“<img src='http://openweathermap.org/img/w/' + data.weather.icon + '.png>'“) I think this will work
the double quotes define unwanted boundaries in your html injection, so you have to alternate between single and double
OR
escape the double quotes aimed at your URL
$(“h1”).html(“<img src=\“http://openweathermap.org/img/w/\“ + data.weather.icon + \“.png>\” “) like this
Xi
@yuman959
Mar 05 2017 07:28
How do I escape the double quotes?
oh with the \
eliecerthoms
@eliecerthoms
Mar 05 2017 07:28
yup
@Lumexralph how?
Xi
@yuman959
Mar 05 2017 07:29
Let me give both a try!
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 07:29
@natalyscosta You can also use the push() and reduce() methods to achieve it.
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:29
@eliecerthoms you can use || or tenary operator
Xi
@yuman959
Mar 05 2017 07:30
It worked! Thanks!!! @eliecerthoms
CamperBot
@camperbot
Mar 05 2017 07:30
yuman959 sends brownie points to @eliecerthoms :sparkles: :thumbsup: :sparkles:
:cookie: 314 | @eliecerthoms |http://www.freecodecamp.com/eliecerthoms
eliecerthoms
@eliecerthoms
Mar 05 2017 07:30
@Lumexralph ah yeah! did it with the ternary
function getAllPosts() {
    return Post.find(function(err, posts) {
        err ? console.log(err); return 'Error fetching Posts': return posts
    })
}
@yuman959 my pleasure
Xi
@yuman959
Mar 05 2017 07:31
:-)
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:31
@eliecerthoms okay
eliecerthoms
@eliecerthoms
Mar 05 2017 07:32
@Lumexralph does that look alright?
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:32
@eliecerthoms i don't think so, did it work?
eliecerthoms
@eliecerthoms
Mar 05 2017 07:32
im squeamish about the console.log() separated with the ;
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:32
@eliecerthoms yes, same here
@eliecerthoms you know ; terminates or ends a statement
eliecerthoms
@eliecerthoms
Mar 05 2017 07:33
@Lumexralph haven't tested it :P I'm still setting up all the code and stuff
yeeh :S
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:34
@eliecerthoms maybe you you console log after the tenary operator
eliecerthoms
@eliecerthoms
Mar 05 2017 07:35
I kinda see how I could manage to do that, but it would beat the simplicity of the ternary :P
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:36
@eliecerthoms you're just using console log to debug, it doesn't change the simplicity of the operator
eliecerthoms
@eliecerthoms
Mar 05 2017 07:36
function getAllPosts() {
    return Post.find(function(err, posts) {
        err ? return 'Error fetching Posts': return posts;
        console.log(err);
    })
}
Like this you say?
if there's an error it would log it, if not, it would still attempt to do so, but log undefined/null
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:37
@eliecerthoms but due to return it won't be reached
eliecerthoms
@eliecerthoms
Mar 05 2017 07:37
true!!
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:37
@eliecerthoms do it before the operator
eliecerthoms
@eliecerthoms
Mar 05 2017 07:38
but it would log null if there wasn't an error D:
better stick to the basics imo hahahah
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:39
@eliecerthoms your operator is not assigning a value to err i hope you know?
@eliecerthoms and if there's an error? won't it log it too?
eliecerthoms
@eliecerthoms
Mar 05 2017 07:39
yes I know, but if that callback gets passed the list of posts, the err would be null
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:42
@eliecerthoms you don't even need to log it in the callback, you can track it in the getAllPosts function from whatever is returned from the callback
@eliecerthoms because this is what will be logged whatever the state of err..... return 'Error fetching Posts': return posts;
eliecerthoms
@eliecerthoms
Mar 05 2017 07:44
@Lumexralph I don't think so, first I am returning the Post.find() operation which will exit the main function, then there's the issue with async
Tanner Jack
@Knifetanner2
Mar 05 2017 07:45
I am using this code and it is just returning a blank string but with no error. Some help?
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) { var result = ""; // Your code below this line var myStr='Once there was a'; myStr += myNoun; myStr +='that was very'; myStr +=myAdjective; myStr +='. It '; myStr +=myVerb; myStr +='very '; myStr +=myAdverb; // Your code above this line return result; } // Change the words here to test your function wordBlanks("dog", "big", "ran", "quickly");
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:45
@eliecerthoms oh..... async
eliecerthoms
@eliecerthoms
Mar 05 2017 07:45
@Knifetanner2 try to format it with three backticks up, three backticks down
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:46
@eliecerthoms then track what is returned from the Post.find()
eliecerthoms
@eliecerthoms
Mar 05 2017 07:46
```
CODE HERE
```
@Knifetanner2
Tanner Jack
@Knifetanner2
Mar 05 2017 07:46
I did that :/
eliecerthoms
@eliecerthoms
Mar 05 2017 07:46
try again mate haha
badalsaibo
@heyDante
Mar 05 2017 07:46
``` (shift + enter)
Tanner Jack
@Knifetanner2
Mar 05 2017 07:47
function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
  var result = "";
  // Your code below this line
  var myStr='Once there was a';
  myStr += myNoun;
  myStr +='that was very';
  myStr +=myAdjective;
  myStr +='. It ';
  myStr +=myVerb;
  myStr +='very ';
  myStr +=myAdverb;


  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("dog", "big", "ran", "quickly");
it needed its own line i guess
eliecerthoms
@eliecerthoms
Mar 05 2017 07:47
@Lumexralph but it would be even MORE complicated wouldn't it? xD
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:48
@eliecerthoms depends on what you mean by complicated....
eliecerthoms
@eliecerthoms
Mar 05 2017 07:48
@Knifetanner2 you're returning result
@Knifetanner2 you need to add the string to result, then return result
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:49
@Knifetanner2 you need to join your parameters with + separated with spaces " " assign it to result
Tanner Jack
@Knifetanner2
Mar 05 2017 07:50
what do you mean by add string?
eliecerthoms
@eliecerthoms
Mar 05 2017 07:50
@Lumexralph I'm just gonna do my if statement mate hah
function getAllPosts() {
    return Post.find(function(err, posts) {
      if (err) {
          console.log(err);
          return 'Error fetching Posts'
      }
      return posts
    })
}
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:51
@eliecerthoms :laughing:
eliecerthoms
@eliecerthoms
Mar 05 2017 07:51
@Knifetanner2 what youre doing to myString, do it to result too
result += myString
then return result
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:51
@Knifetanner2 :point_up: March 5, 2017 8:49 AM
Tanner Jack
@Knifetanner2
Mar 05 2017 07:52
that worked but wasn't supposed to code under the line haha. Whatever
eliecerthoms
@eliecerthoms
Mar 05 2017 07:53
@Knifetanner2 You could've just returned myString tho hahaha
Tanner Jack
@Knifetanner2
Mar 05 2017 07:54
¯\_(ツ)_/¯
Prashant Gaurav
@prashantgaurav36
Mar 05 2017 07:54
i am confused in this problem
Word Blanks
what to do please help
Ogundele Olumide
@Lumexralph
Mar 05 2017 07:55
@prashantgaurav36 :point_up: March 5, 2017 8:49 AM
eliecerthoms
@eliecerthoms
Mar 05 2017 07:55
@prashantgaurav36 send what you have, mate
@prashantgaurav36 maybe someone will help.
Prashant Gaurav
@prashantgaurav36
Mar 05 2017 07:58
@eliecerthoms in javascript there is a challenge called Word Blanks
eliecerthoms
@eliecerthoms
Mar 05 2017 08:00
@prashantgaurav36 Well, first you gotta know what you don't know
Ogundele Olumide
@Lumexralph
Mar 05 2017 08:00
@prashantgaurav36 i already gave you an hint
ESLMiguel
@ESLMiguel
Mar 05 2017 08:01
anyone else had an issue with cloud9 where the page just keeps loading (and never finishes)?
eliecerthoms
@eliecerthoms
Mar 05 2017 08:01
so try your hardest, then when you have a perceived solution, that is not working...
you come back here
Prashant Gaurav
@prashantgaurav36
Mar 05 2017 08:01
ok sir
eliecerthoms
@eliecerthoms
Mar 05 2017 08:02
@ESLMiguel Maybe an infinite loop in your node implementation?
check what's happening there, that's what comes to my mind
ESLMiguel
@ESLMiguel
Mar 05 2017 08:06
@eliecerthoms all of my workspaces were doing the same thing
eliecerthoms
@eliecerthoms
Mar 05 2017 08:07
@ESLMiguel has to be an error with c9 then, try doing the challenges in your pc. If you have windows install Cmder (with all the unix options) and Git for Windows
And It's better that way because you'll have a local dev environment that you can tweak and use offline
(and way faster in my case)
ESLMiguel
@ESLMiguel
Mar 05 2017 08:09
yeah i want to set up my own dev environment
downloaded brackets and atom
still a work in progress lol
tareq4
@tareq4
Mar 05 2017 08:14
Hi guys... what is the diffrent between { if } and { else if } ?
Ogundele Olumide
@Lumexralph
Mar 05 2017 08:16
@tareq4 if if comes out false it runs the else if
Alo
@aloRanking
Mar 05 2017 08:18
morning...pls help me with this binary Agent, all im gettin are chineese characters
Elazar Fein
@SkySibe
Mar 05 2017 08:19
I on the Condense arrays with reduce challenge
I don't know how to slove this

var array = [4,5,6,7,8];
var singleVal = 0;

var singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal + currentVal;
}, 0);

singleVal = array;

Use the reduce method to sum all the values in array and assign it to singleVal.
tareq4
@tareq4
Mar 05 2017 08:21
var code = "formatted";
ow ok @Lumexralph ... so you use else and if in the same time.. if if was false
@Lumexralph thx
CamperBot
@camperbot
Mar 05 2017 08:23
tareq4 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1257 | @lumexralph |http://www.freecodecamp.com/lumexralph
Manish Giri
@Manish-Giri
Mar 05 2017 08:23
@SkySibe singleVal = array;
why is this line still there?
Ogundele Olumide
@Lumexralph
Mar 05 2017 08:43
@SkySibe remove this var singleVal = 0; because you're using that variable name below to hold the reduced value of the array and singleVal = array; assigns the array again to singleVal changing the initial value which is correct to array reference
@Manish-Giri hallo!
Karthik Nallasivan
@furball514
Mar 05 2017 08:46
http://codepen.io/furball/pen/LWNMwr why isn't my axios get requests working
r2d2
@UsamaHameed
Mar 05 2017 09:06
Can someone help with react?
Manuel Micu
@manu-4216
Mar 05 2017 09:06

@furball514 you should use Axios on componentDidMount. And spead your 2 variables with .data

And pls tidy your JS (there is a button in the corner to do it), it's really difficult to read without clean indentation

Also I see you didn't use React concept of Components. That's really core to React way. I suggest do this tutorial, really useful: https://reacttraining.com/online/react-fundamentals

OGKevin
@OGKevin
Mar 05 2017 09:14
pff is someone willing to fix a 20k JSON for me :(
Manish Giri
@Manish-Giri
Mar 05 2017 09:16
@Lumexralph hola :wave:
Devon
@crzyballr
Mar 05 2017 09:24
hey guys, can I develop an app / website just using Java and Bootstrap? or do I need to know html and css
Ogundele Olumide
@Lumexralph
Mar 05 2017 09:26
@crzyballr html is the skeleton of the webpage, css is the flesh of the web page......Bootstrap is a framework built on CSS
@Manish-Giri how're you?
juw3lstar
@juw3lstar
Mar 05 2017 09:31
I cant seem to get behind why it is not filtering the arguments at the place [i]. It just returns the initial array...
function destroyer(arr) {
  // Remove all the values
  function filterino(value) {
    return value !== arguments[i];
  }
  var newArr = arr;
  for(var i=1;i<arguments.length-1; i++) {
    newArr = newArr.filter(filterino);

  }
  return newArr;
}
destroyer([3, 5, 1, 2, 2], 2, 3, 5);
Manuel Micu
@manu-4216
Mar 05 2017 09:32

@crzyballr Java can potentially be used for backend only. But it's not a easy language, compared to JS. Just make yourself a service and learn JS. It's easy and good for front and backend (nodeJS).

Here at FCC we are using a full JS (javascript) approach: nodeJS for backend! and JS for frontend logic.

So just do the FCC roadmap and you're goo to make any app/website using the right aproach and tools

elad ben aderet
@eladonline
Mar 05 2017 09:33
i have completed the twitch challenge your more then welcome to vhttps://codepen.io/eladonline/full/bqpJvy/
OGKevin
@OGKevin
Mar 05 2017 09:36
i need some help with weather citty list JSON
its not formatted right, according to validators there is no EOF and i cant seem to fix to
it
René
@RenevandenHeuvel
Mar 05 2017 09:40
Anyone nows the answer to challenge "Finding a Remainder in JavaScript"?
Manuel Micu
@manu-4216
Mar 05 2017 09:40
@RenevandenHeuvel @OGKevin you need to provide the code (link)
OGKevin
@OGKevin
Mar 05 2017 09:41
@manu-4216 bruh, its a 20k liner JSON that has errors no way I'm pasting that http://bulk.openweathermap.org/sample/city.list.json.gz
according to validators there is no EOF
so like JSON needs a a {all info} or [all info] style
but i cant seem to fix it
Manuel Micu
@manu-4216
Mar 05 2017 09:44
@OGKevin For which challenge is this for?
OGKevin
@OGKevin
Mar 05 2017 09:45
@manu-4216 😑 show local weather ? :P
i want the user to be able to specify in which country he wants to see the weather with means i need this JSON, but these idiots didnt format it right so now i have to fix it but its a 20k liner and smimply adding [ ] at the beginning and end doesnt work
Manuel Micu
@manu-4216
Mar 05 2017 09:50
Not sure if you need that. Did you do the api call for getting your wether info for one location?
Veronika Krukovich
@VKrukovich
Mar 05 2017 09:53

```function chetn(arr, ch) {
var out = 0;

arrOut = [];
for (var n = 0; n < 10000; n++) {
    arrOut[n] = arr[n];
}

for (var i = 0; i < 10000; i++) {
    if (arr[i]!== 0 && arr[i]% ch=== 0) {
         out = out+1;

    }
    if
    (arr[i]!== 0 && arr[i]% ch!== 0) {
         out = out+1;
    }
}

return out;
}
console.log(chetn(arrLab4numb, 2));

how to count number of even elements separate from number of odd elements??? now it counts all sum even+odd
OGKevin
@OGKevin
Mar 05 2017 09:54
@manu-4216 yes i need it.... user inputs his/hers country name, i pull the info from this JSON.. changes the id in the api call, plus the info from that specific location...
thx way
anywaty
Ghulam Shabir
@ghulamshabir
Mar 05 2017 09:54
@juw3lstar arguments[i] will be the same as value because filterino has it's own instance of arguments object
OGKevin
@OGKevin
Mar 05 2017 09:55
@ghulamshabir is there a way to auto fix a huge JSON w an syntax error in it ?
the city list JSON form openweather is wrongly formatted and therefore unusable
Ghulam Shabir
@ghulamshabir
Mar 05 2017 09:56
@OGKevin yeah search for json lint
Omer Iqbal
@omerbutt
Mar 05 2017 09:57

Need help regarding Confirm the Ending

My Code:


function confirmEnding(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor

  var splitted = str.split(" ");

  if (splitted.length > 1 ){

    for (var i = 0 ; i < splitted.length ; i++) {
      if ((splitted[i].length - 1) == target) {
        return true;
      }

      else {
        return false;
      }
    }

  }

  else if (splitted.length == 1) {
    splitted = splitted.join(" ");


    for (var j = 0 ; j < splitted.length; j++){
      if (splitted.substr(-1,1) == target) {
        return true;
      }

      else {
        return false;
      }
    }

  }


}

confirmEnding("Bastian", "n");

My code is not working for only below two:

confirmEnding("He has to give me a new name", "name") should return true.

&

confirmEnding("Open sesame", "same") should return true.

Manuel Micu
@manu-4216
Mar 05 2017 09:57
@RenevandenHeuvel What do you have till now?
Pieter Stokkink
@forkerino
Mar 05 2017 09:57
Hello
OGKevin
@OGKevin
Mar 05 2017 09:57
@ghulamshabir yea ive used that one but its a 20K line JSON and it spits out EOF error wich is hard to fix in this file
@forkerino :wave:
Ghulam Shabir
@ghulamshabir
Mar 05 2017 09:58
@forkerino hi
OGKevin
@OGKevin
Mar 05 2017 09:58
@forkerino do you feel like helping me fix a 20k liner JSON ? 😔
Pieter Stokkink
@forkerino
Mar 05 2017 09:58
ah, man, I just woke up.
OGKevin
@OGKevin
Mar 05 2017 09:58
@forkerino haha thats why i asked :P
i know its a shitty task
makes u wake up xD
Pieter Stokkink
@forkerino
Mar 05 2017 09:59
@OGKevin I'll pass
Manuel Micu
@manu-4216
Mar 05 2017 09:59
@OGKevin You file is not json. You'd have to format it first, at least by putting comas after each line, and encapsulating it by [...].
Ghulam Shabir
@ghulamshabir
Mar 05 2017 09:59
@omerbutt your loop only runs for once
OGKevin
@OGKevin
Mar 05 2017 10:00
@forkerino hehe i understand
Omer Iqbal
@omerbutt
Mar 05 2017 10:01
@ghulamshabir The loop in the first part ?
Eric Ngu
@ericngu
Mar 05 2017 10:01
Hello guys, can someone explain what does the underscore in str.replace(/[\_W]/g, '') do?
Manuel Micu
@manu-4216
Mar 05 2017 10:01

@OGKevin Anyway, using a json file like that is not the way to go. You need to use an api call to get the data that you need only.

And not have a data dump offline...

OGKevin
@OGKevin
Mar 05 2017 10:01
@manu-4216 its not my JSON its from OpenWeather poorly formated JSON
@manu-4216 ill use the api ofc... but i need this JSON for when the user specifies his/hers location
Manuel Micu
@manu-4216
Mar 05 2017 10:03
@OGKevin WHy not just query the api with that user specified location? I'm sure there is a way for that
OGKevin
@OGKevin
Mar 05 2017 10:03
@manu-4216 i cant load this JSON online neither bc that version is wrongly formatted so i need to have the fixed and saved offline
juw3lstar
@juw3lstar
Mar 05 2017 10:03
@ghulamshabir makes sense, thank you
CamperBot
@camperbot
Mar 05 2017 10:03
juw3lstar sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1895 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Pieter Stokkink
@forkerino
Mar 05 2017 10:04
@OGKevin Why don't you just make a query with the city name? http://openweathermap.org/current#name
OGKevin
@OGKevin
Mar 05 2017 10:04
@manu-4216 That is exactly what I'm going to do.... and ill nee to extract the information for this JSON... country id,, lon lat ect ect
Omer Iqbal
@omerbutt
Mar 05 2017 10:04
@ghulamshabir Oh, If I'm not wrong, I'd have to run one more for loop since I'm splitting it into sub-arrays, right?
Ghulam Shabir
@ghulamshabir
Mar 05 2017 10:04
@omerbutt both loops, returns in if and else parts will make the loop stop at first iteration but you want to loop through the array and also you want to split the str into it's characters ? you split the str into array which has only one element with the str itself
OGKevin
@OGKevin
Mar 05 2017 10:05
@forkerino bc i want to do it the recommended way :D We recommend to call API by city ID to get unambiguous result for your city.
xD and those id's are stored in that JSON
so if user type Colombia ill get the id from this JSON for example
René
@RenevandenHeuvel
Mar 05 2017 10:05
@manu-4216 var remainder; 11 % 3 = 1. I also tried other codes wich didn't work. This code also doesn't work, because 4 * 3 = 12. Remainder can't be -1. And I can't find the answer extrapolating the examples,.
Manuel Micu
@manu-4216
Mar 05 2017 10:07
@RenevandenHeuvel you need on the second line to use your declared variable 'reminder' . Did you try to give it the result of 11 % 3 ? followed by ;
juw3lstar
@juw3lstar
Mar 05 2017 10:07
@ghulamshabir thank you
CamperBot
@camperbot
Mar 05 2017 10:07
juw3lstar sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:warning: juw3lstar already gave ghulamshabir points
Ghulam Shabir
@ghulamshabir
Mar 05 2017 10:07
@omerbutt actually you don't have to split the str, all you need to use subtring on str to get a substring from back of it which equals in length to target and then compare them
Manuel Micu
@manu-4216
Mar 05 2017 10:08
ALso you can create a new line in this editor with SHIFT + ENTER
@RenevandenHeuvel
Pieter Stokkink
@forkerino
Mar 05 2017 10:09
@OGKevin that sounds like a transfer of their problem with finding the right city to you having that same problem. :) I downloaded their JSON and it looks good here. Haven't checked all of them, but what error are you getting?
Omer Iqbal
@omerbutt
Mar 05 2017 10:09
@ghulamshabir Hmmm, okay, leme read about sub-string more and re-write the code :))
Thank you ~ In-case It doesn't get solved, will bother again xD
CamperBot
@camperbot
Mar 05 2017 10:09
omerbutt sends brownie points to @ghulamshabir :sparkles: :thumbsup: :sparkles:
:star2: 1896 | @ghulamshabir |http://www.freecodecamp.com/ghulamshabir
Ghulam Shabir
@ghulamshabir
Mar 05 2017 10:09
@omerbutt np
Pieter Stokkink
@forkerino
Mar 05 2017 10:10
yes
OGKevin
@OGKevin
Mar 05 2017 10:11
whut i used it to get data[0].name i got undefined so i threw it in a validator it gave me EOF error
hmm
Pieter Stokkink
@forkerino
Mar 05 2017 10:12
@OGKevin well it is not an array. It is just a list of separate objects.
@OGKevin btw how are you going to store all this data?
and serve it up?
OGKevin
@OGKevin
Mar 05 2017 10:12
@forkerino true but then how am i suppose to get in the first object ?
Pieter Stokkink
@forkerino
Mar 05 2017 10:13
you have to transform the data.
René
@RenevandenHeuvel
Mar 05 2017 10:13
@manu-4216 I tried this code as well. var remainder; 11 % 3;
Do you know the answer challenge?
Pieter Stokkink
@forkerino
Mar 05 2017 10:13
@OGKevin making an array would be easiest.
OGKevin
@OGKevin
Mar 05 2017 10:13
@forkerino cloud somewhere
Pieter Stokkink
@forkerino
Mar 05 2017 10:13
put [] around it and enter a , at the end of each line.
search }} and replace with }},
OGKevin
@OGKevin
Mar 05 2017 10:13
@forkerino yea thats what I'm currently doing :P
@forkerino ive done that but atom cant handle it
:(
to much for atom to handle
Pieter Stokkink
@forkerino
Mar 05 2017 10:14
@OGKevin took 1 second in sublime
here I am helping you with your JSON. :|
OGKevin
@OGKevin
Mar 05 2017 10:15
@forkerino xd hahaha :heart:
hold up lemme download subliome
Manuel Micu
@manu-4216
Mar 05 2017 10:16
@OGKevin notepad is also fine, works well for me :)
Pieter Stokkink
@forkerino
Mar 05 2017 10:16
@OGKevin it'll be slow, though for the user, because you would have to look through a 20mb file everytime someone searches, which means you'd have to download it somehow. Not sure how to do this in codepen...
OGKevin
@OGKevin
Mar 05 2017 10:17
@forkerino i don't use code pen bro, don't like it that much i prefer to code it locally git it, push to github and use surge or gitpages
Pieter Stokkink
@forkerino
Mar 05 2017 10:18
@OGKevin ok, that can work.
OGKevin
@OGKevin
Mar 05 2017 10:18
i really do enjoy atom tho shame if sublime works better, brackets cant even open the file xD
Pieter Stokkink
@forkerino
Mar 05 2017 10:18
I've said goodbye to codepen as well
:)
OGKevin
@OGKevin
Mar 05 2017 10:18
@forkerino :fist:
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:19
```var myArr = [31, 32, 100, 77];
function myRange(arr, n, k) {
var out = 0,
for (var i = 0; i < myArr.length; i++) {
if (arr[i] >= n && arr[i] <= k) {
out = out + arr[i];
}
}
return out;
}
console.log(myRange(myArr, 31, 67));
what is wrong with for? it writes missing variable name
OGKevin
@OGKevin
Mar 05 2017 10:20
@forkerino whats the shortcut to replace in sublime do you know it out of your head ? :D
Pieter Stokkink
@forkerino
Mar 05 2017 10:20
@OGKevin control H
i think
OGKevin
@OGKevin
Mar 05 2017 10:21
dude how the hell can sublime do this in 1 sec and atom just crashes ....
and i real do like atom :(
Pieter Stokkink
@forkerino
Mar 05 2017 10:21
I don't know. Do you have many plugins in atom?
They might suck up some memory
But really it shouldn't be a problem. I think.
OGKevin
@OGKevin
Mar 05 2017 10:22
i do have a few, git, beautify, markdown viewer, some snippets,
Pieter Stokkink
@forkerino
Mar 05 2017 10:22
Unless you are working on an ancient computer
OGKevin
@OGKevin
Mar 05 2017 10:23
@forkerino lmao. nah macbook pro mid 2014 i think
Pieter Stokkink
@forkerino
Mar 05 2017 10:23
no clue
OGKevin
@OGKevin
Mar 05 2017 10:23
for example if i open jquery min js in atom it crashes as well ...
Pieter Stokkink
@forkerino
Mar 05 2017 10:24
really!?!?!
OGKevin
@OGKevin
Mar 05 2017 10:24
yea so i cant accidently open it or else ill be screwed
how do you open a project in sublime tho
ah nvm
Pieter Stokkink
@forkerino
Mar 05 2017 10:27
@OGKevin atom crashes on my computer too.
OGKevin
@OGKevin
Mar 05 2017 10:28
@forkerino when u do what ?
Pieter Stokkink
@forkerino
Mar 05 2017 10:28
when I try to do stuff with this json
clean install
on a laptop with 8gb ram
few other things running
OGKevin
@OGKevin
Mar 05 2017 10:29
lmao shame 😔 does sublime also have plugins like atom
git and stuff like that
Pieter Stokkink
@forkerino
Mar 05 2017 10:29
@OGKevin tons
OGKevin
@OGKevin
Mar 05 2017 10:29
guess ill have to move to sublime then
Pieter Stokkink
@forkerino
Mar 05 2017 10:30
@OGKevin you'll have to install the package manager and then you can find all of them inside Sublime
* Package Control
OGKevin
@OGKevin
Mar 05 2017 10:33
ill go ahead and do that, ive managed to do []begining and end and replaced }} w }}, and ofc removed the last , but still getting undefined so ill throw it in a validator again
Pieter Stokkink
@forkerino
Mar 05 2017 10:34
@VKrukovich what are you trying to do?
@VKrukovich inside your for, you probably need to use i<arr.length
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:35
@forkerino yeah i have fix it
Pieter Stokkink
@forkerino
Mar 05 2017 10:35
:+1:
OGKevin
@OGKevin
Mar 05 2017 10:39
@forkerino u have to buy sublime i see ?
Pieter Stokkink
@forkerino
Mar 05 2017 10:40

@OGKevin

Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. There is no enforced time limit for the evaluation.

I didn't pay them yet. Will do when I start earning money as a dev. :)
OGKevin
@OGKevin
Mar 05 2017 10:42
same i guess :P, the JSON still doesnt work tho did u get it to work ? by putting [] at and end ? and them commas ?
Pieter Stokkink
@forkerino
Mar 05 2017 10:42
I didn't use it. So not sure. But this is where I will stop diving into JSON. :)
OGKevin
@OGKevin
Mar 05 2017 10:43
@forkerino lol cool, i was about to post a gist of it hehe
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:44

@forkerino i have made function for arr
var myArr = [31, 32, 100, 77];
function myRange(arr, n, k) {
var out = 0;
for (var i = 0; i < arr.length; i++) {
if (arr[i] >= n && arr[i] <= k) {
out = out + arr[i];
}
}
return out;
}
console.log(myRange(myArr, 31, 67));

and it works correctly, now im trying to make it work with arr in separate linked js file but it console.log to me 0 and i know the right answer is sum: 184187 i cant understand why it doenst work
```
function range(arr, n, k) {
var out = 0;
arrOut = [];
for (var n = 0; n < 10000; n++) {
arrOut[n] = arr[n];
}

for (var i = 0; i < 10000; i++) {
    if (arr[i] >= n && arr[i] <= k) {
     out = out + arr[i];
    }
}
return out;

}
console.log(range(arrLab4numb, 31, 67));

Pieter Stokkink
@forkerino
Mar 05 2017 10:48
@VKrukovich well, you cannot just assume js knows how to get stuff from another file. You'd have to use an ES6 module or CommonJS require or something.
to import the array
oh wait.
what do you mean by linked js file
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:50
@forkerino too complicated i was told that it will see my array
Pieter Stokkink
@forkerino
Mar 05 2017 10:50
?
how did you link it?
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:51
@forkerino i mean that my array is in separate js file
Pieter Stokkink
@forkerino
Mar 05 2017 10:51
yes, so how did you link the files?
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:52
@forkerino i linked it in html
@forkerino
```<script src="Lab.js"></script>
<script src="index.js"></script>
i write in index.js
Pieter Stokkink
@forkerino
Mar 05 2017 10:55
@VKrukovich is the arrLab4numb array in the global scope of Lab.js?
Veronika Krukovich
@VKrukovich
Mar 05 2017 10:55
@forkerino yeah
Clip2net_170305135650.png
@forkerino i console.log (arrLab4numb)
Pieter Stokkink
@forkerino
Mar 05 2017 10:58
@VKrukovich I see the problem. You shouldn't use n in your first loop, because it overwrites the function parameter.
Sorry, I missed the first loop, because I thought the bottom code was similar to the top code.
So basically you are looking for numbers bigger than 10000
in arrLab4numb
use another iterator and you'll be fine.
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:04
@forkerino !!!!!!!!!!!!) it counts without n in first loop, do you know what for we overwrites the function parameter? basically im looking for sum numbers that are >=31 and <=67, and 10000 is length of my arrLab4numb
Pieter Stokkink
@forkerino
Mar 05 2017 11:06
I don't understand the question.
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:07
Clip2net_170305140630.png
@forkerino do you know russian?
Pieter Stokkink
@forkerino
Mar 05 2017 11:07
if you use for (var n = 0; the function parameter n will be overwritten. Use for (var i = 0; (and change the other ones too. Or don't use the first loop at all, because you don't need it.
no russian, sorry
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:08
@forkerino ок thank you
CamperBot
@camperbot
Mar 05 2017 11:08
vkrukovich sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1365 | @forkerino |http://www.freecodecamp.com/forkerino
WiseKodama
@WiseKodama
Mar 05 2017 11:08
Hello everyone, hope you are having a wonderful sunday.
Can someone tell me why my timer doesn't display numbers bellow 0:10?
Nvm... stupid spelling error :)
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:20

@forkerino i must use that loop to make safe copy of arr of arrLab4numb
arrOut = []; for (var n = 0; n < 10000; n++) { arrOut[n] = arr[n]; } but how i can count if the function parameter n will be overwritten and with this loop my next loop doesnt work((((((((((((( i have understood the problem but dont see how to go out of it

for (var i = 0; i < 10000; i++) {
if (arr[i] >= n && arr[i] <= k) {
out = out + arr[i];
}
}
return out;
}

Timothy Lehner
@TimLehner
Mar 05 2017 11:21
@WiseKodama That's really great!!!
OGKevin
@OGKevin
Mar 05 2017 11:21

ok why is this happening.

[{
  "base": "stations",
  "clouds": {
    "all": 90
  },
  "cod": 200,
  "coord": {
    "lat": 51.51,
    "lon": -0.13
  },
  "dt": 1485789600,
  "id": 2643743,
  "main": {
    "humidity": 81,
    "pressure": 1012,
    "temp": 280.32,
    "temp_max": 281.15,
    "temp_min": 279.15
  },
  "name": "London",
  "sys": {
    "country": "GB",
    "id": 5091,
    "message": 0.0103,
    "sunrise": 1485762037,
    "sunset": 1485794875,
    "type": 1
  },
  "visibility": 10000,
  "weather": [
    {
      "description": "light intensity drizzle",
      "icon": "09d",
      "id": 300,
      "main": "Drizzle"
    }
  ],
  "wind": {
    "deg": 80,
    "speed": 4.1
  }
}]
$.ajax({
  url: './test.json',
  async : false
})
.done(function(data) {
   console.log(data[0]);
  console.log("success");
})
.fail(function() {
  console.log("error");
})
.always(function() {
  console.log("complete");
});

log outputs [ 😑

Timothy Lehner
@TimLehner
Mar 05 2017 11:21
@WiseKodama Mine so far :( http://codepen.io/TimLehner/pen/vxKdRw
OGKevin
@OGKevin
Mar 05 2017 11:21
log data outputs the entire thing, and data.base is undefined
CamperBot
@camperbot
Mar 05 2017 11:21
Archives for HelpJavaScript
Timothy Lehner
@TimLehner
Mar 05 2017 11:23
@OGKevin thats a head scratcher.. is the response definitely what you posted?
WiseKodama
@WiseKodama
Mar 05 2017 11:24
@TimLehner It's coming along! Once you curve the edges of the buttons and have a nice gradient background it will be awesome! Good work!
Timothy Lehner
@TimLehner
Mar 05 2017 11:24
@WiseKodama At the moment only the buttons for the timer settings are really as the should be. The other buttons and input for displaying time left is gonna go, but I was just getting all the functionality working first
Dan Couper
@DanCouper
Mar 05 2017 11:25
@OGKevin data[0].base, it's an object in an array
OGKevin
@OGKevin
Mar 05 2017 11:25
@TimLehner yea ive been trying for hours
ill make screenshots if you like ?
Dan Couper
@DanCouper
Mar 05 2017 11:25
Not data.base, that isn't a thing
Timothy Lehner
@TimLehner
Mar 05 2017 11:25
@DanCouper Ahh yeah thats it, in the code posted he did correctly log data[0]
WiseKodama
@WiseKodama
Mar 05 2017 11:25
@TimLehner give me a link when you are done, I would love to see it!
OGKevin
@OGKevin
Mar 05 2017 11:25
@DanCouper then how I'm confused now then
Timothy Lehner
@TimLehner
Mar 05 2017 11:26
@DanCouper Your response is [{}] so that means its an array of objects
Dan Couper
@DanCouper
Mar 05 2017 11:26
@OGKevin The thing you posted is an array with an object in
What @TimLehner just said
OGKevin
@OGKevin
Mar 05 2017 11:27

yes

so ill need to access the first value of the array w [0]

wich is the first object
Timothy Lehner
@TimLehner
Mar 05 2017 11:27
you can do data.base only if the response is of the form {} note the lack of []
OGKevin
@OGKevin
Mar 05 2017 11:28
i removed the [] and I'm still getting undefined when i log data.base
Timothy Lehner
@TimLehner
Mar 05 2017 11:28
@OGKevin Then anything thats part of that object you access as follows data[0].base, or data[0].weather[0].main
Dan Couper
@DanCouper
Mar 05 2017 11:28
So data[0].base. data.base would be you looking for a key called base in an array called data
Which makes no sense
Timothy Lehner
@TimLehner
Mar 05 2017 11:28
no you DEFINITELY need the []
Pieter Stokkink
@forkerino
Mar 05 2017 11:28
@VKrukovich something like this?
function range(arr, n, k) {
var out = 0;
arrOut = arr.slice(); // easiest way to make a copy. But I don't really understand why you would need it, you don't do anything with it. 

for (var i = 0; i < arr.length; i++) { // use arr.length, hardcoding a length can be problematic when data changes.
    if (arr[i] >= n && arr[i] <= k) {
     out = out + arr[i];
    }
}
return out;
}
Timothy Lehner
@TimLehner
Mar 05 2017 11:28
if its json and starts [] then you need to access it as an array element
OGKevin
@OGKevin
Mar 05 2017 11:29
@DanCouper the array called data is the json i loaded ?
@TimLehner yes well is that not like this ?data[i].prop
Timothy Lehner
@TimLehner
Mar 05 2017 11:29
yes exactly
OGKevin
@OGKevin
Mar 05 2017 11:30
@TimLehner well its not working ... i get undefined
Timothy Lehner
@TimLehner
Mar 05 2017 11:30
you mentioned data.base earlier, which is undefined
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:30
@forkerino yeah that right! only the teacher made copy with
```
arrOut = [];
for (var n = 0; n < 10000; n++) {
arrOut[n] = arr[n];
}
Timothy Lehner
@TimLehner
Mar 05 2017 11:30
console.log(data[0]) outputs what?
OGKevin
@OGKevin
Mar 05 2017 11:30
@TimLehner [ is the output of data[0]
Timothy Lehner
@TimLehner
Mar 05 2017 11:31
and you're sure the server is responding correctly?
what does console.log(JSON.stringify(data)) output
OGKevin
@OGKevin
Mar 05 2017 11:31

its local testing? what u mean with server responding correctly ?

where should i put that log ?

Timothy Lehner
@TimLehner
Mar 05 2017 11:32
are you connecting to an external api or one you made yourself?
OGKevin
@OGKevin
Mar 05 2017 11:32
@TimLehner one i made my self
the JSON is stored on my hdd
Dan Couper
@DanCouper
Mar 05 2017 11:32
Put the log in the same place
As the one currently there, the bit where you get the data
Omer Iqbal
@omerbutt
Mar 05 2017 11:33

Need help regarding Mutations

My code:


function mutation(arr) {


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

    else {
      return false;
    }
  }


}

mutation(["hello", "hey"]);

Why It is not returning false for ["hello", "hey"]?

Veronika Krukovich
@VKrukovich
Mar 05 2017 11:33
@forkerino and it works without that copy arr that i must do! it console.log right unswer
OGKevin
@OGKevin
Mar 05 2017 11:33
@DanCouper @TimLehner the output
"[{\n  \"base\": \"stations\",\n  \"clouds\": {\n    \"all\": 90\n  },\n  \"cod\": 200,\n  \"coord\": {\n    \"lat\": 51.51,\n    \"lon\": -0.13\n  },\n  \"dt\": 1485789600,\n  \"id\": 2643743,\n  \"main\": {\n    \"humidity\": 81,\n    \"pressure\": 1012,\n    \"temp\": 280.32,\n    \"temp_max\": 281.15,\n    \"temp_min\": 279.15\n  },\n  \"name\": \"London\",\n  \"sys\": {\n    \"country\": \"GB\",\n    \"id\": 5091,\n    \"message\": 0.0103,\n    \"sunrise\": 1485762037,\n    \"sunset\": 1485794875,\n    \"type\": 1\n  },\n  \"visibility\": 10000,\n  \"weather\": [\n    {\n      \"description\": \"light intensity drizzle\",\n      \"icon\": \"09d\",\n      \"id\": 300,\n      \"main\": \"Drizzle\"\n    }\n  ],\n  \"wind\": {\n    \"deg\": 80,\n    \"speed\": 4.1\n  }\n}]"
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:34
Clip2net_170305143216.png
OGKevin
@OGKevin
Mar 05 2017 11:34
wich is the entire JSON
Shaun
@ShaunBastin
Mar 05 2017 11:34
Has anyone done the word blanks JavaScript exercise? I don't understand the question and so can't work out what the answer is.
Timothy Lehner
@TimLehner
Mar 05 2017 11:34
@omerbutt you are testing if array element 1 ("hey") contains, in that character array, "hello". Which is non-sensical
Pieter Stokkink
@forkerino
Mar 05 2017 11:34
@VKrukovich ok, well the n inside that loop overwrites the n in the function declaration. So there's a problem.
You can change that first loop to :
arrOut = [];
for (var m = 0; m < 10000; m++) {
arrOut[m] = arr[m];
}
using m instead of n
Dan Couper
@DanCouper
Mar 05 2017 11:35
@OGKevin Right, it's working fine. You actually need to parse the JSON though
Omer Iqbal
@omerbutt
Mar 05 2017 11:35

@TimLehner What about this?


function mutation(arr) {


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

    else {
      return false;
    }
  }


}

mutation(["hello", "hey"]);

replaced the positions.

Timothy Lehner
@TimLehner
Mar 05 2017 11:35
Instead:
for (i = 0; i < arr.length; i++) {
  if (arr.indexOf(arr[i]) !== -1) {
    // its in the array
  }
}
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:35
@forkerino console.log shows 0
Timothy Lehner
@TimLehner
Mar 05 2017 11:36
@omerbutt Is that the output of console.log(data)?
Ben Carp
@carpben
Mar 05 2017 11:36
Script challenge. I wonder why I'm getting a NaN instead of a number. https://codepen.io/bencarp/full/LWZJyW/
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:36
@forkerino have changed for m
OGKevin
@OGKevin
Mar 05 2017 11:36
@DanCouper i never had to use that method why should i used it now ? like how come ?
Omer Iqbal
@omerbutt
Mar 05 2017 11:37
@TimLehner which output?
Pieter Stokkink
@forkerino
Mar 05 2017 11:37
@VKrukovich show your complete code.
Timothy Lehner
@TimLehner
Mar 05 2017 11:37
@carpben You have two line: return undefined followed by return str; The second line will never be executed because as soon as you say return undefined you exit the function, returning undefined
@omerbutt That question was directed at @OGKevin , sorry
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:38

@forkerino
```/в диапазоне от 31 до 67 сумма: 184187/
function range(arr, n, k) {
var out = 0;
arrOut = [];
for (var m = 0; n < 10000; n++) {
arrOut[m] = arr[m];
}

for (var i = 0; i < 10000; i++) {
    if (arr[i] >= n && arr[i] <= k) {
     out = out + arr[i];
    }
}
return out;

}
console.log(range(arrLab4numb, 31, 67));

Timothy Lehner
@TimLehner
Mar 05 2017 11:38
@omerbutt my other code snippet was for you, did you try that instead?
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:38
Clip2net_170305143738.png
OGKevin
@OGKevin
Mar 05 2017 11:38
@TimLehner yes
Omer Iqbal
@omerbutt
Mar 05 2017 11:38
@TimLehner Yes, looking for It. Thank you :)
In-case, It didn't get solved, will bother you again :]
CamperBot
@camperbot
Mar 05 2017 11:38
omerbutt sends brownie points to @timlehner :sparkles: :thumbsup: :sparkles:
:cookie: 336 | @timlehner |http://www.freecodecamp.com/timlehner
OGKevin
@OGKevin
Mar 05 2017 11:38
and of the one you said JSON.stringify
Timothy Lehner
@TimLehner
Mar 05 2017 11:39
@VKrukovich change arrOut[m] = arr[m]; to arrOut.push(arr[m])
you can't append to arrays like that
Pieter Stokkink
@forkerino
Mar 05 2017 11:40
@VKrukovich I had two small errors in the code you copy pasted. Change all n's to m's (there are two left).
Timothy Lehner
@TimLehner
Mar 05 2017 11:40
@OGKevin So console.log(JSON.stringify(data)) outputs the whole json string? And console.log(data[0]) outputs [
OGKevin
@OGKevin
Mar 05 2017 11:40
@TimLehner yes and log(data) also spits out the whole JSON
Pieter Stokkink
@forkerino
Mar 05 2017 11:40
@TimLehner ehm, yes you can assign to an individual array element like that.
Timothy Lehner
@TimLehner
Mar 05 2017 11:41
@forkerino really? I thought only for {}
Alejandro López Almeida
@raky291
Mar 05 2017 11:41
Hello, someone can help me to convert this from javascript to C# ?
var arr = [];
if (arr[6] === undefined) {
          arr[6] = [];
}
arr[6].push([1, 2]);
Timothy Lehner
@TimLehner
Mar 05 2017 11:41
javascript is mad, what if you try arr[0] = 5; arr[2] = 6; what happens to arr[1]?
OGKevin
@OGKevin
Mar 05 2017 11:41
@raky291 don't think this is the right room to ask that
Pieter Stokkink
@forkerino
Mar 05 2017 11:41
@TimLehner it'll be undefined.
Alejandro López Almeida
@raky291
Mar 05 2017 11:42
@OGKevin D: where can I ask ?
Timothy Lehner
@TimLehner
Mar 05 2017 11:42
@forkerino how does it allocate the memory?
Johnny
@JohnnyBizzel
Mar 05 2017 11:42
@raky291 are you using lists?
OGKevin
@OGKevin
Mar 05 2017 11:42
@DanCouper how should i use parse ?
Timothy Lehner
@TimLehner
Mar 05 2017 11:42
Pieter Stokkink
@forkerino
Mar 05 2017 11:43
@TimLehner I have no idea how it works under the hood. You'll have to find someone else to answer that question.
OGKevin
@OGKevin
Mar 05 2017 11:43
@TimLehner so i should use jsonstring then parse it and then try to pull a prop ?
Timothy Lehner
@TimLehner
Mar 05 2017 11:43
@forkerino Thanks Fair enough, TIL anyways
CamperBot
@camperbot
Mar 05 2017 11:43
timlehner sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1366 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Mar 05 2017 11:43
:smile:
Timothy Lehner
@TimLehner
Mar 05 2017 11:45
@OGKevin try jQuery.parseJSON(data)[0].base;
OGKevin
@OGKevin
Mar 05 2017 11:45
@TimLehner @DanCouper same result
$.ajax({
  url: './test.json',
  async : false
})
.done(function(data) {
    json = JSON.parse(JSON.stringify(data));
   console.log(json[0]);
   // console.log(JSON.stringify(data));
  console.log("success");
})
.fail(function() {
  console.log("error");
})
.always(function() {
  console.log("complete");
});
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:45
@forkerino ahaha you are good bug system, great thanks now it works, so every time i should use new variable for that copy loop
CamperBot
@camperbot
Mar 05 2017 11:45
vkrukovich sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:warning: vkrukovich already gave forkerino points
Alejandro López Almeida
@raky291
Mar 05 2017 11:45
@JohnnyBizzel well... xD this is my actual c# code, but obviously don't work xD
List<int[]> arr = new List<int[]>();
arr[5].add([1,5]);
Timothy Lehner
@TimLehner
Mar 05 2017 11:46
@raky291 why are you mixing STL containers and c-like arrays?
Pieter Stokkink
@forkerino
Mar 05 2017 11:46
@VKrukovich a variable name different from any function parameter, so in your case not n and not k. A side note: in the latest version of javascript there is also another way to declare a variable, with let instead of var, which doesn't have this problem. The variable will then be scoped to that for-loop, and not affect anything outside.
OGKevin
@OGKevin
Mar 05 2017 11:47
@TimLehner that worked but why ? like it doesnt make sense to me
Timothy Lehner
@TimLehner
Mar 05 2017 11:47
@OGKevin the object "data" was just a string, first we parse the string to a json object. Then you can access elements with [i], .prop as appropriate
OGKevin
@OGKevin
Mar 05 2017 11:48
and why is it a string ?
like i never had to use parse before ?
Alejandro López Almeida
@raky291
Mar 05 2017 11:48
@TimLehner I'm trying to convert this from javascript to C#
var arr = [];
if (arr[6] === undefined) {
          arr[6] = [];
}
arr[6].push([1, 2]);
Omer Iqbal
@omerbutt
Mar 05 2017 11:48
@TimLehner What about this one?

function mutation(arr) {

  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  arr[1] = arr[1].split("");

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

    if (arr[0].indexOf(arr[1], 0) !== 1) {
      return true;
    }

    else {
      return false;
    }
  }


}

mutation(["hello", "hey"]);
Veronika Krukovich
@VKrukovich
Mar 05 2017 11:48
@forkerino now it is clear for me!)
OGKevin
@OGKevin
Mar 05 2017 11:48
so thats why I'm a little confused
Dan Couper
@DanCouper
Mar 05 2017 11:48
@OGKevin just use parse. Parse is to take JSON and convert to use in JS. Stringify is for going in the other direction. Also could use getJSON instead of .ajax to check, it automatically takes JSON and gives you Is if it can. I'm on a phone atm so not best thing to check on, but I think you're missing options here from the jQuery Ajax API.
WiseKodama
@WiseKodama
Mar 05 2017 11:49
Can anyone tell me if the Pomodoro clock should just keep going? Or stop after the one run of work/break?
Johnny
@JohnnyBizzel
Mar 05 2017 11:49
@raky291 is the array integers or strings?
Pieter Stokkink
@forkerino
Mar 05 2017 11:49
@VKrukovich good! Glad I could help.
Alejandro López Almeida
@raky291
Mar 05 2017 11:49
@JohnnyBizzel integers
Timothy Lehner
@TimLehner
Mar 05 2017 11:50
@OGKevin depends how the backend is setup to serve the JSON. Are you setting headers with application/json as necessary?
Pieter Stokkink
@forkerino
Mar 05 2017 11:50
@WiseKodama if there is noone stopping the clock, it should just cycle between the two.
OGKevin
@OGKevin
Mar 05 2017 11:51
@DanCouper in my previous projects i just used url, async sometimes and datatype to JSON, but this time when i use dataType ill get error as output bc ajax fails
WiseKodama
@WiseKodama
Mar 05 2017 11:51
@forkerino ok, thanks
CamperBot
@camperbot
Mar 05 2017 11:51
wisekodama sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 1367 | @forkerino |http://www.freecodecamp.com/forkerino
OGKevin
@OGKevin
Mar 05 2017 11:51
@TimLehner hmm not sure what u mean with that headers
for application JSON
Dan Couper
@DanCouper
Mar 05 2017 11:51
@WiseKodama generally it should go for 25 mins, stop for 5, go again for 25. You're not supposed to be able to stop it until there have been 4 runs of 25 min (I would allow it to though, so up to you how strict you want it to be)
WiseKodama
@WiseKodama
Mar 05 2017 11:52
@DanCouper So max 4 cycles or what?
Dan Couper
@DanCouper
Mar 05 2017 11:53
@OGKevin you're literally just getting a local file here right?
OGKevin
@OGKevin
Mar 05 2017 11:53
@DanCouper yes
Johnny
@JohnnyBizzel
Mar 05 2017 11:53

@raky291 no idea if this will work

List<int> arr;

if (!arr[6] == null) arr[6] = new List<int>;
int[] oneTwo = new int[2] {1,2};
arr[6] = oneTwo;

seems like you are mixing datatypes

WiseKodama
@WiseKodama
Mar 05 2017 11:53
Well, I have a pause and a reset button. It's self discipline first anyway
OGKevin
@OGKevin
Mar 05 2017 11:53
and in all those previous projects as well thats why I'm sooo freaking confused on why all of a sudden I'm getting these weird errors @DanCouper
Dan Couper
@DanCouper
Mar 05 2017 11:53
@WiseKodama I think that's the normal Pomodoro setup - 4 cycles then a long break
WiseKodama
@WiseKodama
Mar 05 2017 11:54
Ok, I'll make it run for 4 cycles and then just stop it. The long break can be w/e and the person can just rerun the clock if they want to.
Do people really work in 25 min intervals?
OGKevin
@OGKevin
Mar 05 2017 11:55
@DanCouper parse fixed the issue tho so thx
CamperBot
@camperbot
Mar 05 2017 11:55
ogkevin sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 533 | @dancouper |http://www.freecodecamp.com/dancouper
OGKevin
@OGKevin
Mar 05 2017 11:55
and @TimLehner thx
Timothy Lehner
@TimLehner
Mar 05 2017 11:55
@raky291 I only know c++, but it looks like its similar enough
List<List<int>> myList = new List<List<int>>();
for (int i = 0; i < 7; i++) {
  if (i != 6) {
  myList.add(new List<int> { 0, 0});
  } else {
  myList.add(new List<int> { 1,  2});
  }
}
OGKevin
@OGKevin
Mar 05 2017 11:55
@forkerino finaly this stupid JSON issue is solved xD
Omer Iqbal
@omerbutt
Mar 05 2017 11:56
@TimLehner What about this one?

function mutation(arr) {

  arr[0] = arr[0].toLowerCase();
  arr[1] = arr[1].toLowerCase();
  arr[1] = arr[1].split("");

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

    if (arr[0].indexOf(arr[1], 0) !== 1) {
      return true;
    }

    else {
      return false;
    }
  }


}

mutation(["hello", "hey"]);
Pieter Stokkink
@forkerino
Mar 05 2017 11:56
@OGKevin \o/
Timothy Lehner
@TimLehner
Mar 05 2017 11:57
@omerbutt What are you trying to achieve?
OGKevin
@OGKevin
Mar 05 2017 11:57
@forkerino it has been hours could have been done by now w this weather project 😔
them struggles
Alejandro López Almeida
@raky291
Mar 05 2017 11:57
@JohnnyBizzel sorry don't works D:
OGKevin
@OGKevin
Mar 05 2017 11:57
at leas ive learned something
Johnny
@JohnnyBizzel
Mar 05 2017 11:57
@raky291 Well I tried. :/
Omer Iqbal
@omerbutt
Mar 05 2017 11:58
@TimLehner Same, Why is mutation(["hello", "hey"]); is not returning false.
Timothy Lehner
@TimLehner
Mar 05 2017 11:58
@OGKevin try accessing the same url (even if localhost) using a rest api application like Postman
Daniel M
@danimeko
Mar 05 2017 11:58
i don't know where i get wrong in this code

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  falsyValue = ["false", "null", 0, "", "undefined", "NaN"];
  var newArr = [];
  for(var i=0; i< arr.length; i++){
    if(falsyValue.indexOf(arr[i]) === -1){
    newArr.push(arr[i]);
    }
  }
//  newArr = arr.filter(function(){return falsyValue.indexOf(falsyValue);});
  return newArr;
}

bouncer([7, "ate", "", false, 9]);
Johnny
@JohnnyBizzel
Mar 05 2017 11:58
@omerbutt returning too soon?
if (arr[0].indexOf(arr[1], 0) !== 1) { return true; }
OGKevin
@OGKevin
Mar 05 2017 11:58
@TimLehner hmm ill take a look
Timothy Lehner
@TimLehner
Mar 05 2017 11:59
@omerbutt under what condition should mutation([]) return true?
Johnny
@JohnnyBizzel
Mar 05 2017 11:59
@omerbutt also, where is i used? - so at the moment, the loop does not go anywhere.
Timothy Lehner
@TimLehner
Mar 05 2017 11:59
@omerbutt the way you are using indexOf is wrong, and you're looping but never using i
OGKevin
@OGKevin
Mar 05 2017 12:00
@TimLehner no I'm not :P wrong @ bro
Timothy Lehner
@TimLehner
Mar 05 2017 12:00
ninja
OGKevin
@OGKevin
Mar 05 2017 12:00
haha
Timothy Lehner
@TimLehner
Mar 05 2017 12:00
sorry @OGKevin :P
@raky291 did that c# snippet work?
Omer Iqbal
@omerbutt
Mar 05 2017 12:01

@JohnnyBizzel hmmm, this point looks legit

returning too soon

I just used i in the for loop (to repeat It).

@TimLehner It should return false if the second argument's alphabets hey are not in the first one hello

Mutations

OGKevin
@OGKevin
Mar 05 2017 12:02
@TimLehner np
Timothy Lehner
@TimLehner
Mar 05 2017 12:02
@omerbutt Ahh that challenge is a bit more tricky, if you wanna check if the mutations are in the string you'll have to look at all the possible ways of ordering the string
@omerbutt since you are only interested if one contains the other, perhaps if you sort the string alphabetically first that'll already help alot. Then you still need to look over how you're constructing your loops
Alejandro López Almeida
@raky291
Mar 05 2017 12:04
@TimLehner Sorry, I can't make it work, I have a lot of time without programming in C # :worried:
Omer Iqbal
@omerbutt
Mar 05 2017 12:04
@TimLehner hmm, sorting is a good option. leme try, thanks again :)
CamperBot
@camperbot
Mar 05 2017 12:04
omerbutt sends brownie points to @timlehner :sparkles: :thumbsup: :sparkles:
:warning: omerbutt already gave timlehner points
Timothy Lehner
@TimLehner
Mar 05 2017 12:05
by sort the string alphabetically, I mean such that "Mary" -> "amry" and "Army" -> "amry" and "aRmY" -> "amry"
@raky291 Sorry :( As I said me only c++. Maybe have a look at some c# reference books?
Omer Iqbal
@omerbutt
Mar 05 2017 12:06
@TimLehner Yes, I got this point. Leme try now ^_^
Timothy Lehner
@TimLehner
Mar 05 2017 12:06
@omerbutt Good luck :)
Johnny
@JohnnyBizzel
Mar 05 2017 12:07
@raky291 Try stack overflow
Timothy Lehner
@TimLehner
Mar 05 2017 12:08
@JohnnyBizzel I dunno how stack overflow will respond to a request like "please convert my code from language x to y". That's not really SO's goal
Johnny
@JohnnyBizzel
Mar 05 2017 12:08
@TimLehner Maybe if he posts the C# code and asks what the problem is with it he might get an answer.
I didn't think he explained what the goal was very well.
Alejandro López Almeida
@raky291
Mar 05 2017 12:10
@TimLehner @JohnnyBizzel Thanks for the help :D
CamperBot
@camperbot
Mar 05 2017 12:10
raky291 sends brownie points to @timlehner and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 337 | @timlehner |http://www.freecodecamp.com/timlehner
:star2: 1422 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Johnny
@JohnnyBizzel
Mar 05 2017 12:11
@raky291 Buena suerte hombre ;)
Timothy Lehner
@TimLehner
Mar 05 2017 12:11
@JohnnyBizzel I mean I have no idea what the code is meant to do, I gave a code snippet that does what the code does but I guess it didn't work
OGKevin
@OGKevin
Mar 05 2017 12:16
im sooo sick and tired of this, why when u type it a a text, the input text gets pasted in the url ?
$(function(){


 $("#location").keyup(function(event) {
    /* Act on the event */
     location = $(this).val();
     console.log(location);
});
})

locaiton is an input text type

Johnny
@JohnnyBizzel
Mar 05 2017 12:17
@OGKevin what is location?
Timothy Lehner
@TimLehner
Mar 05 2017 12:17
@OGKevin is the input inside a <form>?
OGKevin
@OGKevin
Mar 05 2017 12:17
@TimLehner no :blush:
Pieter Stokkink
@forkerino
Mar 05 2017 12:18
@JohnnyBizzel :P
Timothy Lehner
@TimLehner
Mar 05 2017 12:18
@OGKevin can I see the codepen?
Javier Pons
@JavierPons
Mar 05 2017 12:18
hi guys again!!
OGKevin
@OGKevin
Mar 05 2017 12:18
@TimLehner gimme a sec
Johnny
@JohnnyBizzel
Mar 05 2017 12:18
it's not the whole code, clearly!! :/
Don't you just hate code snippits??
Timothy Lehner
@TimLehner
Mar 05 2017 12:19
@JohnnyBizzel I beleive the #location refers to an input on the page
but yeah need more context
Javier Pons
@JavierPons
Mar 05 2017 12:19
I have to do this: Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Johnny
@JohnnyBizzel
Mar 05 2017 12:19
@TimLehner I was taking about the variable??
Javier Pons
@JavierPons
Mar 05 2017 12:19
thats my code:

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.length; j++){
(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]]);

Johnny
@JohnnyBizzel
Mar 05 2017 12:19
@JavierPons sounds like :confounded:
Javier Pons
@JavierPons
Mar 05 2017 12:20
@JohnnyBizzel ?
Johnny
@JohnnyBizzel
Mar 05 2017 12:20
@JavierPons * is the multiplication operator
Timothy Lehner
@TimLehner
Mar 05 2017 12:20
@JohnnyBizzel Ahh yes since this is the .keyup() I assume its triggered by an event to do with that input. Then location is set using $(this <- this input).val()
Johnny
@JohnnyBizzel
Mar 05 2017 12:20
@TimLehner I am thinking location is a reserved word but not sure.
as in Window.location?
Javier Pons
@JavierPons
Mar 05 2017 12:21
@JohnnyBizzel I write product * (arr[i][j]); till here I see.
Timothy Lehner
@TimLehner
Mar 05 2017 12:21
@JohnnyBizzel
location = $(this).val();  // Here the location variable is set no problem
Johnny
@JohnnyBizzel
Mar 05 2017 12:21
@JavierPons format code - see camperbot... '''
CamperBot
@camperbot
Mar 05 2017 12:21
:bulb: to format code use backticks! ``` more info
Johnny
@JohnnyBizzel
Mar 05 2017 12:22
Above
Timothy Lehner
@TimLehner
Mar 05 2017 12:22
@camperbot Thanks! What a good bot
CamperBot
@camperbot
Mar 05 2017 12:22
timlehner sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 3066 | @camperbot |http://www.freecodecamp.com/camperbot
Javier Pons
@JavierPons
Mar 05 2017 12:22
@JohnnyBizzel Sorry I dont understand what you mean. Yes, I now * is multiplication operator ...
Johnny
@JohnnyBizzel
Mar 05 2017 12:23
@JavierPons the code you posted does not have any multiply operations
Javier Pons
@JavierPons
Mar 05 2017 12:23
@JohnnyBizzel Yes.
Timothy Lehner
@TimLehner
Mar 05 2017 12:23
@JavierPons in your code:
for (var j = 0; j< arr.length; j++){
(arr[i][j]); // This doesn't actually do anything, It just reads the value from the array to do nothing with it
}
OGKevin
@OGKevin
Mar 05 2017 12:23
@TimLehner it should log the input but it just goes crazy ogkevinweather.surge.sh
Johnny
@JohnnyBizzel
Mar 05 2017 12:24
@JavierPons the product is the result of a multiplication - eg) 2 * 5 = 10
OGKevin
@OGKevin
Mar 05 2017 12:24
that is the link btw
Javier Pons
@JavierPons
Mar 05 2017 12:24
@JohnnyBizzel but I can't understand where I should put it... thats my problem...
Johnny
@JohnnyBizzel
Mar 05 2017 12:25
@JavierPons how would you do it if you had to add the numbers?
Javier Pons
@JavierPons
Mar 05 2017 12:25
@TimLehner I write product * (arr[i][j]); and doesn't work
Johnny
@JohnnyBizzel
Mar 05 2017 12:25
@JavierPons where do you store the result of that calculation?
Javier Pons
@JavierPons
Mar 05 2017 12:25
lets see..
create new variable
Timothy Lehner
@TimLehner
Mar 05 2017 12:27
@JavierPons product *= (arr[i][j]). Otherwise you are only multiplying and not assigning
@OGKevin What if you try to put
event.preventDefault() at the start?
There's some weird event triggering happening on the keyup
Javier Pons
@JavierPons
Mar 05 2017 12:29
@TimLehner It doesn't work.. :worried:
OMAR HEGAZI
@OmarHegazi94
Mar 05 2017 12:29
guyz what's up
Timothy Lehner
@TimLehner
Mar 05 2017 12:29
@JavierPons I recommend you do some reading into declaring and defining variables, assignment operations and equality checking operations
OMAR HEGAZI
@OmarHegazi94
Mar 05 2017 12:29
i have a problem

var count = 0;

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

return count + (count > 0 ? " Bet" : " Hold");
// Only change code above this line
}

Javier Pons
@JavierPons
Mar 05 2017 12:30
@TimLehner :+1:
Timothy Lehner
@TimLehner
Mar 05 2017 12:30
@JavierPons I mean it does what you tell it to, it mutliplies all elements by all elements in the array
OMAR HEGAZI
@OmarHegazi94
Mar 05 2017 12:30
what should i do ?
Javier Pons
@JavierPons
Mar 05 2017 12:30
@TimLehner Now I little lost
Timothy Lehner
@TimLehner
Mar 05 2017 12:31
@OmarHegazi94 You realise your count only ever increases?
@JavierPons what is the challenege?
Johnny
@JohnnyBizzel
Mar 05 2017 12:31
@OmarHegazi94 this is wrong for the high cards count =- 0;
How can you subtract zero anyway??
Javier Pons
@JavierPons
Mar 05 2017 12:31
@TimLehner Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr
Timothy Lehner
@TimLehner
Mar 05 2017 12:32
@JohnnyBizzel @OmarHegazi94 also does =- work? I alway use -=
Johnny
@JohnnyBizzel
Mar 05 2017 12:32
:+1:
@JavierPons does running code on http://pythontutor.com/javascript.html#mode=edit help?
Timothy Lehner
@TimLehner
Mar 05 2017 12:33
@JavierPons so you have a function multiplyAll(arr), that takes {x1, x2, ..., xn} and returns Product_i xi?
OMAR HEGAZI
@OmarHegazi94
Mar 05 2017 12:33
still something wrong
Timothy Lehner
@TimLehner
Mar 05 2017 12:35
@OmarHegazi94 You know the function only ever counts 1 card right?
OMAR HEGAZI
@OmarHegazi94
Mar 05 2017 12:36
@TimLehner meaning
Timothy Lehner
@TimLehner
Mar 05 2017 12:37
@OmarHegazi94 Just checking that's the intended output
@OmarHegazi94 put some console.log("+1/0/-1") like things in the three cases and verify it's outputting as expected?
@OmarHegazi94 If you're using the codepen editor, press f12 to open your browser dev tools and you'll see the full console output
Boram Jeong
@Boram0206
Mar 05 2017 12:38
Hey guys
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:38
@Boram0206 :wave:
Boram Jeong
@Boram0206
Mar 05 2017 12:38
challenges name of Introducing Else If Statements
Timothy Lehner
@TimLehner
Mar 05 2017 12:38
@JavierPons Can you show me where the problem you are trying to solve is defined?
achudoz
@achudoz
Mar 05 2017 12:39
slightly amusing fact for the paranoid:
If you write 444 in reverse roman numerals, it spells IVILCD. You know, kinda like EVIL CD. And 444 is you know, kinda like 666. I believe i discovered a ALMOST satanic aspect of the universe lol :D
Boram Jeong
@Boram0206
Mar 05 2017 12:39
I don't know what's wrong on my code.

function testElseIf(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
testElseIf(7);

OGKevin
@OGKevin
Mar 05 2017 12:39
@TimLehner did you take a look ?
Boram Jeong
@Boram0206
Mar 05 2017 12:39
@HeebieGeeBee Could you lemme know how to solve it
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:39
@achudoz thats some reaching
Timothy Lehner
@TimLehner
Mar 05 2017 12:40
@OGKevin Yes, did you try putting in the preventDefault()?
Javier Pons
@JavierPons
Mar 05 2017 12:40

@TimLehner thanks for your patience. I write now: 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.length; j++){
product= 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]]);

CamperBot
@camperbot
Mar 05 2017 12:40
javierpons sends brownie points to @timlehner :sparkles: :thumbsup: :sparkles:
:cookie: 338 | @timlehner |http://www.freecodecamp.com/timlehner
achudoz
@achudoz
Mar 05 2017 12:40
@HeebieGeeBee it's the little things in life.
OGKevin
@OGKevin
Mar 05 2017 12:40
@TimLehner nope ill give it a try, why are all these errors appearing and never appeared in previous projects 😔
Javier Pons
@JavierPons
Mar 05 2017 12:41
@TimLehner I now Im close, but still I dont get it
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:41
@Boram0206 looks good to me whats not passing?
Boram Jeong
@Boram0206
Mar 05 2017 12:43

@HeebieGeeBee
function testElseIf(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
testElseIf(7);

HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:43
@Boram0206 oh youre missing curly bracket on the end
Timothy Lehner
@TimLehner
Mar 05 2017 12:43
@JavierPons Pm'd you
Javier Pons
@JavierPons
Mar 05 2017 12:43
@TimLehner ok
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:44

Can anyone tell me why this code won't work...
```function mutation(arr) {
var lowCaseArr;
lowCaseArr = arr.map(function(word) {
return word.toLowerCase();
});
for (var i = 0; i < lowCaseArr1.length; i++) {
if (lowCaseArr[0].indexOf(lowCaseArr[1][i]) !== -1) {
return true;
}
else {
return false;
}
}
/ if (lowCaseArr[0].indexOf(lowCaseArr1) !== -1 || lowCaseArr[0].indexOf(lowCaseArr[1][lowCaseArr1.length - 1]) !== -1) {
return true;
}
else {
return false;
}
/
}

mutation(["hello", "hey"]);
```

Boram Jeong
@Boram0206
Mar 05 2017 12:44
@HeebieGeeBee Thanks. I solved it.. :)
CamperBot
@camperbot
Mar 05 2017 12:44
boram0206 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 950 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Pieter Stokkink
@forkerino
Mar 05 2017 12:45
@SA-P you only look at the first letter in your loop.
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:45
oops... forgot to delete the commented out section...
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:46
@forkerino :wave:
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:46
how do you do the black code box thingy?
Johnny
@JohnnyBizzel
Mar 05 2017 12:46
'''
CamperBot
@camperbot
Mar 05 2017 12:46
:bulb: to format code use backticks! ``` more info
Johnny
@JohnnyBizzel
Mar 05 2017 12:47
camperbot knows ^^
Pieter Stokkink
@forkerino
Mar 05 2017 12:47
@HeebieGeeBee hello!
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:49
Isn't my code and this code kind of similar?
function mutation(arr) {
  var test = arr[1].toLowerCase();
  var target = arr[0].toLowerCase();
  for (i=0;i<test.length;i++) {
    if (target.indexOf(test[i]) < 0)
      return false;
  }
  return true;
 }
My code:
function mutation(arr) {
  var lowCaseArr;
  lowCaseArr = arr.map(function(word) {
    return word.toLowerCase();
  });
  for (var i = 0; i < lowCaseArr[1].length; i++) {
    if (lowCaseArr[0].indexOf(lowCaseArr[1][i]) !== -1) {
      return true;
  }
    else {
      return false;
    } 
  }
mutation(["hello", "hey"]);
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:50
@SA-P there are differences
important ones
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:51
like?
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:52
well your return true inside the the loop is gonna stop the function when you hit true
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:52
Maybe that's why it's not working for this particular array...
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:52
which means it wont loop through every letter
unless all letters are false
oh but you have a reaturn false inside the loop too
so yeah you wont be getting past the first iteration either way
Coded
@Ajayhar
Mar 05 2017 12:55
Does indexOf() function work with integer array?
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:55
Even if I do it like the previous code it doesn't work.
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:56
what did you do? @SA-P
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:56
@HeebieGeeBee function mutation(arr) { var lowCaseArr; lowCaseArr = arr.map(function(word) { return word.toLowerCase(); }); for (var i = 0; i < lowCaseArr[1].length; i++) { if (lowCaseArr[0].indexOf(lowCaseArr[1][i]) < 0) { return false; } return true; }
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 12:57
@SA-P dont return true inside the loop
@Ajayhar and yes it does
Sarfaraz Amin Progga
@SA-P
Mar 05 2017 12:59
@HeebieGeeBee Thanks. I should be more careful with those.
CamperBot
@camperbot
Mar 05 2017 12:59
sa-p sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:cookie: 951 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Coded
@Ajayhar
Mar 05 2017 13:01
@HeebieGeeBee functionName([1, 2, 3, 4] ,2,4) ; What does this line mean?
Nikhil KD
@kadyanikhil
Mar 05 2017 13:01
guys i dont know if there is something wrong cause i am unable to add else {return "No such property";} it either gets error or messes up with other commands
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      } else {
      return "No such property";
    }
  } 
 } 
// Only change code above this line
}
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 13:02
@Ajayhar its the function being called with arguments passed into it
Nikhil KD
@kadyanikhil
Mar 05 2017 13:02
where to add else {return "No such property";}
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 13:02
@kadyanikhil just return no such contacts outside the loop[
Stephen James
@sjames1958gm
Mar 05 2017 13:03
No return no such contact outside the loop
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 13:03
oops
yeah contacts
lol brainfrt
@kadyanikhil
Coded
@Ajayhar
Mar 05 2017 13:03
@HeebieGeeBee Yes. But there is only one argument in the function definition. The line that calls the function seems to have an array and two more arguments. ([1, 2, 3, 4] ,2,4) ;
Stephen James
@sjames1958gm
Mar 05 2017 13:03
Which may have been the intended question?
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 13:04
possibly @sjames1958gm lol
Nikhil KD
@kadyanikhil
Mar 05 2017 13:04
@HeebieGeeBee exactly been stuck for 30 min
HeebieGeeBee
@HeebieGeeBee
Mar 05 2017 13:05
@Ajayhar you can pass more arguments into the function when you call it
Nikhil KD
@kadyanikhil
Mar 05 2017 13:05
whats exact reason for errors
function lookUpProfile(firstName, prop){
// Only change code below this line
  for (var i = 0; i < contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (contacts[i].hasOwnProperty(prop)){
        return contacts[i][prop];
      } else {
      return "No such property";
    }
  } else {return "No such contact";}
 } 
// Only change code above this line
}
@HeebieGeeBee this shows error
Stephen James
@sjames1958gm
Mar 05 2017 13:05
@Ajayhar did you follow the link for the arguments object?