14th
Jul 2016
labanch
@labanch
Jul 14 2016 00:00
can anyone help with the largest of numbers in array challenge? I know I have to use a nested for loop. But I'm having trouble iterating :/ how do I compare within each array?
Diego Mayer
@Chrono79
Jul 14 2016 00:01
use a var, and reset it in every outer loop @labanch
LisaKay
@LKBonner
Jul 14 2016 00:03
I'm sorry, but I am very new to JavaScript. The lesson says: a should have a value of 7, b should have a value of 7, a should be assigned to b with =. so, var a = 7; var b = 7; then I'm stuck........ ugh.
Diego Mayer
@Chrono79
Jul 14 2016 00:05
@LKBonner you have already var a above, so no need to declare (put var before the var name) again
Then, " a should be assigned to b with =" is like you did with 7 and a, just replace them
bitgrower
@bitgrower
Jul 14 2016 00:07
LisaKay
@LKBonner
Jul 14 2016 00:08
@Chrono79 -- Thanks, so : var a = 7, b = 7; Then, i am lost
CamperBot
@camperbot
Jul 14 2016 00:08
lkbonner sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1511 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 14 2016 00:08
@bitgrower `var a = 7; var b = 7;`
Andrew
@westhofa
Jul 14 2016 00:08
``````
// Example
function ourReusableFunction() {
console.log("Heyya, World");
}

ourReusableFunction();

// Only change code below this line

function reusableFunction() {
console.log("Hi world");
}

reusableFunction();``````
Diego Mayer
@Chrono79
Jul 14 2016 00:08
@LKBonner no var again, delete it
and instead of using 7 again when setting b value use a
Each sentence goes separated with ; not , too
Andrew
@westhofa
Jul 14 2016 00:08
lol I figured it out case sensative
LisaKay
@LKBonner
Jul 14 2016 00:10
@Chrono79 ----- Thanks!! (smacking forehead) I appreciate it!
CamperBot
@camperbot
Jul 14 2016 00:10
lkbonner sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: lkbonner already gave chrono79 points
labanch
@labanch
Jul 14 2016 00:17
@Chrono79
```
@Chrono79
``````function largestOfFour(arr) {
var num = 0;
var nums = [];
for(var i = 0; i<arr.length; i++){
for(var j = 0; j<arr[i].length; j++){
if(arr[i][j] > num){
num = arr[i][j];
nums.push();
}
}
}
return nums;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
Diego Mayer
@Chrono79
Jul 14 2016 00:18
you nned to reset num for each subarray
and you need to push num to nums
labanch
@labanch
Jul 14 2016 00:19
@Chrono79 isn't the subarray j? or is the subarray i?
Diego Mayer
@Chrono79
Jul 14 2016 00:21
the subarray is `arr[i]`
Alayna Browder
@Absailnit
Jul 14 2016 00:21
problem on the escape sequences section have all 3 checked but the following part is holding me back.
myStr should have encoded text with the proper escape sequences and no spacing.
labanch
@labanch
Jul 14 2016 00:21
ohh! ok I thought the subarray was arr[i][j] @Chrono79
@Chrono79 ok so arr[i][j] is iterating through each number in the subarray. Got it
Alayna Browder
@Absailnit
Jul 14 2016 00:23
my code is ..var myStr="FirstLine\n\SecondLine\ThirdLine\r;
Jul 14 2016 00:24

@BrianCodes33 - let's see if I can put a sketch of what you want to do here... you want to use your array to store a new quote every time you get one, so you need to have an index to the current quote that you are displaying, and then you have the length of the array.

``````
0 : quote 0
1 : quote 1
2 : quote 2  <--- this would be the current quote if you clicked "next" three times

so array.length = 3   and the currentQuote index = 2

If someone clicked "previous quote" - you would see that you had your
currentQuote index at 2, so you back it up to 1, and take that quote and
output it.  Then if someone clicked "previous" again, you would go back to 1.
Then a click on "next quote" - you would see your currentQuote index = 1,
and length was greater than "currentQuote + 1", so you just advance the
currentQuote index to 2, and output the quote from there.  Then if
someone clicked "next", you would see that you didn't have another quote,
so you would get a new one from your quote API.``````

I probably could do a better algorithmic explanation of that, but that's the essence of what you need to do - maintain your array of quotes and keep track of the current one being displayed, then decide if you have a previous one to display for the "prev" selection, and if you already have one for the next - only requesting the quoteAPI when you are at the end of the array.

LordYamanouchi
@LordYamanouchi
Jul 14 2016 00:24
@Chrono79 How do I make the prop variable correspond when the .hasOwnProperty can't even check for a non-existent prop property?
Shola Abaogun
@codephoo
Jul 14 2016 00:25
thanks @shawlhar
CamperBot
@camperbot
Jul 14 2016 00:25
codephoo sends brownie points to @shawlhar :sparkles: :thumbsup: :sparkles:
:warning: codephoo already gave shawlhar points
Alayna Browder
@Absailnit
Jul 14 2016 00:26
im sorry it is var myStr="FirstLine\n\SecondLine\ThirdLine\r; any clues on why I cannot go forward?
Jean Louis Salbego
@jlouiss
Jul 14 2016 00:26
please guys, can someone tell me if i'm writing good or bad code? How can I improve my writing? http://codepen.io/JLouisS/pen/yJPANX?editors=0010
Joseph Long
@jmafia
Jul 14 2016 00:27
@Absailnit I'm on the same one
having trouble figuring it out as well
David Di Feo
@ddifeo
Jul 14 2016 00:27
@Absailnit to have a backslash appear in a string, you have to put another backslash before it
``var str = "\\Backslash\\";  //Will give you \Backslash\``
Alayna Browder
@Absailnit
Jul 14 2016 00:28
I did when i hit the enter on the forum to adjust here it kicks it out..
David Di Feo
@ddifeo
Jul 14 2016 00:28
hmm thats weird
Greg Munker
@Gmunker
Jul 14 2016 00:29
``````function checkCashRegister(price, cash, cid) {

var cidTotal = cid.reduce(function(a, b) {
return a + b[1];
}, 0).toFixed(2);

var change = (cash - price).toFixed(2);

console.log(cidTotal + " cidTotal"); //335.41
console.log(change + " change"); //96.74

console.log(change > cidTotal);  //True???????? <----

if (cidTotal < change) {
//return "Insufficient Funds";
console.log("in funds");
}

if (change === cidTotal) {
//return "Closed";
console.log("closed");
}
}

checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]);``````
Anyone have an idea why change > cidTotal is returning true?? This is driving me nuts!
Diego Mayer
@Chrono79
Jul 14 2016 00:29

im sorry it is var myStr="FirstLine\n\SecondLine\ThirdLine\r; any clues on why I cannot go forward?

@Absailnit your \r should be between SecondLine and ThirdLine

David Di Feo
@ddifeo
Jul 14 2016 00:29
also your \r should go before ThirdLine, not after. @Absailnit
@Absailnit The way you have it, its skipping a line after ThirdLine. You want to skip a line first
Alayna Browder
@Absailnit
Jul 14 2016 00:30
thanks dave that should solve my issue I think the before the third line
Diego Mayer
@Chrono79
Jul 14 2016 00:31
@realxtensive you can try to quote a post to see if they've escaped the backslash
Joseph Long
@jmafia
Jul 14 2016 00:31

I have this and Im running into trouble:

FirstLine\n\SecondLine\rThirdLine\;

Diego Mayer
@Chrono79
Jul 14 2016 00:32
@jmafia read a couple of posts above this one
the backslash after ThirdLine is not well placed, it should be after SecondLine
Alayna Browder
@Absailnit
Jul 14 2016 00:32
Joseph you have to use two backslash characters before 2nd line
David Di Feo
@ddifeo
Jul 14 2016 00:32
@Absailnit no problem
@Chrono79 huh thanks, didnt know about that
CamperBot
@camperbot
Jul 14 2016 00:32
realxtensive sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1512 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 14 2016 00:33
@Absailnit he has that right
Joseph Long
@jmafia
Jul 14 2016 00:34

I have this now:

var myStr="FirstLine\n\SecondLine\rThirdLine\";

Alayna Browder
@Absailnit
Jul 14 2016 00:35
dont need the backslash after thirdLine
Joseph Long
@jmafia
Jul 14 2016 00:35
The second line requires double escapes, right?
Diego Mayer
@Chrono79
Jul 14 2016 00:35

I have this now:

`var myStr="FirstLine\n\\SecondLine\\rThirdLine\";`

move the last \ after SecondLine
Eduardo Santos
@eddysantos
Jul 14 2016 00:36
Hello Guys... I'm on the JavaScript profile challenge, I keep getting 2 of the tests wrong, for some reason, when I add the "else" statement on this code, the results for "lookUpProfile("Sherlock", "likes")" return as "No contact found". Can somebody help???
``````function lookUpProfile(firstName, prop){
// Only change code below this line

var result;

for(e = 0; e < contacts.length; e++){
if(contacts[e].firstName == firstName && contacts[e].hasOwnProperty(prop)){
result = contacts[e][prop];
} else {
if(contacts[e].firstName !== firstName){
result = "No such contact";
}

if(!contacts[e].hasOwnProperty(prop)){
result = "No such property";
}
}
}

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

// Change these values to test your function
lookUpProfile("Sherlock", "likes");``````
Alayna Browder
@Absailnit
Jul 14 2016 00:36
yes 2 before 2nd and after plus the \r
Eduardo Santos
@eddysantos
Jul 14 2016 00:36
Here's the full code:
``````
//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line

var result;

for(e = 0; e < contacts.length; e++){
if(contacts[e].firstName == firstName && contacts[e].hasOwnProperty(prop)){
result = contacts[e][prop];
} else {
if(contacts[e].firstName !== firstName){
result = "No such contact";
}

if(!contacts[e].hasOwnProperty(prop)){
result = "No such property";
}
}
}

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

// Change these values to test your function
lookUpProfile("Sherlock", "likes");``````
Diego Mayer
@Chrono79
Jul 14 2016 00:36
@eddysantos for some good reason, you can't set all results inside the loop
Eduardo Santos
@eddysantos
Jul 14 2016 00:37
I should use else if right??
Alayna Browder
@Absailnit
Jul 14 2016 00:37
Ok that was somewhat confusing..
Joseph Long
@jmafia
Jul 14 2016 00:37
Im still confused... haha
Michaelangelo Leon
@mikey1995
Jul 14 2016 00:38

Hey so I just finished the "reverse a string" function. Here's my code:

function reverseString(str) {
var input = String(str);
var newStr = input.split("").reverse().join("");
return newStr;
}

reverseString("hello");

I was just wondering why I need var input = String(str) if the argument pasted was already a string to begin with?

Diego Mayer
@Chrono79
Jul 14 2016 00:38
@mikey1995 who told you you needed it?
Alayna Browder
@Absailnit
Jul 14 2016 00:38
var myString="FirstLine\n\SecondLine\\rThirdLine";
Diego Mayer
@Chrono79
Jul 14 2016 00:39
@Absailnit look below
help format
CamperBot
@camperbot
Jul 14 2016 00:39

Multi line Code

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

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

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

Single line Code

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

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

Diego Mayer
@Chrono79
Jul 14 2016 00:39
@Absailnit use the backticks to show all the backslashes
Alayna Browder
@Absailnit
Jul 14 2016 00:40
Yes Holy cow that is golden...
can someone clarify for jmafia? he is so close to the finish line
Drez
@drez14
Jul 14 2016 00:42
hey guys I'm stuck with the caesars cipher challenge
I tried a creative solution but it hasn't worked so far
Diego Mayer
@Chrono79
Jul 14 2016 00:43
@jmafia
you have this: `var myStr="FirstLine\n\\SecondLine\\rThirdLine\";`
you want this: `var myStr="FirstLine\n\\SecondLine\\\rThirdLine";`
See what I meant when I told you to move the last \ after SecondLine now?
Michaelangelo Leon
@mikey1995
Jul 14 2016 00:43
@Chrono79 if i don't put it in my code I get this "ReferenceError: input is not defined"
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 00:44
Ok people I need help understanding functions.. Right now in stuck in "Stand in line" challenge... How do you call the item from the function when " item" is already defined.. I've created a local variable
Drez
@drez14
Jul 14 2016 00:44
``````function rot13(str) { // LBH QVQ VG!

var alphabet= ["A","B","C","D","E","F","G","H","I","J","K","M","N","L","O","P","Q","R","S","T","U","V","W","X","Y","Z"];

var myArr= str.split("");

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

if(myArr[i]===" "){

continue;

}else{

var currInd= alphabet.indexOf(myArr[i]);
var prevInd;

if(currInd>=13){

prevInd= currInd-13;
}else{

prevInd= currInd+13;
}

myArr[i]= alphabet[prevInd];
}
}

myArr= myArr.join("");

return myArr;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");``````
Diego Mayer
@Chrono79
Jul 14 2016 00:44
@mikey1995 you have to replace it for str in the next line too
Joseph Long
@jmafia
Jul 14 2016 00:44
@Chrono79 I see
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 00:44
That .shift() and removes first number
Joseph Long
@jmafia
Jul 14 2016 00:44
thank you
Drez
@drez14
Jul 14 2016 00:44
so far it's returning FREE CODE CZNP instead of FREE CODE CAMP
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 00:45
Any help is greatly appreciated
David Di Feo
@ddifeo
Jul 14 2016 00:46
@DrWhodaFuq it removes the first number, but also returns it. So you can assign it to a variable
@DrWhodaFuq then return that variable
Diego Mayer
@Chrono79
Jul 14 2016 00:46
@drez14 you've built your alphabet wrong
NPeyralans
@NPeyralans
Jul 14 2016 00:47
Can anyone explain to me how to get the data out of a promise object in a factory and return the data to my controller? I've been reading so many articles and watching so many tutorials and this apparently simple question nobody can give me a straight forward answer.
Drez
@drez14
Jul 14 2016 00:47
@Chrono79 OMG
that L
thanks @Chrono79
CamperBot
@camperbot
Jul 14 2016 00:48
drez14 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1513 | @chrono79 |http://www.freecodecamp.com/chrono79
Michaelangelo Leon
@mikey1995
Jul 14 2016 00:48
@Chrono79 I have been enlightened :)
Drez
@drez14
Jul 14 2016 00:49
lol :D
Diego Mayer
@Chrono79
Jul 14 2016 00:49
I feel like a flashlight now :P
Eduardo Santos
@eddysantos
Jul 14 2016 00:49
Hey @Chrono79, so, I can't use the result declaration inside the same for, even if they are in the else if portion of the code?
Diego Mayer
@Chrono79
Jul 14 2016 00:51
you could only set No such contact if the firstName doesn't match and it's the last loop, otherwise if the last contact isn't the one you were looking for you'll return No such contact
So a better way is returning it outside the loop and return inside the loop the property or No such property
Gary Siu
@GarySiu
Jul 14 2016 00:54
@NPeyralans Did you get an answer?
NPeyralans
@NPeyralans
Jul 14 2016 00:55
@GarySiu What do you mean?
Gary Siu
@GarySiu
Jul 14 2016 00:56
@NPeyralans Getting data from a promise
Drez
@drez14
Jul 14 2016 00:57
can I use a regular expression within an if??? like : if( var x==/\W/){ } ??
Diego Mayer
@Chrono79
Jul 14 2016 00:58
don't think so, but try
NPeyralans
@NPeyralans
Jul 14 2016 00:58
@GarySiu No, I don't understand why it is so hard to answer that question. The reason why we call apis is to get data to put in our view right? But everything I read and the answers I get say you can only use the data from the promise object in the callback function in the .then() or .success() part, which doesn't make that data available to be returned from the factory for the controller to pass to the view! I still can't figure it out...
Michaelangelo Leon
@mikey1995
Jul 14 2016 00:58
Hey @Chrono79 can you also help me with the "title case a sentence" function? Here's what i got so far:
``````function titleCase(str) {
var checkStr = str.toLowerCase();
var count = 1;//count starts on second letter

//the first letter is always capitalized
var upperStr = checkStr.replace( checkStr[0], checkStr[0].toUpperCase() );

while( count < upperStr.length - 1){
if( upperStr[count] == " "){
count++;
upperStr = upperStr.replace( upperStr[count], upperStr[count].toUpperCase() );
}else{
count++;
}
}
return upperStr;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");``````
Gary Siu
@GarySiu
Jul 14 2016 00:59
Brian
@BrianCodes33
Jul 14 2016 00:59
NPeyralans
@NPeyralans
Jul 14 2016 00:59
@GarySiu It seems like that is what everybody would be wanting to do when they call apis...
Brian
@BrianCodes33
Jul 14 2016 00:59
any ideas to get this quote generator working properly
NPeyralans
@NPeyralans
Jul 14 2016 01:00
@BrianCodes33 Your quote generator is working pretty good for me except that there is some missing data every now and then. What is the issue your having with it?
eeflores
@eeflores
Jul 14 2016 01:00
@mikey1995 maybe try splitting the string into an array of words?
Gary Siu
@GarySiu
Jul 14 2016 01:01
@NPeyralans I’m working through some examples from here at the moment: http://www.html5rocks.com/en/tutorials/es6/promises/ but I’m willing to take a look at any code you have?
NPeyralans
@NPeyralans
Jul 14 2016 01:01
@BrianCodes33 actually its getting everything good for me, really like the layout too...
Drez
@drez14
Jul 14 2016 01:01
thanks @GarySiu
CamperBot
@camperbot
Jul 14 2016 01:01
drez14 sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
Jul 14 2016 01:01
Hi Everyone. Back again. still having trouble with the same challenge. cant figure out. Can Someone please tell Me how I would 'remove the first element of array.' I have read over how .push, shift, pop, unshift but still cant seem to grasp what or how to solve this challenge. "Stand in Line" queue
Diego Mayer
@Chrono79
Jul 14 2016 01:02
@mikey1995 replace will replace the first ocurrence of that char, not the one you want
eeflores
@eeflores
Jul 14 2016 01:02
This message was deleted
Jul 14 2016 01:02
I have pushed 6 to the end of the testArr but not sure how to
then remove the first element of array.
Diego Mayer
@Chrono79
Jul 14 2016 01:02
@ChadDean82 use arr and item, not testArr and 6
NPeyralans
@NPeyralans
Jul 14 2016 01:04

@GarySiu So this is one of the million things I have tried:

``````        \$scope.userData = [];
\$scope.promises = [];

for (var i = 0; i <  \$scope.urls.length; i++) {
\$scope.promises[i] = \$http.get(\$scope.urls[i]);
})
};

console.log('usersData in ctrl\n' + \$scope.usersData);``````

When I console.log the userData outside the for loop it returns undefined.

Gary Siu
@GarySiu
Jul 14 2016 01:05
Oh boy. Some lovely Angular -_-
So are you trying to get data from a bunch of urls sequentially or when all your promises resolve?
NPeyralans
@NPeyralans
Jul 14 2016 01:06
This one I tried in the controller cause I have been working in the factory for hte last 6 hours and though I would tyry leveraging the \$scope to see if it would work
Jul 14 2016 01:07
shift' It works just like .pop(), except it removes the first element instead of the last."
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:07
@realxtensive thank you thank you!!
CamperBot
@camperbot
Jul 14 2016 01:07
drwhodafuq sends brownie points to @realxtensive :sparkles: :thumbsup: :sparkles:
NPeyralans
@NPeyralans
Jul 14 2016 01:07

Basically when I pass the urls into the http.get I can return the object that I am looking for, in the form of this:

but when I try to access data._links.self and data._links.channel it returns undefined

DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:08
@realxtensive final question
NPeyralans
@NPeyralans
Jul 14 2016 01:09
So how do I go from that object returned above to leverage the data inside of it for my view!! I don't know what anyone else would do with an object like this... lol
Diego Mayer
@Chrono79
Jul 14 2016 01:09
@ChadDean82 if shift returns some value (read what that is) you can return arr.shift() , don't you?
Gary Siu
@GarySiu
Jul 14 2016 01:09
Could you put your code up somewhere?
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:09

function nextInLine(arr, item) {
var testArr= arr.shift();
var item= testArr;
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));
How do I push the defined item?

NPeyralans
@NPeyralans
Jul 14 2016 01:10
I might have to do that it just takes a bit of customizing going from local to codepen... is there a place where I can copy paste from local for you to see, or do you want codepen
Diego Mayer
@Chrono79
Jul 14 2016 01:10
@DrWhodaFuq https://www.freecodecamp.com/challenges/manipulate-arrays-with-push
And read again the instructions so you get the order right
David Di Feo
@ddifeo
Jul 14 2016 01:11
@DrWhodaFuq as @Chrono79 just said, you have to push item into the array
Jul 14 2016 01:11
@Chrono79 do I need to write a whole new function nextInLine with 2 new arg?
Diego Mayer
@Chrono79
Jul 14 2016 01:12
Gary Siu
@GarySiu
Jul 14 2016 01:12
@NPeyralans You can dump it on bitballoon or somewhere, I don’t mind
Jul 14 2016 01:13
@Chrono79 I tried but it returns the wrong var. Supost to return the element that was removed. I thought maybe shift would do the trick.
Diego Mayer
@Chrono79
Jul 14 2016 01:13
NPeyralans
@NPeyralans
Jul 14 2016 01:14
@GarySiu should I put my whole project folder or just the app dir?
Gary Siu
@GarySiu
Jul 14 2016 01:15
@NPeyralans Probably safest to put everything in
Jul 14 2016 01:15
``````function nextInLine(arr, item) {

return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));``````
NPeyralans
@NPeyralans
Jul 14 2016 01:16
@GarySiu neverymind it just rejected the whole folder cause the size with all the bower_components and node_modules etc...
Jul 14 2016 01:16
that was the only thing I have put back in sence the last reset.
NPeyralans
@NPeyralans
Jul 14 2016 01:16
Actually its rejecting all of the files i'm trying to upload, is there the name of another site you know I could put them up there?
Diego Mayer
@Chrono79
Jul 14 2016 01:17
@ChadDean82 ok, why 6? replace it with item, otherwise, it'll always push 6, not the value you use in your function call, not so useful that way
Gary Siu
@GarySiu
Jul 14 2016 01:20
@NPeyralans Can you get a single url to resolve?
NPeyralans
@NPeyralans
Jul 14 2016 01:21
Yup!
just pushed my code to github : https://github.com/NPeyralans/FCCTwitchTV
Yeah that was where I started and it was my first test to make sure it resolved...
But once again when I try to pass the data anywhere outside of the .then() part, it fails...
Jul 14 2016 01:22
@BrianCodes33 - it doesn't seem to be doing the "Previous Quote" correctly... I'm taking a look at what you have...
Brian
@BrianCodes33
Jul 14 2016 01:23
@khaduch yea i know i had a friend help me. although i don't understand what he did :( thinking of going from scratch again
Jul 14 2016 01:24
@Chrono79 hmm so the # at the bottom in the console.log is the # that get's pushed when the item is pushed?
Diego Mayer
@Chrono79
Jul 14 2016 01:25
@ChadDean82 only in that function call, in other tests they use other numbers
Jul 14 2016 01:25
@BrianCodes33 - it feels like there is a lot more complexity there than there needs to be?
NPeyralans
@NPeyralans
Jul 14 2016 01:25
@GarySiu Just pushed another one just to make the comments more descriptive of the issue.
Brian
@BrianCodes33
Jul 14 2016 01:25
sure
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:28
@Chrono79 @realxtensive first, someone tell me how you grab the code screen to post here?.. I feel like this shold be right but i must be missing something here
David Halls
@DavidHalls
Jul 14 2016 01:28
help format
CamperBot
@camperbot
Jul 14 2016 01:28

Multi line Code

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

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

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

Single line Code

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

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

Santiago Gómez
@Sperkajugglite
Jul 14 2016 01:31
hi guys, I'm having trouble with my project can you help me? :P
jeremywu
@JeremyWuuuuu
Jul 14 2016 01:31
hey guys I kinda got a problem which is here collection[id].tracks.push('value');
Santiago Gómez
@Sperkajugglite
Jul 14 2016 01:31
the game works great until you loose in strict mode
and then i haven't been able to understand what happens?
jeremywu
@JeremyWuuuuu
Jul 14 2016 01:31
why is "push()"not functional?
Diego Mayer
@Chrono79
Jul 14 2016 01:32
@JeremyWuuuuu value is a string there, delete the quotes and maybe tracks doesn't exist for that collection[id]
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:32

```function nextInLine(arr, item) {
arr.push(item);
var test=testArr.shift();

//testArr.push();

return test; // 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));```

jeremywu
@JeremyWuuuuu
Jul 14 2016 01:33
thx first but i've tried it did not work :(
willcodes
@willcodes
Jul 14 2016 01:33
Hi Guys
I am starting the Build a random quote generator
Diego Mayer
@Chrono79
Jul 14 2016 01:33
@DrWhodaFuq use arr, not testArr
willcodes
@willcodes
Jul 14 2016 01:33
but I am a little confused on how to start
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:33
``````function nextInLine(arr, item) {
arr.push(item);
var test=testArr.shift();

//testArr.push();

return test;  // 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));``````
willcodes
@willcodes
Jul 14 2016 01:34
I feel like I am not prepared on how to do this, but I don't want to look at the source code to figure it out? any suggestions on how to get started? I guess I can do the html and css for it first
jeremywu
@JeremyWuuuuu
Jul 14 2016 01:35
It says that TypeError: Cannot read property 'push' of undefined
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:35

@Chrono79

``````function nextInLine(arr, item) {
arr.push(item);
var test=arr.shift();

//testArr.push();

return test;  // 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));``````

JACKPOT!!!!

Diego Mayer
@Chrono79
Jul 14 2016 01:36
:+1:
jeremywu
@JeremyWuuuuu
Jul 14 2016 01:36
congrats
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 01:36
tHANK YOU @Chrono79 bROWNIES YOUR QAY
CamperBot
@camperbot
Jul 14 2016 01:36
drwhodafuq sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1514 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 14 2016 01:36
@JeremyWuuuuu that's because the object hasn't a tracks property, as I already told you
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:36
I think I posted this in the wrong room before... anyone have some advice here? I want all divs to be equal width, even if contents are small, yet still have them wrapped in bootstrap responsive containers that will scale divs when window gets resized. Can't seem to figure it out. If I set a min-width to divs, they no longer resize... enter "run" into the search bar and you'll see what I mean (btw, I know the colors suck - working on it!).
http://codepen.io/no_stack_dub_sack/pen/akLkZP?editors=0010
see the second result
Diego Mayer
@Chrono79
Jul 14 2016 01:38
@no-stack-dub-sack use bootstrap col-xs-12 for instance, you also need rows and a container
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:39
i tried that! @Chrono79
NPeyralans
@NPeyralans
Jul 14 2016 01:39
@GarySiu I just added an example of how I can console.log the data that I need in the getFCC() function, but how I cannot return the actual data to the controller
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:39
didn't work for some reason, to do that the parent has to be a "row" right? @Chrono79
Gary Siu
@GarySiu
Jul 14 2016 01:40
@NPeyralans Just reached the point where I can actually start debugging… bare with me
Diego Mayer
@Chrono79
Jul 14 2016 01:40
@no-stack-dub-sack yes
DC
@dctor
Jul 14 2016 01:40
@Chrono79 I am trying to use filter() but can't get it to work, can you see what's wrong?
``````function sym(args) {
var arr = arguments[0];
var arr2 = arguments[1];
var arr3 = arr.concat(arr2).sort();
var arr4 = [];
var arr5 = [];
console.log(arr3);
function isDup() {
for (i = 0; i < arr3.length - 1; i++) {
if (arr3[i] === arr3[i + 1])
return (arr3[i]);
}
}   arr4 = arr3.filter(isDup);
console.log(arr4);
}
sym([1, 2, 3], [5, 2, 1, 4]);``````
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:40
Not working out... I'll try again in case I made a silly mistake @Chrono79
NPeyralans
@NPeyralans
Jul 14 2016 01:40
@GarySiu lol alright, I really appreciate it!!
Stephen James
@sjames1958gm
Jul 14 2016 01:41
@dctor the filter function should take an array element as a parameter and return true/false if the element is in the result true it is false it isn't you don't need a loop over arr3 in that function
Diego Mayer
@Chrono79
Jul 14 2016 01:41
@dctor that sort needs a function too
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:43
@Chrono79 re-run the pen and search "run" again, because I only applied to that second div, result not as expected. This is the html for that div:
``````<div class="container-fluid row">
<div id="result_1" class="searchResults col-xs-12"></div>
</a>
</div>``````
or would the container need to be the parent of the row? @Chrono79
nope, just tried that too
DC
@dctor
Jul 14 2016 01:45
@sjames1958gm ok in other words, isDup needs to return an array, and if it doesn't need a loop...use indexOf?
@Chrono79 got it i'll make a function for sorting thanks
CamperBot
@camperbot
Jul 14 2016 01:46
dctor sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1515 | @chrono79 |http://www.freecodecamp.com/chrono79
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:47

@Chrono79 never mind, just got it with this:

``````<div class="container-fluid">
<div class="row">
<div id="result_1" class="searchResults"></div>
</a>
</div>
</div>``````

just needed to talk it out I guess, thanks Diego

CamperBot
@camperbot
Jul 14 2016 01:47
no-stack-dub-sack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1516 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jul 14 2016 01:47
@no-stack-dub-sack :+1:
jeremywu
@JeremyWuuuuu
Jul 14 2016 01:52
function update(id, prop, value) {
if(collection[prop]!==collection[id].tracks&&value!==null){
collection[id][prop]=value;
}
else if(collection[id][prop]===collection[id].tracks&&value!==null){
collection = collection[id].tracks.push([value]);
}
else {delete collection[id][prop];}
return collection;
}
my whole function is here . but the console told me that
Cannot read property 'push' of undefined
sry for the format
Santiago Gómez
@Sperkajugglite
Jul 14 2016 01:53
:)
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:53
@Chrono79 while I have your ear... maybe there's one other thing you can help me with... notice that when you press enter to search, the form moves EVER so slightly to the left... this is bugging the hell out of me. Looks a little unclean. Any idea why?
http://codepen.io/no_stack_dub_sack/full/akLkZP/
Diego Mayer
@Chrono79
Jul 14 2016 01:53
@no-stack-dub-sack scrollbar and bootstrap
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:54
@Chrono79 can you elaborate?
Santiago Gómez
@Sperkajugglite
Jul 14 2016 01:54
Diego Mayer
@Chrono79
Jul 14 2016 01:57
Jul 14 2016 01:57
@dctor use isDup(val){} . The code will run for each array element and you can use val to target the value each time
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 01:58
@Chrono79 thanks, I'll check it out
CamperBot
@camperbot
Jul 14 2016 01:58
no-stack-dub-sack sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: no-stack-dub-sack already gave chrono79 points
Diego Mayer
@Chrono79
Jul 14 2016 01:59
I'm out, enough code for the day, see ya
Milo Hartsoe
@MiloATH
Jul 14 2016 01:59
Hi, I am working on the weather app. How do i get the button on the same page as the temperature. http://codepen.io/Miloath/pen/pbdaLB
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 02:01
```
Olly Sholotan
@Ollysho
Jul 14 2016 02:02
Hey! Could anyone tell me why this gives an infinite loop?
```
``````
function chunkArrayInGroups(arr, size) {    //Array length has to be equal or less than size
var newArr = [];

for (var i = 0; i < arr.length; i+size) {
newArr.push(arr);
if (newArr[i].length > size) {
newArr[i].length = size;
}
}
return newArr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 02:02
``````
function testLogicalOr(val) {
// Only change code below this line

if (val >10 || val < 20) {
return "Outside";
}

// Only change code above this line
return "Inside";
}

// Change this value to test
testLogicalOr(15);``````
is this a bug or what? evaluation looks right to me
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:02
@MiloATH you mean you want them to be side by side?
Milo Hartsoe
@MiloATH
Jul 14 2016 02:02
@no-stack-dub-sack yes
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:03
@MiloATH have you tried floating it to the right?
NPeyralans
@NPeyralans
Jul 14 2016 02:03
@Ollysho I think it depends on what you are passing in for hte arr and size params
David Halls
@DavidHalls
Jul 14 2016 02:03
@DrWhodaFuq what is your if statement actually testing?
Milo Hartsoe
@MiloATH
Jul 14 2016 02:03
@no-stack-dub-sack with what?
css position?
Olly Sholotan
@Ollysho
Jul 14 2016 02:04
@NPeyralans Okay...
NPeyralans
@NPeyralans
Jul 14 2016 02:05
lol
Olly Sholotan
@Ollysho
Jul 14 2016 02:05
@NPeyralans lol is this you saying I should remove loop protect and it probably isn't an infinite loop?
I just don't see how it would be
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:05
@MiloATH when I open the full pen, they appear to be side by side for me?
DrWhodaFuq
@DrWhodaFuq
Jul 14 2016 02:06
@Byzgig it was posed to test if a given number is inside of the statement or outside, turns out I logical statement backwards.. so everyting outside of the parameters was false as it should've been but the numbers that should've been true weren't
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:06
@MiloATH oh, never mind
NPeyralans
@NPeyralans
Jul 14 2016 02:06
@MiloATH You're missing the </h2> for the element before the button
Olly Sholotan
@Ollysho
Jul 14 2016 02:06
@NPeyralans Like when the third part of the for function is i++ it isn't infinite but when it's i + size it's infinite
DC
@dctor
Jul 14 2016 02:06
CamperBot
@camperbot
Jul 14 2016 02:06
dctor sends brownie points to @bradulz :sparkles: :thumbsup: :sparkles:
Jon
@jcmockbee
Jul 14 2016 02:07

Hi all Im trying nesting for loops this is what I have so far ```
function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(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]]);

```

NPeyralans
@NPeyralans
Jul 14 2016 02:07
@Ollysho Well I think you have to arrange the code so that no matter what the parameters are, it won't go inifinite on you.
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:07
@MiloATH if you put the button and the div with the temp in one div, and then in the CSS under button use `float: right` I think that will solve your problem
@Chrono79 well, not crazy about the solution, but it does work.
Rahul Nayak
@pragyes31
Jul 14 2016 02:08
hello guys, I am working on Random quote machine and for random qupte, I am using an API. but it is always the same quote which is appearinf everytime. the quote is not even changing when I click the new quote button.
Olly Sholotan
@Ollysho
Jul 14 2016 02:08
@NPeyralans Could you explain a smidge more please? I guess I'm just not sure if it will actually go infinite
Rahul Nayak
@pragyes31
Jul 14 2016 02:08
Can someone have a look at it : http://codepen.io/pragyesh31/pen/beBbyK
Olly Sholotan
@Ollysho
Jul 14 2016 02:09
@NPeyralans Like I really see no reason why it should
Milo Hartsoe
@MiloATH
Jul 14 2016 02:09
@no-stack-dub-sack that didn't works
*work
goyalruchi90
@goyalruchi90
Jul 14 2016 02:10
help balanced paranthesis
CamperBot
@camperbot
Jul 14 2016 02:10
no wiki entry for: `balanced paranthesis`
NPeyralans
@NPeyralans
Jul 14 2016 02:10
@Ollysho just for example if someone passes -1 to size parameter than it will go inifinite because it will always be less than arr.length
@Ollysho What is your code trying to do and what parameters are you going to pass into it?
David Halls
@DavidHalls
Jul 14 2016 02:11
@DrWhodaFuq yes, so did you get it fixed
Olly Sholotan
@Ollysho
Jul 14 2016 02:11
@NPeyralans I'm trying to Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.
@NPeyralans And I didn't think of that dang
NPeyralans
@NPeyralans
Jul 14 2016 02:12
lol
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:12
@MiloATH I'm sorry, I meant to suggest `display: inline-block` try that instead of `float : right`
NPeyralans
@NPeyralans
Jul 14 2016 02:13
@Ollysho I think you're going to want to use the .splice() method. Have you looking into that?
Gary Siu
@GarySiu
Jul 14 2016 02:13
@NPeyralans I got an array of userdata in the console. Haven’t touched Angular for ages so not sure what you want to do with it next
Milo Hartsoe
@MiloATH
Jul 14 2016 02:14
still on different lines @no-stack-dub-sack
Olly Sholotan
@Ollysho
Jul 14 2016 02:14
@NPeyralans Yeah I looked at that I guess I just couldn't figure out how to splice through my array
NPeyralans
@NPeyralans
Jul 14 2016 02:14
@GarySiu HOw'd you do that??
Olly Sholotan
@Ollysho
Jul 14 2016 02:14
@NPeyralans As in, go through the array splicing things and then sending them to the new array but once the new array is "full" start a new group
Gary Siu
@GarySiu
Jul 14 2016 02:14
@NPeyralans
``````mainFac.getData = function(urls) {

var promises = urls.map(function(url) {
return \$http.get(url);
});

Promise.all(promises).then(function(responses) {
var data = responses.map(function(res) {
return res.data;
});
console.log(data);
})

}``````
NPeyralans
@NPeyralans
Jul 14 2016 02:15
@Ollysho Yeah, I'm pretty sure you'll have to use .splice - check it out and always start with a simpler example until you understand how it works then work up from there...
@GarySiu Werd.
@GarySiu Don't even know what to say, but I never would have thought of someting that resembles that ...
Olly Sholotan
@Ollysho
Jul 14 2016 02:16
@NPeyralans Alright... I'll keep hammering. Thanks man
CamperBot
@camperbot
Jul 14 2016 02:16
ollysho sends brownie points to @npeyralans :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:16
@MiloATH well, without playing around with it a bit, I can't really say, but using display: inline-block method should work if done correctly. Check out this post: http://stackoverflow.com/questions/3619233/div-side-by-side-without-float
Jon
@jcmockbee
Jul 14 2016 02:16
Anyone happen to know how to solve nesting for loops ?
Gary Siu
@GarySiu
Jul 14 2016 02:16
@NPeyralans Angular is meant to come with a promise library called \$q but you don’t seem to have it included
Chase
@Belax8
Jul 14 2016 02:17
@jcmockbee Yep. Where are you stuck?
Milo Hartsoe
@MiloATH
Jul 14 2016 02:17
I saw that post. I think I am going to change the button to text and use jquery .click() @no-stack-dub-sack thanks anyways
CamperBot
@camperbot
Jul 14 2016 02:17
miloath sends brownie points to @no-stack-dub-sack :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:17
@MiloATH using float could work as well, but you'll just have to play around with the divs a bit.
Gary Siu
@GarySiu
Jul 14 2016 02:18
Jessicazhou1994
@Jessicazhou1994
Jul 14 2016 02:18
Gary Siu
@GarySiu
Jul 14 2016 02:18
@NPeyralans It’s es6 so there’s no guarantee it will work in all browsers. Would recommend you use a library for compatibility
Jessicazhou1994
@Jessicazhou1994
Jul 14 2016 02:18
i cannot delete
NPeyralans
@NPeyralans
Jul 14 2016 02:18
@GarySiu When I tried it I got : Provider 'mainFactory' must return a value from \$get factory method.
Gary Siu
@GarySiu
Jul 14 2016 02:19
Oh I took out the return but you can put it back
Jon
@jcmockbee
Jul 14 2016 02:19

@Belax8

this is what I have so far and it it just gives me x on everything ```
function multiplyAll(arr) {
var product = 1;
// Only change code below this line

for (var i=0; i < arr.length; i++) {
for (var j=0; j < arr[i].length; j++) {
console.log(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]]);

```

NPeyralans
@NPeyralans
Jul 14 2016 02:19
Promise.all is ES6? My chrome should be able to handle that right?
Gary Siu
@GarySiu
Jul 14 2016 02:20
Yeah Chrome is fine
Jon
@jcmockbee
Jul 14 2016 02:21
@Belax8 i should have i and j multiplying together to return product
Joseph
@revisualize
Jul 14 2016 02:21
@jcmockbee Can I ask you some side questions?
NPeyralans
@NPeyralans
Jul 14 2016 02:21
@GarySiu Uhh, where was the return statement? I can't get it to work (sorry i'm pretty new to all this)
Gary Siu
@GarySiu
Jul 14 2016 02:21
You had return userData at the bottom
Jon
@jcmockbee
Jul 14 2016 02:22
@revisualize you bet
Joseph
@revisualize
Jul 14 2016 02:22
@jcmockbee I'm seeing a LOT of people `console.log arr[i][j]` ... Not just you ... Why are you doing that?
@jcmockbee I'm trying to figure out how / where / if there is a breakdown in the curriculum.
Gary Siu
@GarySiu
Jul 14 2016 02:23
@NPeyralans You used to have var userData = [] at the top. The thing is if you return it, then it will run before the async stuff happens
NPeyralans
@NPeyralans
Jul 14 2016 02:23
@GarySiu Ha! Nice , yeah I just had a misplaced comment at the bottom - works great, THANK YOU SOOOO MUCH!!!!
CamperBot
@camperbot
Jul 14 2016 02:23
npeyralans sends brownie points to @garysiu :sparkles: :thumbsup: :sparkles:
Gary Siu
@GarySiu
Jul 14 2016 02:23
Good luck!
Chase
@Belax8
Jul 14 2016 02:23
@jcmockbee Yep that looks great. Now just change your `console.log();` to something that multiplies the number, like `product *= arr[i][j];`
Jon
@jcmockbee
Jul 14 2016 02:23
they are seperate arrays and and I am running two for loops that multiply together
NPeyralans
@NPeyralans
Jul 14 2016 02:23
@GarySiu Yeah, this is really the first time i've worked with asynchronous data returns , i don't really understand how to handle it...
Chase
@Belax8
Jul 14 2016 02:24
@revisualize I like using `console.log(arr[i][j]);` because then it helps me visualize what I am trying to access.
Joseph
@revisualize
Jul 14 2016 02:24
@jcmockbee The though process should be that you're assigning `product = 1` ... You should then create a product of all the numbers in the array by reassigning product to be a multiplication of the value in `arr[i][j]` ... Then return the accumulation of `product`.
Gary Siu
@GarySiu
Jul 14 2016 02:24
I think using angular makes your life a lot more complicated? Maybe start with just callbacks, work your way up to promises before tackling harder stuff?
Joseph
@revisualize
Jul 14 2016 02:24
Hmmm
@jcmockbee Well, you're almost doing everything correctly. Except your stuck because you're using console.log.
NPeyralans
@NPeyralans
Jul 14 2016 02:25
@GarySiu I, to be honest, don't have a clue about any of this web stuff, I've just been doing COursera classes covering angular so I wouldn't even know how to start with anything else....
Gary Siu
@GarySiu
Jul 14 2016 02:26
@NPeyralans Yeah or just plain old vanilla javascript
jQuery uses it’s own non-standard way of handling async stuff called “deffered"
Jon
@jcmockbee
Jul 14 2016 02:27
@revisualize I thought console.log was needed for display ?
NPeyralans
@NPeyralans
Jul 14 2016 02:28
Yeah, maybe just for the experience I'll solve this one in both angular and then try to write it up in jquery so I can understand it a bit better. Thanks
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:28
@MiloATH here, this works. put `display: inline-block` on both temperature and button-div. Just tried it, works like a charm.
``````         <div id="test">
<div id="temperature">
<h2 id="temp">0</h2>
</div>
<div id="button-div">
<button onClick="useOther()">°F</button>
</div>
</div>``````
Pedro Portela
@Pedro12909
Jul 14 2016 02:29
Hi, I'm having trouble solving one of euler's problems.
Here's what I want to do:
"If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below whatever the user's input is."
Here's my code:
Milo Hartsoe
@MiloATH
Jul 14 2016 02:30
@no-stack-dub-sack am I doing something wrong? http://codepen.io/Miloath/pen/pbdaLB
Pedro Portela
@Pedro12909
Jul 14 2016 02:30
``````var input = prompt("Please enter a number");

if (input > 0 && !isNaN(input)) {
for (var i = 0; i < input; i++)
{
if (i % 3 === 0 || i % 5 === 0)
{
var res += i;
}
else
{
continue;
}
}
}
else
{
prompt("It needs to be a positive integer!");
}
prompt(res);``````
Jon
@jcmockbee
Jul 14 2016 02:31
@Belax8 Thankyou belax just so I am reading this the same way you do
CamperBot
@camperbot
Jul 14 2016 02:31
jcmockbee sends brownie points to @belax8 :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:31
@MiloATH now you have two divs with id temperature, get rid of the outer one
Pedro Portela
@Pedro12909
Jul 14 2016 02:31
can you tell me why it isnt working?
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:32
@MiloATH and `button-div` should have `display: inline-block` not `test`
Milo Hartsoe
@MiloATH
Jul 14 2016 02:33
Jon
@jcmockbee
Jul 14 2016 02:33
@Belax8 both arrays i and j when multiplied are equal to product. This is the same as saying console.log(arr[i][j]);
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:35
@MiloATH change temperature to `display: inline-block` and you should be golden
Chase
@Belax8
Jul 14 2016 02:35
Sorry @jcmockbee I'm not sure what you mean
Milo Hartsoe
@MiloATH
Jul 14 2016 02:35
Great! thanks @no-stack-dub-sack
CamperBot
@camperbot
Jul 14 2016 02:35
miloath sends brownie points to @no-stack-dub-sack :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:36
no prob, I get so much help from folks around here, I'm happy to be able to actually return the favor from time to time
CamperBot
@camperbot
Jul 14 2016 02:36
:warning: miloath already gave no-stack-dub-sack points
Peter Weinberg
@no-stack-dub-sack
Jul 14 2016 02:37
@MiloATH maybe change the button text to something like "toggle temp" or just "toggle" too so that when it's on F it doesn't have another F next to it and when it's Celsius, it won't have an F next to it
just a suggestion
Milo Hartsoe
@MiloATH
Jul 14 2016 02:37
Go idea
James S.
@Mrblue27
Jul 14 2016 02:41

```
// Setup
function testStrict(val) {
if (val == 11) { // Change this line
return "Equal";
}
return "Not Equal";
}

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

``` Any Idea why the equality operater is not correct

Jon
@jcmockbee
Jul 14 2016 02:42
@revisualize Actually looking back at your explaination that you just gave in the help section would be better than the sentence below instructions . The explanation in help that you posted much better .
Milo Hartsoe
@MiloATH
Jul 14 2016 02:43
@no-stack-dub-sack I changed it to /°F works well.
NPeyralans
@NPeyralans
Jul 14 2016 02:43
@GarySiu Hey, my bad man, I just realized that I was able to console.log the array of data also, but it was the returning the values that I couldn't do.
@GarySiu You think I should just give up on trying to do this in angular and work in jquery or vanilla javascript?
Rahul Nayak
@pragyes31
Jul 14 2016 02:47
can someone check and tell me why new quote is not generating when I click on "new quote" button ? http://codepen.io/pragyesh31/pen/beBbyK?editors=0010#0
Ankit
@ankitagar
Jul 14 2016 02:50
I was facing the same problem look at my pen... you will figure it out. http://codepen.io/aagarw12/pen/pbPmZb
willcodes
@willcodes
Jul 14 2016 02:51
Where did u guys learn to use .ajax?
did i miss something???
Rahul Nayak
@pragyes31
Jul 14 2016 02:51
@ankitagar sure, let me take a look
@willcodes udacity course on Ajax is helpful
willcodes
@willcodes
Jul 14 2016 02:52

NPeyralans
@NPeyralans
Jul 14 2016 02:52
@pragyes31 You haven't put the function call in the html
willcodes
@willcodes
Jul 14 2016 02:52
FCC didnt show it right?
NPeyralans
@NPeyralans
Jul 14 2016 02:52
@willcodes Lots of suffering my friend, and still more of it for me!
robertky
@robertky
Jul 14 2016 02:52
Does anyone know why, when I try to make a basic table header row with one "element", it won't show up?
I am going to make the table bigger, but just want to at least make one cell show up first and it wont show up :/.
NPeyralans
@NPeyralans
Jul 14 2016 02:53
@willcodes Not much from fcc on the ajax front... Seems to be the most difficult topic too
willcodes
@willcodes
Jul 14 2016 02:55
ok because I am on the random quote generator and I have no idea how to use javascript to use a .json quote thing
i tried going through the .json lesson but it doesnt seem to pull the data from .json
NPeyralans
@NPeyralans
Jul 14 2016 02:55
@willcodes i was in the same boat. Lots of suffering. Lots of suffering. Trial error. Nights without sleep. Families neglected. Can't stop thinking about solving the problem. Obsession. Etc...
willcodes
@willcodes
Jul 14 2016 02:57
this is not comforting
James S.
@Mrblue27
Jul 14 2016 02:57
``````// Setup
function testStrict(val) {
if (val === 7)
if (val === "7"){ // Change this line
return "Equal";
}
return "Not Equal";
}

// Change this value to test
testStrict(10);``````
How can I get the number 7 to be equal.
robertky
@robertky
Jul 14 2016 02:57
ANYONE?????
Do you know why my table wont show up in the code with javascript?
ronaldrdguez
@ronaldrdguez
Jul 14 2016 03:04

``````var body=document.getElementsByTagName('body')

body.appendChild(table);``````

`getElementsByTagName()` returns a collection, not a single element, you need to change that last line to `body[0].appendChild(table)`

robertky
@robertky
Jul 14 2016 03:07
Ahh, ok thanks.
ronaldrdguez
@ronaldrdguez
Jul 14 2016 03:07
np
Clayharms
@Clayharms
Jul 14 2016 03:08

Hi I could use some help please:

"Convert the switch statement into a lookup table called lookup. Use it to lookup val and assign the associated string to the result variable."

function phoneticLookup(val) {
var result = "";

// Only change code below this line
val "???" = {
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
};

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

Where I put "val "???" = {" I'm not sure what this line is supposed to say so that I can "lookup" my table
David Halls
@DavidHalls
Jul 14 2016 03:09
@Clayharms try switch(val) and work from there
Clayharms
@Clayharms
Jul 14 2016 03:10
I'm not allowed to use switch for this exercise
David Halls
@DavidHalls
Jul 14 2016 03:11
oh, what problem is it?
Clayharms
@Clayharms
Jul 14 2016 03:11
"Using Objects for Lookups"
'Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a switch statement or an if/else chain. This is most useful when you know that your input data is limited to a certain range.'
Jul 14 2016 03:11
```if (val === 7) if (val === "7")``` @Mrblue27 should be ```if(val ==7 || val == "7"){}
Rahul Nayak
@pragyes31
Jul 14 2016 03:14

@NPeyralans which function call?

@pragyes31 You haven't put the function call in the html

Stephen James
@sjames1958gm
Jul 14 2016 03:14
@robertky You were appending strings not variable and document.table is not valid just use table, same with document.trow
``````var body = document.getElementsByTagName('body')[0];
var table = document.createElement('table');
body.appendChild(table);
var trow=document.createElement('tr');
table.appendChild(trow);
//for(var i=0;i<4;i++)
//{
//}

document.getElementsByTagName('body')[0].appendChild(table);``````
@Clayharms var lookup = your object
Jason
@albionlos
Jul 14 2016 03:15
// Setup
var outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
var myOutfit = "sweater";// Only change code above this line
return outerWear;
}
myOutfit();
Stephen James
@sjames1958gm
Jul 14 2016 03:16
@albionlos You should not be using the function name in your var myOutfit
Jason
@albionlos
Jul 14 2016 03:17
ok ty
Rahul Nayak
@pragyes31
Jul 14 2016 03:18
@ankitagar why did you parse the response. It was already an object?
David Halls
@DavidHalls
Jul 14 2016 03:19
@Clayharms var lookup = { --- this is first thinig you need to do
Eduardo Santos
@eddysantos
Jul 14 2016 03:19
@Chrono79 I didn't thank you for your help!! Thanks!!
CamperBot
@camperbot
Jul 14 2016 03:19
:star2: 1517 | @chrono79 |http://www.freecodecamp.com/chrono79
eddysantos sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
Xavier Velez
@JonSnow08
Jul 14 2016 03:22
I need a bit of help with using jQuery to get API data for the weather app if anybody has a second
bitgrower
@bitgrower
Jul 14 2016 03:23
@Chrono79 is awesome !!!
Xavier Velez
@JonSnow08
Jul 14 2016 03:24
``````\$("document").ready(main);

function main() {
//This gets the users location and stores it in already defined globals
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var long = position.coords.longitude;
var latt = position.coords.latitude;
});
}
var weatherData =  \$.getJSON("api.openweathermap.org/data/2.5/weather?lat=" + latt + "&lon=" + long + "&appid=ca1580d2338e3d7f84fec44abbe30b11");
console.log(weatherData);
}
console.log(weatherData);``````
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:26
wiki format
CamperBot
@camperbot
Jul 14 2016 03:26

Multi line Code

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

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

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

Single line Code

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

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

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

function updateRecords(id, prop, value) {

if(prop === "tracks"){
collection[id].tracks.push([value]);
}

else if (prop==="tracks" && value === ""){
delete collection[id][prop];
}
else {
collection[id][prop].push(value);
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
/``````
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:29
So i'm on "Returning Boolean Values from Functions". Fix the function isLess to remove the if/else statements. Here is my code and it's not working.
``````function isLess(a, b) {
// Fix this code
switch (isLess) {
case 10, 15:
break;
case 15, 10:
break;
}
}
// Change these values to test
isLess(10, 15);``````
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:30
case 10: case 15: MAke this correction @geekysmurf123
You are missing ":"
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:31
@SopanTripathi but they both have 10 and 15
Moredou
@Moredou
Jul 14 2016 03:31
anyone there?
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:31
yeppers
robertky
@robertky
Jul 14 2016 03:32

Hi everyone, does anyone know why the below code won't work?

```

var table = document.createElement('table');
document.body.appendChild('table');
Moredou
@Moredou
Jul 14 2016 03:32
I have a problem, can you help me ?
the Counting Cards?
robertky
@robertky
Jul 14 2016 03:32
``````var table = document.createElement('table');
document.body.appendChild('table');``````
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:32
@geekysmurf123 You can write more simpler function without cases... or without hardcoding numbers.... See this:
robertky
@robertky
Jul 14 2016 03:32
The console says, "TypeError: Argument 1 of Node.appendChild is not an object""
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:33
``````
function isLess(a, b) {
// Fix this code
return a<b;
}

// Change these values to test
isLess(10, 15);

/``````
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:33
that's farther ahead than i, but it seems that you are identifying an ID. is it a class?
@SopanTripathi lol. ty. i was making it harder than it needed to be
CamperBot
@camperbot
Jul 14 2016 03:34
geekysmurf123 sends brownie points to @sopantripathi :sparkles: :thumbsup: :sparkles:
help me
CamperBot
@camperbot
Jul 14 2016 03:36

:point_right: adding snippets to sublime text [wiki]

If you are a user of sublime text (I hope you are, it kicks ass. You can get it here), then you may have already noticed some of the tab completion capabilities. For example, when you are opening an html tag such as `<p>`, it automatically closes the tag as soon as you type `/`. You can get similar functionality for pieces of code you end up re-writing over and over, and it's surprisingly easy!

Here's an example, which activates after typing `div` and then tab:

bitgrower
@bitgrower
Jul 14 2016 03:37
@SopanTripathi did you get help with your push function ?
Moredou
@Moredou
Jul 14 2016 03:38
bitgrower
@bitgrower
Jul 14 2016 03:38
can you post your code, @Moredou ?
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:38
@bitgrower No....Its been 2 days... and i am not bale to move ahead
Moredou
@Moredou
Jul 14 2016 03:38
i have no idea
@bitgrower i have no idea
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:39
i hate to say it but this site has a major issue when going to the next subject. you have no basis and they don't explain it. prior. I am just going through the javascript right now, but it seems to me that you need to already know it before starting this program, which is not what i got out of the website
Jose Colmenares
@jlrcolm
Jul 14 2016 03:39
Hello! I have many problems with this challenge https://www.freecodecamp.com/challenges/profile-lookup
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:40
i am getting a little irritated because of this
robertky
@robertky
Jul 14 2016 03:41
Does anyone know why this won't add a table onto the skeleton on HTML?
bitgrower
@bitgrower
Jul 14 2016 03:41
@geekysmurf123 -- the folks in here are volunteers -- I'm sorry you're having problems ... but I'm not involved with the overall design ... I'm just here, as many of the volunteers are, to help with immediate js problems ...
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:41
it keeps jumping from concept to concept without telling you how.
robertky
@robertky
Jul 14 2016 03:41
``var table = document.createElement('table'); document.body.appendChild('table');``
The console says, "TypeError: Argument 1 of Node.appendChild is not an object""
bitgrower
@bitgrower
Jul 14 2016 03:41
I'm sorry -- but i can only help with specific js problems ... not the design of curriculum ...
robertky
@robertky
Jul 14 2016 03:41
Does anyone know why the above code wont even work?
It's only two lines.
bitgrower
@bitgrower
Jul 14 2016 03:42
@SopanTripathi - any time you have an error where you get function not found or not defined, it means the variable you are using is not seen as the right type ...
Jose Colmenares
@jlrcolm
Jul 14 2016 03:42
I want to print the something inside all the values of contacts[number].property but console.log doesn't not work
bitgrower
@bitgrower
Jul 14 2016 03:42
overall folks ... if you have problems with a specific challenge, you can also get hints from the wiki ...
like so
help profile lookup
CamperBot
@camperbot
Jul 14 2016 03:42

Challenge Profile Lookup

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

We have an array of objects representing different people in our contacts lists.

A `lookUpProfile()` function that takes firstName and a property (prop) as arguments has been pre-written for you.

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the value of that property.

If firstName does not correspond to any contacts then return `No such contact`.

If prop does not correspond to any valid properties then return `No such property`.

• Change the code below `// Only change code below this line` and up to `// Only change code above this line`.
• Ensure that you are editing the inside of the `lookUpProfile()` function.
bitgrower
@bitgrower
Jul 14 2016 03:43
or help record collection
oops
help record collection
CamperBot
@camperbot
Jul 14 2016 03:43

Challenge Record Collection

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

bitgrower
@bitgrower
Jul 14 2016 03:43
so, if there isn't someone here to immediately help you (remember, we're all volunteers) -- you might be able to get some help by looking at the wiki pages and the hints ...
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:44
well, i just had help on the last problem becuase it skipped to a new concept. now i am having a problem with this concept. Return Early Pattern for Functions = Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
``````// Setup
function abTest(a, b) {
// Only change code below this line
return a | b < 0;

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);``````
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:44
@bitgrower So, what variable is nto right in my code: ?
robertky
@robertky
Jul 14 2016 03:44
``````var table = document.createElement('table');
document.body.appendChild('table');``````
The above code doesn't work, does anyone know why :/? I have tried multiple things, all I'm trying to do is add a table element onto the body of a skeleton HTML doc. Why does the console say, ""TypeError: Argument 1 of Node.appendChild is not an object""?
bitgrower
@bitgrower
Jul 14 2016 03:45
@SopanTripathi -- I'm guessing it's this line (sorry for the delay, I had to scroll up) ... Hang on just one more help, I hope
@all -- you can also try running your code thru pythontutor.com/javascript.html ... and you can see where your code (often times) goes off into the weeds -- you can step thru your code and watch as it illustrates what's happening in your variables & in memory ... it's pretty awesome ...
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:47
can anyone help me with my last post
Jaren Escueta
@jarenescueta731
Jul 14 2016 03:50
@geekysmurf123 what have you tried so far?
bitgrower
@bitgrower
Jul 14 2016 03:50

@SopanTripathi what's happening is, I believe, (it's hard to track at the moment, hang on, and I'll try and grab your code) ... is there's a test case -- the 2nd one for record collection, which attempts to add an array value to the tracks property -- except for the particular record you are trying to add it to has NO tracks property ... so you have to add it ... and adding a property is pretty simple ... if I have a record with an id, I can add a property & a value all in one line of code ...

collection[id][prop] = [value];

like that ...

Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:51
@jarenescueta731 only what you see because i have no idea what they want and had no info prior.
Xavier Velez
@JonSnow08
Jul 14 2016 03:51
am I in the wrong chat to get help with the weather app bonfire?
CamperBot
@camperbot
Jul 14 2016 03:51
type `bonfire name` to get some info on that bonfire. And check HelpBonfires chatroom
bitgrower
@bitgrower
Jul 14 2016 03:51
this has the potential to add the tracks property to the record id, with the array element value ...
@JonSnow08 -- you can check out the frontend room
help rooms
CamperBot
@camperbot
Jul 14 2016 03:52

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap `FreeCodeCamp/Help`
JavaScript/Algorithms `FreeCodeCamp/HelpJavaScript`
Front End `FreeCodeCamp/HelpFrontEnd`
Data Visualization `FreeCodeCamp/HelpDataViz`
Back End `FreeCodeCamp/HelpBackEnd`

Choose the right room for your questions!

`back to top ↑`

Xavier Velez
@JonSnow08
Jul 14 2016 03:52
@bitgrower oh okay thank you
CamperBot
@camperbot
Jul 14 2016 03:52
jonsnow08 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1138 | @bitgrower |http://www.freecodecamp.com/bitgrower
Xavier Velez
@JonSnow08
Jul 14 2016 03:52
@bitgrower even if its a JS API question?
bitgrower
@bitgrower
Jul 14 2016 03:52
especially if it's a js api question -- that room is for the front end projects that are part of the curriculum ... :)
like the one you are working on :)
Jeremiah Kalb
@geekysmurf123
Jul 14 2016 03:53
i think i am just going to stop and do my training elsewhere. it's to bad because i was going to donate a lot of my time when finished
later everyone
bitgrower
@bitgrower
Jul 14 2016 03:53
there's always a trade off ... hope you find what you're looking for @geekysmurf123 ...
Xavier Velez
@JonSnow08
Jul 14 2016 03:54
@bitgrower thank you
CamperBot
@camperbot
Jul 14 2016 03:54
jonsnow08 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: jonsnow08 already gave bitgrower points
Vivek Tripathi
@SopanTripathi
Jul 14 2016 03:54
@bitgrower I am remodifying my code... Will send you brownie ...in case...solve it... :D
Jaren Escueta
@jarenescueta731
Jul 14 2016 03:56
@geekysmurf123 yeah it can be hard to get help with a problem when you don't even know what the problem is
Lee
@leebut
Jul 14 2016 04:04

@geekysmurf123 I understand your concerns. I have had WTF moments during the javaScript challenges. It does seem like there is not enough depth of input in some cases, and the project examples use additional code to that taught (bootstrap example uses a jumbotron, which was not taught). However, what it does do, is force you to find solutions to problems, which may be better for you in the the long-term. After all, people learn when they do things, and not necessarily when they are shown.
To deal with that aspect, I have started writing my own examples in an editor to help me consolidate each challenge.

You also have to consider that this is leading to practical tasks and potentially work.

Slava Knyazev
@knyzorg
Jul 14 2016 04:06
Anybody on free to help?
Stuck on "Sum All Primes"
sumPrimes(10) works
sumPrimes(977) does not
Gives me a number slightly less than 1000 too low
I thought it was my algo to determine if a number is prime but I tried other ones from the web
None worked
I get 72179 for 977
Could this be a bug?
shanshanwen
@shanshanwen
Jul 14 2016 04:12

function queue(arr, item) {

return item; // Change this line
}

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

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

This message was deleted
Write a function to the queue, using an array arr and a digital item as an argument.Digital item added to the end of the array, and then remove the first element of the array, the queue function should return the removed element.
For help
Some people?
Jaren Escueta
@jarenescueta731
Jul 14 2016 04:19
@shanshanwen what is the name of that challenge?
silver537
@silver537
Jul 14 2016 04:20
@shanshanwen what array method adds an element to the end of the array. And what method takes the first element? Youve done this in a previous challenge.
shanshanwen
@shanshanwen
Jul 14 2016 04:26
How did this challenge?
silver537
@silver537
Jul 14 2016 04:26
Eh nvm.
shanshanwen
@shanshanwen
Jul 14 2016 04:26
Stand in Line
The name
Jaren Escueta
@jarenescueta731
Jul 14 2016 04:27
@silver537 lol
@silver537 no you're right
silver537
@silver537
Jul 14 2016 04:30
CamperBot
@camperbot
Jul 14 2016 04:30
Jaren Escueta
@jarenescueta731
Jul 14 2016 04:30
thanks camperbot
@silver537 about what you told @shanshanwen
silver537
@silver537
Jul 14 2016 04:32
Oh yea. Im,not giving the answer. Thats not how you learn. Besides, theres a wiki section that gives you the answer for all of the challenges.
Help stand in line
CamperBot
@camperbot
Jul 14 2016 04:32

Challenge Stand In Line

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

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.

• Change the code below `//Your Code here` and up to `//Change this line`.
• Ensure that you are editing the inside of the `nextInLine` function.
• Use an array function you learned to add the item to the end of the array arr.
• Use an array function you learned to remove the first element from array arr.
• Return the element removed.

Viknesh
@vk2mars
Jul 14 2016 04:32
help Sum All Odd Fibonacci Numbers
CamperBot
@camperbot
Jul 14 2016 04:32

Algorithm Sum All Odd Fibonacci Numbers

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

silver537
@silver537
Jul 14 2016 04:32
@shanshanwen :point_up_2:
Jaren Escueta
@jarenescueta731
Jul 14 2016 04:33
@silver537 oh i didn't realize he was asking for the answer straight up
silver537
@silver537
Jul 14 2016 04:33
They all do. -_- at least what ive seen.
Viknesh
@vk2mars
Jul 14 2016 04:35
Hi so I'm working on the Sum All Odd Fibonacci Numbers question, but am unable to pass the very last scenario, sumFibs(75025).
``````function sumFibs(num) {
var a =[1,1];
var preval = 1;
var curval = 1;
var newval = 2;
while (curval < num){
newval = curval + preval;
preval = curval;
curval = newval;
if (curval%2 == 1){
a.push(curval);
}
}
a = a.splice(0,a.length-1);
var sum = a.reduce(function(a, b) { return a + b; }, 0);
return sum;
}``````
Not sure why it doesn't work for only that case...thoughts?
Jaren Escueta
@jarenescueta731
Jul 14 2016 04:38
@vk2mars all the previous cases have been even (besides 1 which checks if it returns a number), does it work for all odd numbers?
Jod
@jod29
Jul 14 2016 04:52
Need help. I got 7/9 of the tests. Last two bottom won't pass the test.
``````
function mutation(arr) {
arr0 = arr[0].toLowerCase();
arr1 = arr[1].toLowerCase();
var arr2;
for (var i = 0, len = arr1.length; i<len; i++) {
arr2 = arr0.indexOf(arr1.charAt(i));}
if (arr2 !== -1)
return true;
else
return false;
}

mutation(["hello", "hey"]);``````
Markus Kiili
@Masd925
Jul 14 2016 04:53
@jod29 You need to return false if the character is not found and figure out where to return true.
@vk2mars Are you generating fibos up to and including num?
Jod
@jod29
Jul 14 2016 04:55
any hint? :)
Markus Kiili
@Masd925
Jul 14 2016 04:56
@vk2mars You test curval and then you generate a larger number and push it. Should you be testing the pushed number?
Jod
@jod29
Jul 14 2016 04:58
tnx @Masd925 . be back later. my class is about to start.
Markus Kiili
@Masd925
Jul 14 2016 05:02
@vk2mars Code works if you use `curval<=num`, but the logic could be clearer.
Edmund To
@edmundtfy
Jul 14 2016 05:02

Hello, here's snippet of my code and I don't know why it doesn't work:

``````function search() { // this is the start of my js, declaring a function
//declaring some variables here to get the URL I want
\$.getJSON(URL, function(data) { //I declared the URL variable and tested it, it's fine
});``````

and there is no window alert...

silver537
@silver537
Jul 14 2016 05:03
I dont think you need the window object.
Edmund To
@edmundtfy
Jul 14 2016 05:04

what do you mean? just

``alert('hi');``

?

@silver537 just tried, doesn't work either. Actually all the code inside getJSON doesn't work
silver537
@silver537
Jul 14 2016 05:06
Hmmm. Input the whole alert in quotes. I never messed with json but i remember something about code being inside quotes.
When everything fails, turn to documents!
Edmund To
@edmundtfy
Jul 14 2016 05:07
@silver537 nope nothing happens~! what do you mean turn to documents?
silver537
@silver537
Jul 14 2016 05:09
Documentation. I cant link it since im on my phone. But just search up JSON documentation. And it should give you some websites with references on json information
Edmund To
@edmundtfy
Jul 14 2016 05:09
and by the way, I link that "search" function to a button. when I put the entire javascript inside a document-ready function (advised by FreeCodeCamp), it doesn't work... is it something with browser?
Edmund To
@edmundtfy
Jul 14 2016 05:23
hello, can anybody explain this error? XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrsearch=Albert%20I&gsrlimit=5. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.
hello, can anybody explain this error?
``` ```
sorry... can anybody explain this error?
``XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrsearch=Albert%20I&gsrlimit=5. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s.codepen.io' is therefore not allowed access.``
Markus Kiili
@Masd925
Jul 14 2016 05:27
@edmundtfy Are you using `jsonp`?
Edmund To
@edmundtfy
Jul 14 2016 05:30
@Masd925 the original code is
``````\$.getJSON(URL, function(data) { //I declared the URL variable and tested it, it's fine
});``````
@Masd925 thanks, but sorry, problem solved, I forgot to add &callback=?.........
CamperBot
@camperbot
Jul 14 2016 05:31
edmundtfy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2109 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Jul 14 2016 05:35
I wanna see how you solved it
Subramanya Chakravarthy
@chakrihacker
Jul 14 2016 05:47
help mutations
CamperBot
@camperbot
Jul 14 2016 05:47

Algorithm Mutations

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

• Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..

jasonsalcedo543
@jasonsalcedo543
Jul 14 2016 05:50
HELP! On the console my Output is working but. The test doesnt consider my answer.
Exercise - Testing Objects for Properties
CamperBot
@camperbot
Jul 14 2016 05:50
no wiki entry for: `on the console my output is working but the test doesnt consider my answerexercise - testing objects for properties`
jasonsalcedo543
@jasonsalcedo543
Jul 14 2016 05:50

// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
if (myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
} else {
}
}

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

Moyosore Sosan
@Mohyour
Jul 14 2016 05:51
Hi guys
``````var Bike = function() {

// Only change code below this line.
var gear;
this.getGear=function(){
return this.gear;
};
this.setGear=function(gear){
gear=gear;
};
};``````
Markus Kiili
@Masd925
Jul 14 2016 05:53
@Mohyour There is no property `this.gear` on the object. `return this.gear` < - undefined
Also don't shadow the private variable with the method parameter `function(gear)` (choose another name).
Moyosore Sosan
@Mohyour
Jul 14 2016 05:56
@Masd925 Thanks so much, that helped. modified my code to:
``````var Bike = function() {

// Only change code below this line.
var gear;
this.getGear=function(){
return gear;
};
this.setGear=function(gears){
gear=gears;
};
};``````
CamperBot
@camperbot
Jul 14 2016 05:56
mohyour sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2110 | @masd925 |http://www.freecodecamp.com/masd925
Moyosore Sosan
@Mohyour
Jul 14 2016 05:57
That worked
Markus Kiili
@Masd925
Jul 14 2016 05:58
@Mohyour Good. A name like `newGear` would be good for the method parameter.
Moyosore Sosan
@Mohyour
Jul 14 2016 05:59
@Masd925 Okay, appreciate the help
Zina Astafyeva
@tragetraje
Jul 14 2016 06:07
help Find the Longest Word in a String
CamperBot
@camperbot
Jul 14 2016 06:07

Algorithm Find the Longest Word in a String

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

:checkered_flag: Problem Explanation:

You have to go through each word and figure out which one is the longest and return not the word, but how many characters it has.

Mustafijur rahman
@Dinar717
Jul 14 2016 06:08
@tragetraje split the string then find the length of every word.
then which one become longest return the length
Markus Kiili
@Masd925
Jul 14 2016 06:10
@Dinar717 Do you mean split the string?
Mustafijur rahman
@Dinar717
Jul 14 2016 06:10
@Masd925 yes
Zina Astafyeva
@tragetraje
Jul 14 2016 06:18
Hi @Dinar717, i kind of understand what to do but can't figure out how :) i've split the string, should i declare a new variable to keep track of the current longest word?
Mustafijur rahman
@Dinar717
Jul 14 2016 06:19
Zina Astafyeva
@tragetraje
Jul 14 2016 06:20
almost nothing to post here...
``````function findLongestWord(str) {
var newStr = str.split(' ');
var longestStr = '';
for(var i=0; i < newStr.length; i++) {

}

return str.length;
}``````
Amey Singh
@AmeySingh
Jul 14 2016 06:20
guys whats wrong with is code

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

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

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

Zina Astafyeva
@tragetraje
Jul 14 2016 06:21
@Dinar717 and now compare the first word with the consecutive ones, if it's longer than it's the current longest word, if there is no longer word, return it..?
Mustafijur rahman
@Dinar717
Jul 14 2016 06:22
@tragetraje yes
you can declare a variable for longest length
Zina Astafyeva
@tragetraje
Jul 14 2016 06:24
aha, ok, thanks @Dinar717 will try to figure it out on my own then
CamperBot
@camperbot
Jul 14 2016 06:24
tragetraje sends brownie points to @dinar717 :sparkles: :thumbsup: :sparkles:
Mustafijur rahman
@Dinar717
Jul 14 2016 06:24
@tragetraje :+1:
seegi
@seegi
Jul 14 2016 06:27
Hello
I want to learn JS what should i do give some suggesion
Subroto
@Shub1427
Jul 14 2016 06:28
In Counting Cards section, we need to give output only for the last call to cc([card]) function. How is it even possible?
@seegi use freecodecamp to learn it
seegi
@seegi
Jul 14 2016 06:28
Where i will get excise code in JS
Where bro can send me link
@Shub1427
Markus Kiili
@Masd925
Jul 14 2016 06:29
@Shub1427 Check `card` and change value of global variable `count` accordingly. Then figure out the return value from `count` (not `card`).
Aayush Sharma
@techdiary
Jul 14 2016 06:32
`var myStr = "FirstLine\n \\SecondLine\\ \rThirdLine"`
Guys i'm stuck in this
help me/
CamperBot
@camperbot
Jul 14 2016 06:32

Via GUI

2. Open Varpanel.
3. In PATH variable, add the relevant path (for example).

Via Command Line

Refer to this answer on Super User.

Subroto
@Shub1427
Jul 14 2016 06:33

@Masd925 The solution that u r suggesting will output a return statement for each card:

cc(2) - // "1 Bet"
cc(3) _ //"2 Bet"

n so on.... But instead i need output for only last cc() call

jeremywu
@JeremyWuuuuu
Jul 14 2016 06:33
guys plz help me with the subject named "profile lookup"
Subroto
@Shub1427
Jul 14 2016 06:33
@techdiary remove spaces in your string
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:33
function lookUp(firstName, prop){
// Only change code below this line
for (var i = 0; i< 4;i++){
if (contacts[i].firstName !== firstName){
`````` return "No such contact";}
else
if(contacts[i][prop]!==prop){
return "No such property";
}
else return [prop];
}``````
my loop here seems not working
Markus Kiili
@Masd925
Jul 14 2016 06:34
@Shub1427 No. The value of card should change count, and count determines the return value. Count is a global variable that has a value before the function call is made.
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:34
i don't know how
Aayush Sharma
@techdiary
Jul 14 2016 06:34
i did and it's not working @Shub1427
Gregory Garzon
@chibieee
Jul 14 2016 06:35
@JeremyWuuuuu what lesson?
Subroto
@Shub1427
Jul 14 2016 06:35
use terminater then `;` @techdiary
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:36
"profile lookup"
Aayush Sharma
@techdiary
Jul 14 2016 06:36
@Shub1427 It worked now :sparkles:
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:36
god ..it's killing me
Gregory Garzon
@chibieee
Jul 14 2016 06:39
what error are you getting?
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:39
my loop seems not working
it stucked at 3;
i did a 0to3 loop but it just not working
Markus Kiili
@Masd925
Jul 14 2016 06:40
@JeremyWuuuuu You are returning no such contact after checking one contact.
Subroto
@Shub1427
Jul 14 2016 06:40

@Masd925 Thanx for ur help.... Actually never even tried running the code once... It's ok if the function returns a string for each call...

I thought if there are 5 calls then the last call should only return a string. Others should not, which was wrong :smile:

CamperBot
@camperbot
Jul 14 2016 06:40
shub1427 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2111 | @masd925 |http://www.freecodecamp.com/masd925
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:41
what does that mean .. can u be more specific?
Markus Kiili
@Masd925
Jul 14 2016 06:41
@JeremyWuuuuu You can only return no such contact after checking all the contacts.
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:42
okay .. i get it so how am i supposed to fix it?
Markus Kiili
@Masd925
Jul 14 2016 06:42
@JeremyWuuuuu Easiest is to make two nested if's for the firstname check and property existence check (positive checks). Then just put returns on correct spots.
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:43
i see
Markus Kiili
@Masd925
Jul 14 2016 06:43
@JeremyWuuuuu Proper way to make the property existence check is .hasOwnProperty() or .propertyIsEnumerable().
jeremywu
@JeremyWuuuuu
Jul 14 2016 06:43
thx a lot
thx man . u helped a lot
anvarov
@anvarov
Jul 14 2016 06:44

hello, I stucked at Wherefore art thou bonfire. I have to make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument). Each property and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.

For example, if the first argument is [{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], and the second argument is { last: "Capulet" }, then you must return the third object from the array (the first argument), because it contains the property and its value, that was passed on as the second argument.

This message was deleted
Magnus Holm
@mghlm
Jul 14 2016 06:46
I am completely stuck in one of the assignments - would you recommend me to skip it and go on, or should I try to look up the solution? I have spent close to an hour trying to break through now, but I just can’t seem to understand it..
Faisal Zulfiqar
@faisal1337
Jul 14 2016 06:47

In challenge [237] it says that
"You can invert any match by using the uppercase version of the regular expression selector.
For example, \s will match any whitespace, and \S will match anything that isn't whitespace."

and I only pass the challenge when I use '/\S/g'. With a '+' operator I cannot pass it. Why the

• operator is not required here?
anvarov
@anvarov
Jul 14 2016 06:47
so i wrote this function:
``````function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var newArr = [];
arr = Object.keys(source);
for (var i = 0; i <= collection.length + 1; i++) {
for (var j = 0; j <= source.length + 1; j++) {
if (collection[i].hasOwnProperty(arr(j)) && collection[i][arr(j)] === source[arr(j)]) {
newArr.push(collection[i]);
}
}
}
// Only change code above this line
return newArr;
}``````
Markus Kiili
@Masd925
Jul 14 2016 06:48
@m4gnusholm What challenge? You can post your code and try get help here first.
@anvarov Try to format the code:
explain format
CamperBot
@camperbot
Jul 14 2016 06:48

Multi line Code

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

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

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

Single line Code

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

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

Gregory Garzon
@chibieee
Jul 14 2016 06:48
Magnus Holm
@mghlm
Jul 14 2016 06:49
@Masd925 it’s the “Profile Lookup” one, number 217. I am supposed to write a function that checks for names, but all I can come up with is the if/else, I just can’t figure out how to use the while loop that I think I’m supposed to use
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 06:50

I have zero clue what to do for Chunky Monkey. Anyone that can point me in the right direction?

`
function chunkArrayInGroups(arr, size) {
var newArray = [];

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

return arr;
}

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

Magnus Holm
@mghlm
Jul 14 2016 06:50
It’s an array with several objects inside. I can’t figure out what to do with the loop
Markus Kiili
@Masd925
Jul 14 2016 06:50
@anvarov Only push if the property values match for all the source keys, not just one.
Faisal Zulfiqar
@faisal1337
Jul 14 2016 06:50

In challenge [237] it says that
"You can invert any match by using the uppercase version of the regular expression selector.
For example, \s will match any whitespace, and \S will match anything that isn't whitespace."

and I only pass the challenge when I use '/\S/g'. With a '+' operator I cannot pass it. Why the '+' operator is not required here? We shouldn't stop on the first Non-space character should we? Please explain.

anvarov
@anvarov
Jul 14 2016 06:50
@m4gnusholm but I'm getting empty array, I think the problem is here `if (collection[i].hasOwnProperty(arr(j)) && collection[i][arr(j)] === source[arr(j)])`
it gives always `false` condition i think
Faisal Zulfiqar
@faisal1337
Jul 14 2016 06:51
SOMEONNNEEE???
Markus Kiili
@Masd925
Jul 14 2016 06:51
@m4gnusholm The simplest structure is two nested if's inside the contact loop. First if should check if the firstName property of the looped contact is equal to the value of firstName parameter (is it the contact we look for).
Magnus Holm
@mghlm
Jul 14 2016 06:52
@Masd925 should i use for or while loop?
Markus Kiili
@Masd925
Jul 14 2016 06:52
@m4gnusholm For loop might be simpler.
Magnus Holm
@mghlm
Jul 14 2016 06:52
@Masd925 ok, but should i use i<array.length ?
if i do that, does it take the number of objects in the array?
Markus Kiili
@Masd925
Jul 14 2016 06:53
@anvarov `arr(j)` <- problem here. An array, not a function.
@anvarov You need to change the loop logic to push only if the property values match for all the source keys.
@Digital-Banana It is easier if you increment i by +=size. Then you could make slices of arr with .slice() and push them to a result array. Just figure out correct slice arguments.
Magnus Holm
@mghlm
Jul 14 2016 06:57
@Masd925 this aint working:
``````for (i=0; i<contacts.length; i++) {
if((contacts.firstName === firstName) && (contacts.hasOwnProperty(prop) === true)) {
return contacts[prop];
}
}``````
Markus Kiili
@Masd925
Jul 14 2016 06:58
@m4gnusholm `contacts` is an array. It has no .firstName property.
How do you access the looped contact?
@m4gnusholm Two nested if's makes a simpler solution.
Magnus Holm
@mghlm
Jul 14 2016 06:59
@Masd925 i don’t know then. what’s the name of the objects?
Markus Kiili
@Masd925
Jul 14 2016 06:59
`contacts` is an array and you loop the array indices. How do you access array elements?
Magnus Holm
@mghlm
Jul 14 2016 06:59
with brackets
contacts[]
?
Markus Kiili
@Masd925
Jul 14 2016 06:59
`contacts[i]` is one contact, yes.
Magnus Holm
@mghlm
Jul 14 2016 07:00
so, if(contacts[i].firstName === firstName ?
i don’t know how to access the firstName property of each of the contacts
Markus Kiili
@Masd925
Jul 14 2016 07:01
Make the first if only `contacts[i].firstName === firstName)`, and on the if block make another if for the property existence check.
`contacts[i].firstName` is the value of the firstName property.
Magnus Holm
@mghlm
Jul 14 2016 07:01
@Masd925 ok i’ll try, thanks!
CamperBot
@camperbot
Jul 14 2016 07:01
m4gnusholm sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2112 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 14 2016 07:02
Then you only need to add the returns on correct spots. Elses are optional.
anvarov
@anvarov
Jul 14 2016 07:02
@Masd925 "You need to change the loop logic to push only if the property values match for all the source keys." can you explain deeper?
Markus Kiili
@Masd925
Jul 14 2016 07:04
@anvarov You need to check if the condition holds for all the values of `j`. To do it, you can make a flag variable that is set to true by default. If you find a mismatch, you set the flag to false. After the j loop you can check the flag and push if it is true. Basic loop logic for checking if many things are true.
@anvarov Another way would be to use methods like .filter() and .every(). Nothing wrong with loops of course.
Magnus Holm
@mghlm
Jul 14 2016 07:10
@Masd925 How does this look?
``````for (i=0; i<contacts.length; i++) {
if(contacts[i].firstName === firstName) {
if(contacts[i].hasOwnProperty(prop) === true) {
return contacts[i][prop];

} else if((contacts[i].firstName === firstName) === false) {
return "No such contact";
} else if(contacts[i].hasOwnProperty(prop) === false) {
return "No such property";
}
}
}``````
Markus Kiili
@Masd925
Jul 14 2016 07:10
@m4gnusholm You only need the first two if's, and the returns. No more if's.
Magnus Holm
@mghlm
Jul 14 2016 07:10
@Masd925 oh yes of course
@Masd925 after each if, right?
Faisal Zulfiqar
@faisal1337
Jul 14 2016 07:11
@Masd925 how do you return "No such contact" and the "No such property" then?
Magnus Holm
@mghlm
Jul 14 2016 07:11
@Masd925 or wait, how can it know then if it’s the name or property missing?
Markus Kiili
@Masd925
Jul 14 2016 07:12
@m4gnusholm At different parts of the code, different conditions hold or not.
Faisal Zulfiqar
@faisal1337
Jul 14 2016 07:12
I used two other for loops to loop through the whole list and check if they are present. And change the a variable if they are there. And at the end two other if's to return the string accordingly ..
Markus Kiili
@Masd925
Jul 14 2016 07:13
@m4gnusholm For example inside the first if block but after the second if block, you know it is the correct contact but there is no property.
`if(contacts[i].hasOwnProperty(prop) === true)` is the same as `if(contacts[i].hasOwnProperty(prop))`
Magnus Holm
@mghlm
Jul 14 2016 07:16
@Masd925 Ok. But I don’t understand how I am supposed to make it return different strings depending on what statement is false

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property"

Markus Kiili
@Masd925
Jul 14 2016 07:16
@m4gnusholm Put the return after the if block. There the condition is false.
Norvin Burrus
@ndburrus
Jul 14 2016 07:17
@Digital-Banana do you understand the lesson?
Markus Kiili
@Masd925
Jul 14 2016 07:17
@m4gnusholm No such contact belongs after the loop block because only there you have checked all the contacts and no return is made.
Faisal Zulfiqar
@faisal1337
Jul 14 2016 07:18
@m4gnusholm here is my approach. I made two variable for both the conditions and made two other for loops, one to check if the firstName was present and the other to check if the prop was there. If any of the conditions were true inside for loop I would change the variable value from 0 to 1. And at the end I had two if's to check if the value of variable is 0 which means nothing has found then I would return the string accordingly.
Magnus Holm
@mghlm
Jul 14 2016 07:18
@Masd925 But how does it then know when to return “no such contact” versus “no such property” ?
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 07:18
@ndburrus i'm working on it :)
Magnus Holm
@mghlm
Jul 14 2016 07:20
@faisal1337 Thank you, great to see another apporach even though I’m afraid it will confuse me more atm. :)
CamperBot
@camperbot
Jul 14 2016 07:20
m4gnusholm sends brownie points to @faisal1337 :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Jul 14 2016 07:20
@Digital-Banana you may enjoy these: :sparkles:
Markus Kiili
@Masd925
Jul 14 2016 07:20
@m4gnusholm No such contact should be returned after the loop block. No such property should be returned inside the first if block (the first name is correct) but after the second if block (there was no property).
Faisal Zulfiqar
@faisal1337
Jul 14 2016 07:20
`````` var check1 = 0;
var check2 = 0;
for (var j = 0; j < contacts.length; j++) {
if (contacts[j].firstName === firstName) {
check1 = 1;
}
}

for (var k = 0; k < contacts.length; k++) {
if (contacts[k].hasOwnProperty(prop)) {
check2 = 1;
}
}

if (check1 === 0) {
return "No such contact";
}
else if (check2 === 0) {
return "No such property";
}``````
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 07:21
@ndburrus Nice, thanks!!
CamperBot
@camperbot
Jul 14 2016 07:21
digital-banana sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Magnus Holm
@mghlm
Jul 14 2016 07:21
@faisal1337 oh, that’s a smart way to do it!
Norvin Burrus
@ndburrus
Jul 14 2016 07:22
@Digital-Banana you're welcome :) enjoy! :palm_tree:
Magnus Holm
@mghlm
Jul 14 2016 07:22
@Masd925 What is the loop block?
Markus Kiili
@Masd925
Jul 14 2016 07:22
@m4gnusholm For loop block.
Magnus Holm
@mghlm
Jul 14 2016 07:23
@Masd925 what is a block?
Lee
@leebut
Jul 14 2016 07:23

Hello. I'm on the challenge, 'Passing Values to Functions with Arguments'.
The instructions state:

functionWithArgs should be a function
functionWithArgs(1,2) should output 3
functionWithArgs(7,9) should output 16
Call functionWithArgs after you define it.

How do I code to get both calculations into the console? I have:

```// Example
function ourFunctionWithArgs(a, b) {
console.log(a - b);
}
ourFunctionWithArgs(10, 5); // Outputs 5

// Only change code below this line.
function functionWithArgs(a,b){
console.log(a + b);
}
functionWithArgs(1,2);
functionWithArgs(7,9);

Markus Kiili
@Masd925
Jul 14 2016 07:23
@m4gnusholm `{...}`
Lee
@leebut
Jul 14 2016 07:23
The result is always 16.
Magnus Holm
@mghlm
Jul 14 2016 07:23
ok, so when you say the for block you mean everything inside the loop too?
Markus Kiili
@Masd925
Jul 14 2016 07:24
@m4gnusholm With loop block I mean everything inside `for(...){here}`
Norvin Burrus
@ndburrus
Jul 14 2016 07:25
@m4gnusholm these may be helpful: :sparkles:
Magnus Holm
@mghlm
Jul 14 2016 07:25
@Masd925 Ok. I’m sorry but I still don’t understand where to put the return statements - I can’t see how to do it without another if / else statement
Markus Kiili
@Masd925
Jul 14 2016 07:26
@m4gnusholm I mean like this. Try to figure out why they are where they are:
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i<contacts.length; i++) {
if (contacts[i].firstName===firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
return "No such property";
}
}
return "No such contact";
// Only change code above this line
}``````
Magnus Holm
@mghlm
Jul 14 2016 07:26
@Masd925 don’t you have to put “else” ?
@ndburrus thanks
CamperBot
@camperbot
Jul 14 2016 07:26
m4gnusholm sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jul 14 2016 07:26
It is optional, so this works too:
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i<contacts.length; i++) {
if (contacts[i].firstName===firstName) {
if (contacts[i].hasOwnProperty(prop)) {
return contacts[i][prop];
}
else return "No such property";
}
}
return "No such contact";
// Only change code above this line
}``````
Magnus Holm
@mghlm
Jul 14 2016 07:27
@Masd925 ohhh
Norvin Burrus
@ndburrus
Jul 14 2016 07:27
@m4gnusholm you're welcome! enjoy :sparkles:
Faisal Zulfiqar
@faisal1337
Jul 14 2016 07:27
That's neat. :+1:
Magnus Holm
@mghlm
Jul 14 2016 07:27
@Masd925 so does that mean that javascript first reads the first if statement, and if that’s not true, it goes to “else return” and then after that the second if statement?
Markus Kiili
@Masd925
Jul 14 2016 07:28
@m4gnusholm Because there is a return on the if block that terminates the function, the else after the if block is optional.
@m4gnusholm If the firstname check is true, there will always be a return then.
Norvin Burrus
@ndburrus
Jul 14 2016 07:28
@leebut is it resolved?
Lee
@leebut
Jul 14 2016 07:30
@ndburrus Not yet. It appears as though the function is being called but it is only displaying the second call.
Magnus Holm
@mghlm
Jul 14 2016 07:30
@Masd925 I just don’t understand why it would not just return “no such property” if the firstname check was not true but the property was. wouldn’t it read that return before the “no such contact” return ?
Markus Kiili
@Masd925
Jul 14 2016 07:30
@m4gnusholm If the condition on `if` is true, the block is executed. If not, the execution skips the block.
Lee
@leebut
Jul 14 2016 07:31
@ndburrus However, the challenge is showing as successful, but to me it isn't because it is only returning one number to the console, not both. It seems like the instructions are incorrect.
Magnus Holm
@mghlm
Jul 14 2016 07:31
i think i’ll have to read up on blocks...
Markus Kiili
@Masd925
Jul 14 2016 07:32
@m4gnusholm If firstname doesn't match, the whole block `{if (contacts[i].hasOwnProperty(prop)) {return contacts[i][prop];} else return "No such property";}` is skipped and the loop goes to the next step.
Indentation shows the block structure so you can see that from the code.
Lee
@leebut
Jul 14 2016 07:34
The instructions in these challenges are often vague or do not allow for all results to be displayed, just like the Celsius challenge. That states to show various conversions, but does not allow for coding to show all of the solutions.
Magnus Holm
@mghlm
Jul 14 2016 07:35
@Masd925 ok, it’s really hard for me to understand. I wonder if there is some recourse that can visualize it in some way..
Vivek Tripathi
@SopanTripathi
Jul 14 2016 07:36
Guyz, is this 2 same in your opinion:
Markus Kiili
@Masd925
Jul 14 2016 07:36
@m4gnusholm Don't know. Just try to see that if the if condition is false, the whole if block is skipped whatever structures it holds.
Vivek Tripathi
@SopanTripathi
Jul 14 2016 07:37
Guyz, is this 2 same in your opinion: 1. collection[id][prop].push(value); 2. collection[id][prop]= value; ????
Magnus Holm
@mghlm
Jul 14 2016 07:37
@Masd925 Ok, thank you very much for your help!
CamperBot
@camperbot
Jul 14 2016 07:37
m4gnusholm sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: m4gnusholm already gave masd925 points
Vivek Tripathi
@SopanTripathi
Jul 14 2016 07:37
``````collection[id][prop].push(value);
collection[id][prop]= value;``````
Is both of them same ???
Norvin Burrus
@ndburrus
Jul 14 2016 07:38
@leebut does this add clarity? :sparkles:
``````code:
function ourFunctionWithArgs(a, b) {
console.log("a - b: " + (a - b));
}
ourFunctionWithArgs(10, 5); // Outputs 5
// Only change code below this line.
function functionWithArgs(a,b){
console.log("a + b: " + (a + b));
}
functionWithArgs(1,2);
functionWithArgs(7,9);

output:
a - b: 5
a + b: 3
a + b: 16``````
Markus Kiili
@Masd925
Jul 14 2016 07:38
@SopanTripathi First one pushes value to the array in the property value. The second assigns value to the property (possibly overwriting what was there earlier).
r2d2
@UsamaHameed
Jul 14 2016 07:38
Hi, I need help on the same challenge as @SopanTripathi
Magnus Holm
@mghlm
Jul 14 2016 07:39
@Masd925 I think I get it better. so… if name check is true, but property is false, then it returns the else. if name check is false it skips everything and goes to the next number in the array. ok. ok.
Markus Kiili
@Masd925
Jul 14 2016 07:40
Yes.
Magnus Holm
@mghlm
Jul 14 2016 07:40
ok thank you!
does this way of thinking become easier? lol
Markus Kiili
@Masd925
Jul 14 2016 07:41
@m4gnusholm Yes, it does, but you find other things that are hard.
Magnus Holm
@mghlm
Jul 14 2016 07:41
@Masd925 can’t wait ;)
nah, it’s fun so far!
Elizabeth Fine
@elizabethfinedev
Jul 14 2016 07:44
hey guys can anyone help me with a github question or am i in the wrong place?
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 07:45
What's the diference between Slice and Splice? Is there a reason to prefer one over the other?
Markus Kiili
@Masd925
Jul 14 2016 07:46
@Digital-Banana Different syntax and usage. Slice makes a new array, but splice mutates the original.
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 07:47
@Masd925 So why not always use Splice to keep things tidy instead of having a new array?
Lee
@leebut
Jul 14 2016 07:47
@ndburrus Thank you for that. I understand that the numbers are assigned to the 'a' and 'b' arguments. I'm still not sure how your displays both outputs for the functionWithArgs () calls.
CamperBot
@camperbot
Jul 14 2016 07:47
leebut sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Lee
@leebut
Jul 14 2016 07:49

@ndburrus Here's what I did in an external editor to display on a web page.

``````<script>
function leeFunction (num1, num2){

document.getElementById("args").innerHTML = (num1 + num2);
}
leeFunction(5,10); // The numbers are fed into num1 and num2 arguments
leeFunction(6,7); // The numbers are fed into num1 and num2 arguments
</script>``````

This code only displays 13.

Norvin Burrus
@ndburrus
Jul 14 2016 07:49
@BananaHavana this maybe helpful (git): :sparkles:
Elizabeth Fine
@elizabethfinedev
Jul 14 2016 07:49
thank you @ndburrus
CamperBot
@camperbot
Jul 14 2016 07:49
bananahavana sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jul 14 2016 07:50
@Digital-Banana Sometimes you don't want to mutate the original. Maybe you just pass a reference to an array to a function and wan't some information about it in return.
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 07:51
@Masd925 Thanks
CamperBot
@camperbot
Jul 14 2016 07:51
digital-banana sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2113 | @masd925 |http://www.freecodecamp.com/masd925
Norvin Burrus
@ndburrus
Jul 14 2016 07:51
@leebut well, the functions calls happen sequentially, right? one is listed (the function is called/executed), and the next is listed (then that version, different variables, is called/executed)... make sense?
@BananaHavana you're welcome! enjoy :)
Lee
@leebut
Jul 14 2016 07:52
@ndburrus Yes, it does. However, the instructions in the challenge imply that both results should be shown.
And the challenge passes when only one solution is shown.
Evan
@EvanDCP
Jul 14 2016 07:54
can somebody check my code and see what's wrong please?
``````//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
if(firstName === contacts.firstName && prop == contacts[0] {
return contacts.firstName;
}
else if(firstName !== contacts.firstName) {
return "No such contact";
}
else if(prop !== contacts.prop) {
return "No such property";
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");``````
MT
@tnhminh
Jul 14 2016 07:55
prop == contacts[0]. It wrong here
Markus Kiili
@Masd925
Jul 14 2016 07:55
@EvanDCP `contacts` is an array. It does not have any firstName property. Also `.prop` won't work because
The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: `var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants"`. Bracket notation works with keys that can be arbitrary strings `cat["lives left"]; //returns 3`, variables `var key="clothes"; cat[key]; //returns "pants"`, or expressions `cat["lives"+" "+"left"]; //returns 3`.
MT
@tnhminh
Jul 14 2016 07:56
correct prop === contacts[0] @EvanDCP
Evan
@EvanDCP
Jul 14 2016 07:57
hmm but I'm trying to find first name of the first {}, so number 0, right? what should I write instead?
Markus Kiili
@Masd925
Jul 14 2016 07:57
@tnhminh Not correct because contacts[0] is an object and prop holds a string.
MT
@tnhminh
Jul 14 2016 07:57
Moreover, contact is an array that contain 4 elements, so that can't reference to child's attribute
Norvin Burrus
@ndburrus
Jul 14 2016 07:57
@leebut i understand why one would think that. if we look specifically at what is required - we see that the functionality is really what's being requested. yes, it does indicate that the results be output. but it does not indicate that both functions output should be produced, only that it can be produced from the code. which the code can/will do.
if we examine the requirements, a key word is "should". this implies that if the function were called, then the result would be... clear as mud?
MT
@tnhminh
Jul 14 2016 07:58
thank @Masd925
CamperBot
@camperbot
Jul 14 2016 07:58
tnhminh sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2114 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 14 2016 07:58
@EvanDCP First you need to loop or iterate contacts array.
Evan
@EvanDCP
Jul 14 2016 07:58
okay use a for loop
Norvin Burrus
@ndburrus
Jul 14 2016 07:59
@EvanDCP this may be useful: :sparkles:
Evan
@EvanDCP
Jul 14 2016 08:01
okay I have this now, but still wrong:
``````function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(firstName === contacts[firstName] && prop === contacts[prop] {
return contacts[firstName];
}
else if(firstName !== contacts[firstName]) {
return "No such contact";
}
else if(prop !== contacts[prop]) {
return "No such property";
}``````
Lee
@leebut
Jul 14 2016 08:01
@ndburrus Pehaps the writer of the content should consider sticking to one possible output solution or write something like, ' Try assigning different values to the arguments to create new calculations.' Anyway, thank you for clearing that up for me. :)
CamperBot
@camperbot
Jul 14 2016 08:01
leebut sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: leebut already gave ndburrus points
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 08:02

Looking for advice on Chunky Monkey
`function chunkArrayInGroups(arr, size) {
var chunks = [];

for (var i = 0; i < arr.length; i += size) {
chunks.push(arr.slice(i));
}

return chunks;
}

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

``````function chunkArrayInGroups(arr, size) {
var chunks = [];

for (var i = 0; i < arr.length; i += size) {
chunks.push(arr.slice(i));
}

return chunks;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
Oh i'm suppose to use three of these `
Pedro Abel Díaz Sánchez
@coderHook
Jul 14 2016 08:03
Guys, is there any way to pass a formatted string url as a url in json, I mean that when you click you can access to that website
Norvin Burrus
@ndburrus
Jul 14 2016 08:03
@leebut anytime! :palm_tree:
@Digital-Banana ok.... need to carefully eamine what we're doing here: `(i)` the slice parameters...
also, what needs to happen to the/se slice parameter/s (within the loop)? :) hint/s: chunky, chunk, etc....
Evan
@EvanDCP
Jul 14 2016 08:05
can anyone help?
patrickbarth
@patrickbarth
Jul 14 2016 08:05
@Digital-Banana You slice everything from i to the end;)
@Digital-Banana It would be better if you'd give slice to arguments one for the beginning and 1 for th end;)
So in this case it would be arr.slice(i, i+size); I suppose
Kenny Jeurissen
@Digital-Banana
Jul 14 2016 08:13
Oh i got it, no idea how though... this is my code
``````function chunkArrayInGroups(arr, size) {
var chunks = [];

for (var i = 0; i < arr.length; i) {
chunks.push(arr.slice(i, i += size));
}

return chunks;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);``````
Evan
@EvanDCP
Jul 14 2016 08:18
anybody there?
willfree108
@willfree108
Jul 14 2016 08:18
I'm
Evan
@EvanDCP
Jul 14 2016 08:19
can you look at my code please?
``````
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++) {
if(firstName === contacts["firstName"] && prop === contacts[firstName[prop]]
return contacts[firstName];
}
else if(firstName !== contacts["firstName"]) {
return "No such contact";
}
else if(prop !== contacts[firstName[prop]]) {
return "No such property";

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");``````
willfree108
@willfree108
Jul 14 2016 08:20
u cant check if there no such contact in ur loop
Evan
@EvanDCP
Jul 14 2016 08:21
what do you mean?
willfree108
@willfree108
Jul 14 2016 08:21
coz in the first loop, it'll check if the object exist or not, and always return something. so u'll always check 1 contact
u should put the return "No such contact" after ur loop
Evan
@EvanDCP
Jul 14 2016 08:22
before if(firstname etc.) ?
do I need a second loop? I don't understand
willfree108
@willfree108
Jul 14 2016 08:23
No, ur loop will check all contact
Evan
@EvanDCP
Jul 14 2016 08:23
what's the problem then?
console says: "Unexpected token return"
willfree108
@willfree108
Jul 14 2016 08:24
ur loop check 1 contact no more
if u want the loop to check all contact, u need to remove `else if(firstName !== contacts["firstName"])`
Evan
@EvanDCP
Jul 14 2016 08:25