These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Mar 2016
Davinw
@Davinw
Mar 02 2016 00:02
@Rmpalija Is there supposed to be an exclamation point in "Go Home"? Ie "Go Home!"?
Sergej
@Rmpalija
Mar 02 2016 00:02
yes
Davinw
@Davinw
Mar 02 2016 00:02
@Rmpalija Well I don't see one in your code :)
Sergej
@Rmpalija
Mar 02 2016 00:03
@Davinw yea , just saw it . That was the "error"
Davinw
@Davinw
Mar 02 2016 00:03
Same with Hole in One
Sergej
@Rmpalija
Mar 02 2016 00:03
@Davinw thank you
CamperBot
@camperbot
Mar 02 2016 00:03
rmpalija sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 298 | @davinw | http://www.freecodecamp.com/davinw
Andrew Vanboxel
@avanbox
Mar 02 2016 00:03

I asked this in here earlier and i still havent figured it out. Im working on the "check for a palindrome" problem. Heres my code:
function palindrome(str) {
var newStr = str.replace(/\W/g, '').toLowerCase;
var checkStr=newStr.split('').reverse().join('');
return newStr == checkStr;
}
palindrome("eye");

I am getting an error telling me that newStr.split is not a function. Why?

Davinw
@Davinw
Mar 02 2016 00:03
@Rmpalija Yw! Also, for future reference, you should always use === instead of ==
Rita Alfonso
@alfonsotech
Mar 02 2016 00:07
This message was deleted
help formatting
CamperBot
@camperbot
Mar 02 2016 00:07

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Rita Alfonso
@alfonsotech
Mar 02 2016 00:07
@avanbox ^
Andrew Vanboxel
@avanbox
Mar 02 2016 00:07
figured it out!
the .toLowerCase() was causing it for some reason
Rita Alfonso
@alfonsotech
Mar 02 2016 00:08
@avanbox you are checking the wrong two strings against each other
Davinw
@Davinw
Mar 02 2016 00:08
@avanbox you weren't calling toLowerCase
@avanbox you need the () at the end :)
Rita Alfonso
@alfonsotech
Mar 02 2016 00:09
@avanbox also, use === strict equality, not == where possible
it's hard to look at the unformatted code...
Andrew Vanboxel
@avanbox
Mar 02 2016 00:11
thanks @Davinw @alfonsotech
CamperBot
@camperbot
Mar 02 2016 00:11
avanbox sends brownie points to @davinw and @alfonsotech :sparkles: :thumbsup: :sparkles:
:star: 318 | @alfonsotech | http://www.freecodecamp.com/alfonsotech
:star: 299 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Mar 02 2016 00:11
@avanbox yw!
Andrew Vanboxel
@avanbox
Mar 02 2016 00:12
so to formt the code in here i do `
and then code here?
Rita Alfonso
@alfonsotech
Mar 02 2016 00:12
@avanbox nope, look above for detailed instructions
Andrew Vanboxel
@avanbox
Mar 02 2016 00:13
i did but i dont get it
gvik02
@gvik02
Mar 02 2016 00:14
Need help with Falsy Bouncer
Rami
@RNwebdk
Mar 02 2016 00:25
@avanbox sent you a private message
Will
@wworland
Mar 02 2016 00:25
i got un-busy here at work and looked back at your hints guys and was able to fix my errors and pass the challenge. thanks @Davinw & @chrisdav6
CamperBot
@camperbot
Mar 02 2016 00:25
wworland sends brownie points to @davinw and @chrisdav6 :sparkles: :thumbsup: :sparkles:
:warning: wworland already gave chrisdav6 points
:star: 301 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Mar 02 2016 00:26
@wworland yw!
gvik02
@gvik02
Mar 02 2016 00:29
seems like everyone is very busy
Rami
@RNwebdk
Mar 02 2016 00:30
@gvik02 i wanna help, but haven't got that far yet
gvik02
@gvik02
Mar 02 2016 00:30
I appreciate that @RNwebdk it's ok
Rami
@RNwebdk
Mar 02 2016 00:31
i hope someone else will step in soon and give a hint :)
Davinw
@Davinw
Mar 02 2016 00:31
@gvik02 It's usually easier to just post your actual question rather than to ask permission :)
RNwebdk @RNwebdk pokes @gvik02
gvik02
@gvik02
Mar 02 2016 00:44
Thing is that I have solved it but not in a right way
@Davinw
I tricked it @Davinw
Davinw
@Davinw
Mar 02 2016 00:44
@gvik02 well ask away then :)
gvik02
@gvik02
Mar 02 2016 00:44
I mean the solution
Rami
@RNwebdk
Mar 02 2016 00:49
@gvik02 your not giving us a chance to help m8, share your code , show and tell.
tia
@tvdeleon24
Mar 02 2016 00:59
hey working on "accessing objects properties with variables". having some trouble. can anyone point me in the right direction?

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16]; // Change this Line

Hector Garcia
@augmt
Mar 02 2016 01:00
@tvdeleon24 the challenge wants you to access the object's property using a variable
the key you're using, in this case 16, needs to be stored in a variable
Rita Alfonso
@alfonsotech
Mar 02 2016 01:03
Just finished my local weather app, woot woot!
tia
@tvdeleon24
Mar 02 2016 01:08
@augmt hmm. I'm trying to move things around but I missing the mark.
Davinw
@Davinw
Mar 02 2016 01:09
@alfonsotech grats!
tia
@tvdeleon24
Mar 02 2016 01:09

@augmt // Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var player = testObj[16]; // Change this Line
// Change this Line

Hector Garcia
@augmt
Mar 02 2016 01:09
@tvdeleon24 playerNumber should be a number and you should use playerNumber to get a property from testObj
tia
@tvdeleon24
Mar 02 2016 01:13
@augmt got it. revised but with no luck. it's telling me I'm not using bracket notation even tho I'm pretty sure that I am.
var playerNumber = 16; // Change this Line
var player = testObj[16];
Davinw
@Davinw
Mar 02 2016 01:14
@tvdeleon24 you aren't using the playerNumber variable you created
uCtrlr
@uCtrlr
Mar 02 2016 01:14
Access the number using playerNumber variable
Hector Garcia
@augmt
Mar 02 2016 01:15
yep, as they said
Andrew Vanboxel
@avanbox
Mar 02 2016 01:15
function largestOfFour(arr) {
  var newArr;

  for(var i =0; i<3; i++){
    var Largest=0;
    for (var x = 0; x<3; x++){

        if(arr[i][x]>Largest)
          {
            Largest=arr[i][x];
          }

    }
    newArr.push(Largest);

  }
  return newArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
im getting "newArr is undefined" . dont give me the answer just point me in the right direction
Norman Dela Cruz
@dcnr
Mar 02 2016 01:17
@avanbox var newArr; is just setting newArr to an undefined value
@avanbox you should define it as an array, var newArr = [];
Andrew Vanboxel
@avanbox
Mar 02 2016 01:17
thank you @dcnr
CamperBot
@camperbot
Mar 02 2016 01:17
avanbox sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 747 | @dcnr | http://www.freecodecamp.com/dcnr
DJ
@qualitymanifest
Mar 02 2016 01:18
@avanbox and you shouldn't hardcode a number where you want your loops end i<3 and x<3
This message was deleted
Andrew Vanboxel
@avanbox
Mar 02 2016 01:18
yeah i had .length but i was trouble shooting
DJ
@qualitymanifest
Mar 02 2016 01:19
gotcha
tia
@tvdeleon24
Mar 02 2016 01:20
@uCtrlr @augmt thanks got it.
CamperBot
@camperbot
Mar 02 2016 01:20
tvdeleon24 sends brownie points to @uctrlr and @augmt :sparkles: :thumbsup: :sparkles:
:star: 347 | @augmt | http://www.freecodecamp.com/augmt
:star: 257 | @uctrlr | http://www.freecodecamp.com/uctrlr
Norman Dela Cruz
@dcnr
Mar 02 2016 01:21

While I don't condone hard coding either, I think it's ok for this one since

... For simplicity, the provided array will contain exactly 4 sub-arrays. ...

I accept this as the go ahead :P

Andrew Vanboxel
@avanbox
Mar 02 2016 01:23
lol
DJ
@qualitymanifest
Mar 02 2016 01:23
yeah i reviewed the challenge and realized that, but in that case you would want <4
¯\(ツ)
Andrew Vanboxel
@avanbox
Mar 02 2016 01:24
true
Carolina Lujan
@CarolGonz
Mar 02 2016 01:27
Hi, I need some help, please. How could I Convert Celsius to Fahrenheit??
Andrew Vanboxel
@avanbox
Mar 02 2016 01:28
20°C × 9/5 + 32 = 68 °F
Carolina Lujan
@CarolGonz
Mar 02 2016 01:29
aaah ok. Now I undersdant
thanks @avanbox :)
CamperBot
@camperbot
Mar 02 2016 01:29
carolgonz sends brownie points to @avanbox :sparkles: :thumbsup: :sparkles:
:star: 279 | @avanbox | http://www.freecodecamp.com/avanbox
Andrew Vanboxel
@avanbox
Mar 02 2016 01:30
ok now im getting arr[i] is undefined.
hmmm
i should just use .map
DJ
@qualitymanifest
Mar 02 2016 01:35
@avanbox paste your code again?
Andrew Vanboxel
@avanbox
Mar 02 2016 01:36
function largestOfFour(arr) {
  var newArr = [];

  for(var i =0; i<arr[i].length; i++){
    var Largest=0;
    for (var x = 0; x<arr[i][x].length; x++){

        if(arr[i][x]>Largest)
          {
            Largest=arr[i][x];
          }

    }
    newArr.push(Largest);

  }
  return newArr;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
DJ
@qualitymanifest
Mar 02 2016 01:37
@avanbox the problem lies in your i<arr[i].length and x<arr[i][x].length
Andrew Vanboxel
@avanbox
Mar 02 2016 01:38
ok
DJ
@qualitymanifest
Mar 02 2016 01:41
most specifically x<arr[i][x].length. think about what arr[i][x] is there. the first time around it's 13, since that's arr[0][0]. but that's a number, which doesn't have a length property
Andrew Vanboxel
@avanbox
Mar 02 2016 01:41
oh duh
thanks this is usually how my problems happen. something ridiculous
DJ
@qualitymanifest
Mar 02 2016 01:42
np
Andrew Vanboxel
@avanbox
Mar 02 2016 01:42
Tanks @qualitymanifest
CamperBot
@camperbot
Mar 02 2016 01:42
avanbox sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1034 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Andrew Vanboxel
@avanbox
Mar 02 2016 01:43
can you send points in pms?
DJ
@qualitymanifest
Mar 02 2016 01:43
nah, camperbot doesn't snoop on pms haha
Andrew Vanboxel
@avanbox
Mar 02 2016 01:44
bam. delete two things and it works!
DJ
@qualitymanifest
Mar 02 2016 01:44
cool :+1:
Andrew Vanboxel
@avanbox
Mar 02 2016 01:45
whats funny is ive already done these. I started building some projects and they re arranged the maps in the middle of me building them so i decided to go through them again. good thing.
prestonk25
@prestonk25
Mar 02 2016 01:59
myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces
var myStr = ' \"backslash\" \t"tab\" \t"tab\" \r"carriage-return\" \n"new-line\"'; // Change this line
I can't get this to work because I don't know the proper syntax, can someone please help?
DJ
@qualitymanifest
Mar 02 2016 02:01
@prestonk25 no need to put the word equivalents in there. \\ is the way to escape a backslash. \t is the way to escape a tab. etc.
kelvinshang
@kelvinshang
Mar 02 2016 02:05
I am completely lost in the "Stand in Line" challenge, its asking: Write a function queue 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 queue function should then return the element that was removed.
function queue(arr, item) {
  // Your code here
  console.log(arr, item);
  console.log(arr.push(item));
  console.log(arr.shift());
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
can anyone help me solve this?
demipixel
@demipixel
Mar 02 2016 02:09
I need help
What is "TypeError: Cannot create property '2' on number '1'
DJ
@qualitymanifest
Mar 02 2016 02:10
@demipixel paste your code/ codepen
demipixel
@demipixel
Mar 02 2016 02:10
no my code is top secret
DJ
@qualitymanifest
Mar 02 2016 02:10
k
Andrew Vanboxel
@avanbox
Mar 02 2016 02:10
lol
demipixel
@demipixel
Mar 02 2016 02:10
ill just think of another solution
Thanks anyway
ok but srsly
Davinw
@Davinw
Mar 02 2016 02:11
@kelvinshang you need to capture the item you shifted into a variable
demipixel
@demipixel
Mar 02 2016 02:11
This message was deleted
nvm
figured it out
kelvinshang
@kelvinshang
Mar 02 2016 02:13
@Davinw I have no idea what that means...
Davinw
@Davinw
Mar 02 2016 02:13
@kelvinshang so the shift() function removes the first element from the array
kelvinshang
@kelvinshang
Mar 02 2016 02:13
yes
Davinw
@Davinw
Mar 02 2016 02:13
@kelvinshang the challenge is asking you to return the deleted first item from the array
kelvinshang
@kelvinshang
Mar 02 2016 02:14
@Davinw yeah i know what it's asking me but im confused how i would return something that I deleted
Davinw
@Davinw
Mar 02 2016 02:14
@kelvinshang so, the shift method, when it's used, returns the item deleted
@Davinw so, var deletedItem = arr.shift(); for instance, would "capture" the deleted item into a variable
kelvinshang
@kelvinshang
Mar 02 2016 02:15
@Davinw okay let me try that, one second
Davinw
@Davinw
Mar 02 2016 02:15
and you would then return that variable
kelvinshang
@kelvinshang
Mar 02 2016 02:17
@Davinw this is what i tried, but to no avail
function queue(arr, item) {
  // Your code here
  console.log(arr, item);
  console.log(arr.push(item));
  console.log(arr.shift());
  var deletedItem = arr.shift();
  return deletedItem;  // 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));
Davinw
@Davinw
Mar 02 2016 02:17
you've shifted twice
get rid of the console.log(arr.shift());
the test is likely looking for 1, and with your code as is you will be returning 2, because you deleted 1 with that first call
kelvinshang
@kelvinshang
Mar 02 2016 02:19
@Davinw ah it worked! thanks!
CamperBot
@camperbot
Mar 02 2016 02:19
kelvinshang sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 302 | @davinw | http://www.freecodecamp.com/davinw
Davinw
@Davinw
Mar 02 2016 02:20
@kelvinshang Yw! So incidentally you don't actually have to capture the value into a variable, you can actually just write return arr.shift();
kelvinshang
@kelvinshang
Mar 02 2016 02:20
@Davinw let me try that, one sec
Davinw
@Davinw
Mar 02 2016 02:20
but do you understand why they are doing basically the same thing here?
Kenny
@Kennpow
Mar 02 2016 02:23
hey guys :)
kelvinshang
@kelvinshang
Mar 02 2016 02:23
@Davinw that worked as well. is it because creating a new var for shift() captures the deleted number and then you return the deleted number through the var, and returning just arr.shift() would give you the deleted number and not save it?
Davinw
@Davinw
Mar 02 2016 02:24
@kelvinshang yep exactly!
kelvinshang
@kelvinshang
Mar 02 2016 02:24
@Davinw awesome, thanks Davin!
CamperBot
@camperbot
Mar 02 2016 02:24
kelvinshang sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:warning: kelvinshang already gave davinw points
Kenny
@Kennpow
Mar 02 2016 02:24
(studying c++ right now but) in overloading functions, i understand you can use the same name for functions with different number of parameters, can i use the same number of parameters but different data types?
and return types is not a valid way to overload
Davinw
@Davinw
Mar 02 2016 02:25
@kelvinshang so the general style guideline would be don't create extra variables if you don't have to. If you needed to do extra work on the deleteditem, then making a variable would make sense. Since you don't, it's cleaner to just return directly
kelvinshang
@kelvinshang
Mar 02 2016 02:26
@Davinw gotcha, thanks for the explanation. That was actually a much simpler concept than I thought
CamperBot
@camperbot
Mar 02 2016 02:26
kelvinshang sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:warning: kelvinshang already gave davinw points
Davinw
@Davinw
Mar 02 2016 02:27
@kelvinshang You're welcome! And a lot of coding is like that. Although some things are just as hard as you thought they were :)
Ruzanna
@ruzzyx
Mar 02 2016 02:39

Hello! I am doing the "Stand in Line" part of the basic JavaScript course. Super clueless as to what I'm supposed to here. Any help will be appreciated!

"Write a function queue 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 queue function should then return the element that was removed."

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

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I've honestly stared at this for a good 5 minutes, not sure where to even start. Messed around a bit to try and get a clue, but no luck.
DJ
@qualitymanifest
Mar 02 2016 02:42
@ruzzyx someArray.push("something") pushes "something" onto the end of someArray
someArray.shift() will remove the first part of someArray, and if you assign that to a variable or return it, that variable or return will get the part of someArray that you removed
instead of someArray and "something", you will work with the variables available to you: arr and item.
Ruzanna
@ruzzyx
Mar 02 2016 02:44
Ok, let me try that.
Ruzanna
@ruzzyx
Mar 02 2016 02:49
@qualitymanifest So I tried this, but it's not working:
function queue(arr, item) {
  // Your code here
  arr.shift();
  item.push(6);

  return queue;  // Change this line
}
DJ
@qualitymanifest
Mar 02 2016 02:49
@ruzzyx item isn't an array, it's a number that you want to push into arr
and your return should be the first part of arr that you removed
tia
@tvdeleon24
Mar 02 2016 02:52

working on "objects for Lookups". here is my code, // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha": "Adams",
"bravo": "Boston",
"charlie": "Chicago",
"delta": "Denver",
"echo": "Easy",
"foxtrot": "Frank",
"": undefined,
};
result += lookup[val];
// Only change code above this line
return result;
}

// Change this value to test
phoneticLookup("foxtrot");

E
@efhjones
Mar 02 2016 02:52
Can anyone help me with Random Quote Generator? I've been stuck for like a week...
tia
@tvdeleon24
Mar 02 2016 02:52
undefined won't process.
bitgrower
@bitgrower
Mar 02 2016 02:53
This message was deleted
bitgrower @bitgrower cleans her glasses ...
DJ
@qualitymanifest
Mar 02 2016 02:54
This message was deleted
bitgrower
@bitgrower
Mar 02 2016 02:54
@tvdeleon24 -- what is the purpose of doing += to result ?
@efhjones ... nope -- you've passed me by ... unfortunately, I was already wandering around in adv algos before they re-arranged the schedule ...
Moisés Man
@moigithub
Mar 02 2016 02:57
@tvdeleon24 wonder if undefined was there.. or u added that
Ruzanna
@ruzzyx
Mar 02 2016 02:57
@qualitymanifest I think I understand that part now, does this look right?
function queue(arr, item) {
  // Your code here
  arr.shift();
  arr.push(item);
  return queue;  // Change this line
}
bitgrower
@bitgrower
Mar 02 2016 02:58
yeah, I run @tvdeleon24 's code just fine without any undefinednesses running around ...
DJ
@qualitymanifest
Mar 02 2016 02:58
@ruzzyx close... but arr.shift() just removes the first part of arr and throws it away
bitgrower
@bitgrower
Mar 02 2016 02:58
@ruzzyx -- you need to return an item from the array ... not the name of the function ... :)
DJ
@qualitymanifest
Mar 02 2016 02:59
@ruzzyx you need to return the value produced by arr.shift
tia
@tvdeleon24
Mar 02 2016 03:00
@bitgrower it was misunderstanding. when it processed the alpha - foxtrot. it gave me the false idea that i was doing something wrong with the undefined thing when actuality it was the result statement.
bitgrower
@bitgrower
Mar 02 2016 03:00
ahhh ...
yeah, I mean, the syntax for the result statement works ... it's just suggestive that you had something you are concatenating together, that is, something other than the empty string with the value from the lookup ... :)
Ruzanna
@ruzzyx
Mar 02 2016 03:01
@qualitymanifest @bitgrower Oh hey, I think I figured it out!
function queue(arr, item) {
  // Your code here
  arr.push(item);
  return arr.shift();  // Change this line
}
DJ
@qualitymanifest
Mar 02 2016 03:02
@ruzzyx yep that looks right :+1:
bitgrower
@bitgrower
Mar 02 2016 03:02
AWESOME!!!! @ruzzyx !!!!
that's excellent ... i've seen others given far more clues and still wandering around clueless ... good job!
E
@efhjones
Mar 02 2016 03:03
@bitgrower I think they should have kept the old schedule, jumping straight into calling APIs is way more advanced than anything they taught up to that point and it makes for a frustrating jump.. IMHO
Ruzanna
@ruzzyx
Mar 02 2016 03:04
Thanks @qualitymanifest @bitgrower !
CamperBot
@camperbot
Mar 02 2016 03:04
ruzzyx sends brownie points to @qualitymanifest and @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 1038 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
:star: 680 | @bitgrower | http://www.freecodecamp.com/bitgrower
tia
@tvdeleon24
Mar 02 2016 03:04
@bitgrower gotta put to memory that (=+) and (=) are very different, haha. thanks for ya help
CamperBot
@camperbot
Mar 02 2016 03:04
tvdeleon24 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 681 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 02 2016 03:04
hmmm ... that part, I dunno about ... but I do think having the tribute & profile page right after doing html/bootstrap stuff was very smart ... I see a lot more people involved with doing the ziplines now, and not getting bogged down in js algos ...
@tvdeleon24 -- get it right ... it's += ... not =+
oh, and you're most welcome ...
@efhjones ... there are a lot of people who create websites without knowing a lot of js at all ...
E
@efhjones
Mar 02 2016 03:06
That's encouraging, but I want to be a good coder! :worried:
bitgrower
@bitgrower
Mar 02 2016 03:06
...so ... I'm not sure ... the main thing in terms of the 2nd set of ziplines is dealing with the async world
Edwilson Cruz
@EdwilsonCruz
Mar 02 2016 03:06
hey Convert Celsius to Fahrenheit i'm stop =,(
Robert Valmassoi
@valmassoi
Mar 02 2016 03:07
how do you do a pause/wait/delay inbetween iterations in a loop?
bitgrower
@bitgrower
Mar 02 2016 03:07
and not sure any of the algos will get you more comfortable with that ... I'm not quite sure where the json/api section ...
Ruzanna
@ruzzyx
Mar 02 2016 03:07
I'm still trying to understand why it worked, I understand what the .push() and .shift() did, cause it says "Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed." Wouldn't that mean:
bitgrower @bitgrower kicks @valmassoi a little ... hi there! have you tried searching out stack overflow ?
Robert Valmassoi
@valmassoi
Mar 02 2016 03:07
  for (z=0; z<steps.length; z++){
    light(steps[z]);
    setTimeout(wait, 1000);
  }
bitgrower
@bitgrower
Mar 02 2016 03:08
ahhhh okay ...
Robert Valmassoi
@valmassoi
Mar 02 2016 03:08
@bitgrower of course and it gave me setTimeout
which is not working
bitgrower
@bitgrower
Mar 02 2016 03:08
I think there's a setInterval, as well ...
Robert Valmassoi
@valmassoi
Mar 02 2016 03:08
dont kick me when im down
tried that aswell
bitgrower
@bitgrower
Mar 02 2016 03:08
awwwwww.... you're not down ... look at ya ... simon!!!! Isn't that the last front end zipline ?
kelvinshang
@kelvinshang
Mar 02 2016 03:08
@ruzzyx by returning arr.shift(), you're returning the deleted value
Gagandeep Singh
@Guggu
Mar 02 2016 03:09

function smallestCommons(arr) {
// Sort array from greater to lowest
// This line of code was from Adam Doyle (http://github.com/Adoyle2014)
arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;

// run code while n is not the same as the array lenght.
do {
quot = newArr[0] loop newArr[1];
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}

loop++;

} while (n !== newArr.length);

return quot;
}

smallestCommons([1, 13]);

bitgrower
@bitgrower
Mar 02 2016 03:09
@ruzzyx -- take a tour of the mozilla developer network pages on shift & push ... :)
This message was deleted
DJ
@qualitymanifest
Mar 02 2016 03:10
@Guggu you really gotta format that
help format
CamperBot
@camperbot
Mar 02 2016 03:10

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

bitgrower
@bitgrower
Mar 02 2016 03:10
love the credit to Adam Doyle for the sort ... LOL ... (the MDN page shows that as well ... )
Gagandeep Singh
@Guggu
Mar 02 2016 03:11

function smallestCommons(arr) {
// Sort array from greater to lowest

arr.sort(function(a, b) {
return b - a;
});

// Create new array and add all values from greater to smaller from the original array.
var newArr = [];
for (var i = arr[0]; i >= arr[1]; i--) {
newArr.push(i);
}

// Variables needed declared outside the loops.
var quot = 0;
var loop = 1;
var n;

// run code while n is not the same as the array lenght.
do {
quot = newArr[0] loop newArr[1];
for (n = 2; n < newArr.length; n++) {
if (quot % newArr[n] !== 0) {
break;
}
}

loop++;

} while (n !== newArr.length);

return quot;
}

smallestCommons([1, 13]);

hey fcc guys help me on this
bitgrower
@bitgrower
Mar 02 2016 03:11
thanks for crediting people for code you use, though ... in your comments, @Guggu
CamperBot
@camperbot
Mar 02 2016 03:11
bitgrower sends brownie points to @guggu :sparkles: :thumbsup: :sparkles:
:star: 292 | @guggu | http://www.freecodecamp.com/guggu
Gagandeep Singh
@Guggu
Mar 02 2016 03:12
I m getting syntax error expected while
bitgrower
@bitgrower
Mar 02 2016 03:12
@guggu ... what algo are you using for this ? sieve of erasthones (sp)? something else ?
Ruzanna
@ruzzyx
Mar 02 2016 03:13
I think I got it... haha thanks @bitgrower @kelvinshang
CamperBot
@camperbot
Mar 02 2016 03:13
ruzzyx sends brownie points to @bitgrower and @kelvinshang :sparkles: :thumbsup: :sparkles:
:warning: ruzzyx already gave bitgrower points
:star: 218 | @kelvinshang | http://www.freecodecamp.com/kelvinshang
DJ
@qualitymanifest
Mar 02 2016 03:13
This message was deleted
bitgrower
@bitgrower
Mar 02 2016 03:13
@valmassoi -- the problem which most people seem to have with the api calls and the like are making sure they are in the same scope and get called at the right time ... (eg, at document ready instead of page start, etc.)
yeah, I think in js you have do while loops, not just do loops
Robert Valmassoi
@valmassoi
Mar 02 2016 03:17

is

function funOne{
  funTwo();
  function funTwo{

  }
}

the same as:

function funOne{
  funTwo();
}
  function funTwo{

  }
Gagandeep Singh
@Guggu
Mar 02 2016 03:18
@bitgrower its not an sp algo...
bitgrower
@bitgrower
Mar 02 2016 03:18
sp ?
Bryan Halterman
@bryhalterman
Mar 02 2016 03:19

Falsy Bouncer

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

return arr.filter(notFalsy);
}

function notFalsy(value) {
var falsyValues = [false, null, 0, "", undefined, NaN];

for(i = 0; i < falsyValues.length; i++){
if (value == falsyValues[i]){
return false;
}
}

return true;
}

//bouncer([7, "ate", "", false, 9]);
bouncer([false, null, 0, NaN, undefined, ""]);

Robert Valmassoi
@valmassoi
Mar 02 2016 03:19
im trying to manual loop, but still no luck
function npcTurn(){
  var move = Math.floor(Math.random() * 4)+1;//1 to 4
  steps.push(move);
  $("#counter").html(steps.length);
  var z=0;
  npcLoop(z);
  //player turn gets activated by a click: 
}

function npcLoop(z){
  if (z<steps.length){
      z++;
    light(steps[z]);
    setTimeout(npcLoop, 1000);
  }
 }
Norman Dela Cruz
@dcnr
Mar 02 2016 03:19
@valmassoi only if you don't care about scope. In the first one, funTwo is only accessible inside funOne, and all of funOne's variables are accessible by funTwo
bitgrower
@bitgrower
Mar 02 2016 03:19

@bryhalterman -- I spent hours on this thing ... pulled my hair out ... wrote lines and lines of code ...

...and then I read the helpful hint pages and found how to do falsy bouncer very easily, simply ...

Robert Valmassoi
@valmassoi
Mar 02 2016 03:20
@dcnr cool yeah in this case the scope doesnt matter
Bryan Halterman
@bryhalterman
Mar 02 2016 03:20
My last call to bouncer is returning null instead of an empty array
Norman Dela Cruz
@dcnr
Mar 02 2016 03:20
@valmassoi doesn't setTimeout just defer the execution function you specified to the next set millisecond?
bitgrower @bitgrower thinks @bryhalterman doesn't want to solve falsy bouncer in minutes ... sniff ... sigh ... :(
Norman Dela Cruz
@dcnr
Mar 02 2016 03:21
@valmassoi setTimeout(npcLoop, 1000); will invoke npcLoop after 1 second?
Caleb Martin
@caleb272
Mar 02 2016 03:21
can someone tell me the scope of for loop variables
Robert Valmassoi
@valmassoi
Mar 02 2016 03:21
@caleb272 local
Caleb Martin
@caleb272
Mar 02 2016 03:21
^ are they limited to the loop or function?
bitgrower
@bitgrower
Mar 02 2016 03:21
on the for loop definition ?
Caleb Martin
@caleb272
Mar 02 2016 03:21
yes
Norman Dela Cruz
@dcnr
Mar 02 2016 03:21
@caleb272 depends on how you initialized them in your for loop. let will only allow your variables in the for loop be accessible in the for loop. var will let them be accessible outside.
Bryan Halterman
@bryhalterman
Mar 02 2016 03:22
I'll read through the hint pages again
thanks @bitgrower
CamperBot
@camperbot
Mar 02 2016 03:22
bryhalterman sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 682 | @bitgrower | http://www.freecodecamp.com/bitgrower
Caleb Martin
@caleb272
Mar 02 2016 03:22
k thanks @dcnr
CamperBot
@camperbot
Mar 02 2016 03:22
caleb272 sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 748 | @dcnr | http://www.freecodecamp.com/dcnr
bitgrower
@bitgrower
Mar 02 2016 03:22
yw @bryhalterman
Robert Valmassoi
@valmassoi
Mar 02 2016 03:22
@dcnr i think thats what i want. for it to keep looping after a second
bitgrower
@bitgrower
Mar 02 2016 03:26
LOL ... what is called in some circles a "busy wait" .... hmmmm ....
Norman Dela Cruz
@dcnr
Mar 02 2016 03:26
@valmassoi but setTimeout(npcLoop, 1000); will just call it as npcLoop() right? after one second. And the next one will have undefined z
bitgrower
@bitgrower
Mar 02 2016 03:26
setTimeout(function, milliseconds)
Executes a function, after waiting a specified number of milliseconds.
setInterval(function, milliseconds)
Same as setTimeout(), but repeats the execution of the function continuously.
Norman Dela Cruz
@dcnr
Mar 02 2016 03:27
There's that loop trick with the date method too
James
@drjyounger
Mar 02 2016 03:27
Hi, new to FreeCodeCamp and I'm stuck on the Profile Lookup Challenge under Javascript. Does anyone have a second to help?
Norman Dela Cruz
@dcnr
Mar 02 2016 03:28
like, start date = now, then while start date + (whatever time), then just do nothing.
bitgrower
@bitgrower
Mar 02 2016 03:28
you're doing very well to be new to FCC and that far along ... congrats @drjyounger
that's what these rooms are for ... hence the name ... "helpJavaScript" ... if you don't know how to post your code so you get syntax highlighting, please follow @camperbot's instructions ...
explain format
CamperBot
@camperbot
Mar 02 2016 03:29

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

James
@drjyounger
Mar 02 2016 03:29
Thanks, it's going well and so far this is my first stuck. Are you familiar with the challenge? I'm not sure how, but is there a way to show you what I've got? I keep getting an undefined from what I've typed so far
Robert Valmassoi
@valmassoi
Mar 02 2016 03:29
@dcnr yepp. got it working with var z=0; defined up top and
function npcLoop(){
    if (z<steps.length){
      light(steps[z]);
      z++;
      setTimeout(npcLoop, 2000);
    }
    else{
      z=0;
    }
 }
Adrian
@Adrian95
Mar 02 2016 03:29
i get the right answert on "Manipulate Arrays With push" but it doesnt get checked
is it a bug?
bitgrower
@bitgrower
Mar 02 2016 03:29
@drjyounger -- very familiar ... many people have problems with Profile Lookup
AlonzaThompson
@alonzathompson
Mar 02 2016 03:29

I'm close all of the test check out except for one ("almosta")

function palindrome(str) {
  str = str.toLowerCase().replace(/[\W_]/g, "");
  var len = str.length;
  var strRev = str.split('').reverse().join('');

  for (var i = 0; i < len-1; i++){
    if(str[i] !== strRev[i]){
      return false;
    }
    return true;
  }  
}


palindrome("eye");

any help is much appreciated

James
@drjyounger
Mar 02 2016 03:30
So here's what I've got
if (contacts.firstName.hasOwnProperty(firstName) && contacts[0].firstName[prop].hasOwnProperty(prop)){
return contacts[firstName][prop];
}
if (contacts.firstName.hasOwnProperty(firstName)==="false"){
return "No such contact";
}
if (contacts.firstName[prop].hasOwnProperty(prop)==="false"){
return "No such property";
}
Norman Dela Cruz
@dcnr
Mar 02 2016 03:30
@valmassoi nice! :D
James
@drjyounger
Mar 02 2016 03:30
and I keep getting contacts.firstName undefined
bitgrower
@bitgrower
Mar 02 2016 03:31
@drjyounger -- what is the data structure you are given ... describe it for me ...
James
@drjyounger
Mar 02 2016 03:32
It's as JSON array, here is one of the elements:
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
bitgrower
@bitgrower
Mar 02 2016 03:32
@Adrian95 -- can you post your code, please ?
Adrian
@Adrian95
Mar 02 2016 03:32
i had too reset the code, the challenge had changed since i last was on fcc
Ken Haduch
@khaduch
Mar 02 2016 03:33
@Adrian95 - If you post your code, I can try to help, but I see that someone is helping you, though?
bitgrower
@bitgrower
Mar 02 2016 03:33
okay ... I'm used to thinking of JSON objects ... ... the first clue as to the data structure is the first character that follows the = sign
Adrian
@Adrian95
Mar 02 2016 03:33
its all good :)
bitgrower
@bitgrower
Mar 02 2016 03:33
so, you say, array ... how do you index into an array ?
James
@drjyounger
Mar 02 2016 03:34
maybe I'm using the wrong term and it is an object. but I thought I was accessing the elements with the . syntax of contacts.firstName but I keep getting undefined
bitgrower
@bitgrower
Mar 02 2016 03:34
no -- it says, right in the first sentence ... "an array of objects"
so ... how do you index into an array ?
AlonzaThompson
@alonzathompson
Mar 02 2016 03:35
you use bracket notation like array[0]
James
@drjyounger
Mar 02 2016 03:35
Oh right. So you index into an array by it's index position[1], etc
bitgrower
@bitgrower
Mar 02 2016 03:35
yeppers!!!!
AlonzaThompson
@alonzathompson
Mar 02 2016 03:35
that would be the first position
James
@drjyounger
Mar 02 2016 03:35
So do I need to use a loop to go and check all the parts?
bitgrower
@bitgrower
Mar 02 2016 03:36
that sounds about right, yeah ... :)
James
@drjyounger
Mar 02 2016 03:36
Ah, ok. So I'm barking up the wrong tree with the .hasOwnProperty
bitgrower
@bitgrower
Mar 02 2016 03:36
oh ... it's needed for the problem ... but you first have to deal with the larger data structure first
which is an array ...
but each element is an object ... so then you get to play with various types of object notation ...
James
@drjyounger
Mar 02 2016 03:38
Ok thanks. So just so I have the terminology right, element[0] is the object of Akira, Laine, 0543236543, pizza, etc?
Norman Dela Cruz
@dcnr
Mar 02 2016 03:38
@drjyounger

YEAH! :D

James
@drjyounger
Mar 02 2016 03:38
or contacts[0] I should say
bitgrower
@bitgrower
Mar 02 2016 03:38
well, those are key value pairs in the object ... :)
James
@drjyounger
Mar 02 2016 03:38
Ok, that gets me going in the right direction. Thanks!
bitgrower
@bitgrower
Mar 02 2016 03:39
you got it faster than many people ... just remember ... when you are giving a problem, look at the data structure you're given ... describe it ... and that will guide you into the kind of addressing you need to use to access different pieces ... :)
James
@drjyounger
Mar 02 2016 03:40
Perfect, thanks so much :smile:
bitgrower
@bitgrower
Mar 02 2016 03:40
what kinda doc ?
James
@drjyounger
Mar 02 2016 03:40
Dentist
bitgrower
@bitgrower
Mar 02 2016 03:41
there's a famous computer hobbyist journal ... is now called "Dr Dobbs" ... but it's original name was ... hang on ...
Dr. Dobb's Journal of Computer Calisthenics & Orthodontia ... with the tag of "running light without overbyte" ...
novlem
@m3lv0n
Mar 02 2016 03:42

// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

James
@drjyounger
Mar 02 2016 03:42
Ha! I'll have to google that
novlem
@m3lv0n
Mar 02 2016 03:43
I pushed enter prematurely my question is how do I derive 8 from myData I just don't get it
Adrian
@Adrian95
Mar 02 2016 03:45
var myData = myArray .[2] :[1]
javascript start counting at zero
not 1
novlem
@m3lv0n
Mar 02 2016 03:46
could you please explain because I'm not clear
bitgrower
@bitgrower
Mar 02 2016 03:46
@m3lv0n -- an array is a collection of elements, and the elements can be anything ... numbers, strings, objects, arrays, etc .. .
Adrian
@Adrian95
Mar 02 2016 03:46
first select grp 2 = [7,8,9] then 8 = 1
bitgrower
@bitgrower
Mar 02 2016 03:47
if I give you myArray = [7,8,9]; could you tell me how to address the element with the value of 8 ?
novlem
@m3lv0n
Mar 02 2016 03:47
7 is 0 so 8 is 1?
bitgrower
@bitgrower
Mar 02 2016 03:47
wwhat would the entire address be ?
bitgrower @bitgrower plays the final jeopardy music ....
novlem
@m3lv0n
Mar 02 2016 03:51
would be....buzzer
bitgrower
@bitgrower
Mar 02 2016 03:55
sooooo ... I think there are some previous array exercises before this one ... you might want to review using 1 dimensional arrays before you tackle 2-d Arrays ... because you need to know how to do the first and be comfortable with it before tackling 2D arrays ...
novlem
@m3lv0n
Mar 02 2016 03:55
agreed in fact in the process of doing so
ichirped
@ichirped
Mar 02 2016 03:57
@bitgrower no I couldn't find the answer I was looking for (Pig Latin)
function translate(str) {
  var strArr = str.split('');
  var vowels = ['a', 'e', 'i', 'o', 'u'];

  for(var i=0; i<vowels.length; i++){
    if(strArr.indexOf(vowels[i]) === 0){
      strArr.push('way');
      break;
    }
    else if(strArr.indexOf(vowels[i]) > 0){
      var rem = strArr.splice(0, strArr.indexOf(vowels[i]));
      strArr.push(rem + 'ay');
      break;
    }
  }


  return strArr.join('');
}
it doesn't pass this test translate("glove") should return "oveglay".
bitgrower
@bitgrower
Mar 02 2016 03:59
@ichirped ... if you change your tojs it will show javascript highlighting ...
Michael Poutre
@M1kep
Mar 02 2016 03:59
This message was deleted
bitgrower
@bitgrower
Mar 02 2016 04:00
blah ... if you change ``` to ```js you should get better js syntax highlighting ...
ichirped
@ichirped
Mar 02 2016 04:00
This message was deleted
:(
Michael Poutre
@M1kep
Mar 02 2016 04:01
function translate(str) {
  var strArr = str.split('');
  var vowels = ['a', 'e', 'i', 'o', 'u'];

  for(var i=0; i<vowels.length; i++){
    if(strArr.indexOf(vowels[i]) === 0){
      strArr.push('way');
      break;
    }
    else if(strArr.indexOf(vowels[i]) > 0){
      var rem = strArr.splice(0, strArr.indexOf(vowels[i]));
      strArr.push(rem + 'ay');
      break;
    }
  }


  return strArr.join('');
}
At least it looks rigt this way
Tried quoting what to ender but it didnt wanna do that
This message was deleted
This message was deleted
ichirped
@ichirped
Mar 02 2016 04:02
@M1kep thanks for the formatting, really appreciate it
CamperBot
@camperbot
Mar 02 2016 04:02
ichirped sends brownie points to @m1kep :sparkles: :thumbsup: :sparkles:
:star: 313 | @m1kep | http://www.freecodecamp.com/m1kep
bitgrower
@bitgrower
Mar 02 2016 04:02
your second break statement shouldn't be needed ...?
actually, I don't think either of them should be needed ..
ichirped
@ichirped
Mar 02 2016 04:03
oh ok
bitgrower
@bitgrower
Mar 02 2016 04:03
oh wait ... nvm ...
ichirped
@ichirped
Mar 02 2016 04:04
i don't want to go through all the vowels for no reason @bitgrower
bitgrower
@bitgrower
Mar 02 2016 04:04
well how are you going to know which shows up earliest ?
ichirped
@ichirped
Mar 02 2016 04:04
my problem is understanding this var rem = strArr.splice(0, strArr.indexOf(vowels[i]));
bitgrower
@bitgrower
Mar 02 2016 04:04
lol ... I think I have something to learn from how you did this ... :)
well, splice does 2 things ...
ichirped
@ichirped
Mar 02 2016 04:05
@bitgrower lol...indexOf usually gets you the first occurrence doesn't it ?
bitgrower
@bitgrower
Mar 02 2016 04:05
@ichirped -- not of a group ...
ichirped
@ichirped
Mar 02 2016 04:06
ohhhh @bitgrower hmmm
bitgrower
@bitgrower
Mar 02 2016 04:06
groundbreak <-- if I do indexOf of a, it's gonna be further out than indexOf o -- and you would need to find the index of o ...
ichirped
@ichirped
Mar 02 2016 04:06
i think i got it, now need to figure out how do I turn that around @bitgrower
@bitgrower yeah just realized after you pointed out !!
thanks @bitgrower
CamperBot
@camperbot
Mar 02 2016 04:07
ichirped sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 683 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 02 2016 04:09
yw ... :)
Brian
@sludge256
Mar 02 2016 04:14
:wave:
demipixel
@demipixel
Mar 02 2016 04:14
<3
Catalin Scripcariu
@CatalinScr
Mar 02 2016 04:30
help Symmetric Difference
CamperBot
@camperbot
Mar 02 2016 04:30

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

Baaliisu
@Baaliisu
Mar 02 2016 04:32

var myVar = 87;

// Only change code below this line
myVar = myVar + 1;

can someone tell me what to put here to implement the ++
method
oh wait
Michael Poutre
@M1kep
Mar 02 2016 04:34
@Baaliisu did you get it?
Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:34
heeeeeellllllp
I’ve been trying to do this ‘where art thou’ challenge and have have got stuck…i think i’m close but not close enough
Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:35

```function where(collection, source) {

var arr = [];
var keyPropertyMatch = false;

for (var i=0; i<collection.length; i++) {
var key = Object.keys(collection[i]); // ["a", "b", "c"]
var sourceKey = Object.keys(source); // ["a", "b"]

if (collection[i].hasOwnProperty(sourceKey[i])) {

  for (var j=0; j<source.length; j++) {
  if (collection[i][sourceKey[j]] == source[sourceKey[j]]) {
    keyPropertyMatch = true;
  }
    else {
    keyPropertyMatch = false;
    break;
    }

  }

    }

}
if (keyPropertyMatch === true) {
arr.push(collection[i]);
keyPropertyMatch = false;
}

return arr;```

Michael Poutre
@M1kep
Mar 02 2016 04:35
Read that, should give you a firm understanding
function where(collection, source) {

  var arr = [];
  var keyPropertyMatch = false;

  for (var i=0; i<collection.length; i++) {
  var key = Object.keys(collection[i]); // ["a", "b", "c"]
  var sourceKey =  Object.keys(source); // ["a", "b"]

    if (collection[i].hasOwnProperty(sourceKey[i])) {

      for (var j=0; j<source.length; j++) {
      if (collection[i][sourceKey[j]] == source[sourceKey[j]]) {
        keyPropertyMatch = true;
      }
        else {
        keyPropertyMatch = false;
        break;
        }

      }

        }

  }  
            if (keyPropertyMatch === true) {
          arr.push(collection[i]);
          keyPropertyMatch = false;
   }

  return arr;
Now that its readanble lets see :P
So whats the issue
?
Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:37
@M1kep thanks
CamperBot
@camperbot
Mar 02 2016 04:37
rghadamian sends brownie points to @m1kep :sparkles: :thumbsup: :sparkles:
:star: 315 | @m1kep | http://www.freecodecamp.com/m1kep
Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:37
@M1kep I’m trying to get two loops happening - so basically you loop thorugh the first array of the collection parameter
Michael Poutre
@M1kep
Mar 02 2016 04:38
find where art
CamperBot
@camperbot
Mar 02 2016 04:38

find where art

:zero: algorithm where art thou

Michael Poutre
@M1kep
Mar 02 2016 04:38
0
CamperBot
@camperbot
Mar 02 2016 04:38

:point_right: algorithm where art thou [wiki]

Problem Explanation

Write an algorithm that will take an array for the first argument and return an array with all the objects that matches all the properties and values in the Object passed as second parameter.

:pencil: read more about algorithm where art thou on the FCC Wiki

Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:38
in that loop you check if there is a key from source, if there is then you loop through each of the key’s and check to see if the properties match
@M1kep then if they all go through and the variable keyPropertyMatch === true then it pushs collection[i] into the variable arr…then it goes through the loop again
@M1kep that’s the logic I want anyway…but I can’t seem to crack it
Michael Poutre
@M1kep
Mar 02 2016 04:43
Ok let me take a look real quick, I did it differently, but lets solve it this way and then ill let you knmow how I did it :) We both improve then :D
Terceprime
@Terceprime
Mar 02 2016 04:54
is there a more efficient way to do this?
function reverseString(str) {
  reverseMe = str.split(['']);
  reverseMe.reverse();
  return reverseMe.join(['']);
}
Michael Poutre
@M1kep
Mar 02 2016 04:55
@RGhadamian so far the main issue I see is this: if (collection[i].hasOwnProperty(sourceKey[i])) {
sourceKey[i]
is will very quickly become larger than the size of the sourceKeys array
@Terceprime Thats not how they want you to complete it :/
But yes, line wise there is a more effecient way
Roshan Ghadamian
@RGhadamian
Mar 02 2016 04:56
@M1kep I don’t quite follow...
Michael Poutre
@M1kep
Mar 02 2016 04:56
you can chain most of those
Terceprime
@Terceprime
Mar 02 2016 04:56
oh jeez really? what did I do differently
Michael Poutre
@M1kep
Mar 02 2016 04:56
@Terceprime ultimately they want you to implement it yourself
@RGhadamian ok one second
Terceprime
@Terceprime
Mar 02 2016 04:57
what do you mean, I typed that from scratch from what I learned the previous couple lessons
just wondering if my way was stupid or not
Pat Lee
@pleedesigner
Mar 02 2016 04:58
I'm doing "Storing Values with the Equal Operator". how can I assign "a"to "b" with "=" ?
DJ
@qualitymanifest
Mar 02 2016 04:58
@Terceprime not stupid. but you can return str.split('').reverse().join('')
@Terceprime also no need for [] inside your split and join arguments
Terceprime
@Terceprime
Mar 02 2016 04:59
@qualitymanifest thanks, wasn't sure if you had to convert it to an array separately . The one thing I haven't been great with so far is condensing things down to single line solutions
CamperBot
@camperbot
Mar 02 2016 04:59
terceprime sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1043 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 02 2016 05:00
@Terceprime np. yeah, .split() splits a string into an array
Michael Poutre
@M1kep
Mar 02 2016 05:00
@RGhadamian so right now you increasing the count i, until it is no longer less than the size of COLLECTION
for example
Take a look at this
and click the console on the bottom when you run it
DJ
@qualitymanifest
Mar 02 2016 05:01
@Terceprime condensing to one line solutions isn't always the most important thing: it's often less readable, and sometimes less efficient, speed-wise
DJ
@qualitymanifest
Mar 02 2016 05:01
@Terceprime in this case, it's fine though
Terceprime
@Terceprime
Mar 02 2016 05:02
yeah for quick functions like this it seems like the better way to get used to doing it
J Lee
@SoYuMatic
Mar 02 2016 05:07
Hey I have a question... how applicable are these algorithms to real life front end development?
Michael Poutre
@M1kep
Mar 02 2016 05:10
Most of them probably arent applicable. But its the mindset/way of thinking that is important
Though some of them could be applicable if you wanted to apply then
novlem
@m3lv0n
Mar 02 2016 05:13
@Adrian95 your answer gave me a understanding I was looking for minus the face
Vasily Sidorenko
@vsidoren
Mar 02 2016 05:14
var string = "Split me into an array";
var array = [];

// Only change code below this line.
var array = string.split(" ");

array = string;
any reason you guys can think of this is returning, " you should use split the string by y its spaces." the space seems to be clearly defined
DJ
@qualitymanifest
Mar 02 2016 05:15
@vsidoren at the end you assign string to array....
Michael Poutre
@M1kep
Mar 02 2016 05:15
A couple of thins @vsidoren you re-declare array
and re-assign it multiple times including after you assign it to the split
Rachel
@chellybear
Mar 02 2016 05:17
this is a silly question but is there a way to make this even shorter? xD i'm just curious, it's the falsy bouncer exercise
var newAr = arr.filter(function(val){  
    return val? val:null; 
  });

  return newAr;
DJ
@qualitymanifest
Mar 02 2016 05:18
@chellybear return arr.filter(Boolean);
Rachel
@chellybear
Mar 02 2016 05:18
oooooh
lol wow that's awesome haha, thanks @qualitymanifest
CamperBot
@camperbot
Mar 02 2016 05:20
chellybear sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1045 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Vasily Sidorenko
@vsidoren
Mar 02 2016 05:21
so assigning array = string(); makes it equal to the original string
DJ
@qualitymanifest
Mar 02 2016 05:23
@vsidoren when you put () after string like string() you're trying to treat it like a function. but it's not a function, it's just a string. but yeah, assigning array = string; makes it equal to the original string again.
Michael Poutre
@M1kep
Mar 02 2016 05:36
Blewgh I don't like the least common multiple one
Vasily Sidorenko
@vsidoren
Mar 02 2016 05:36
@qualitymanifest thanks
CamperBot
@camperbot
Mar 02 2016 05:36
vsidoren sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1046 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
Abhishek Challa
@abhishekchalla
Mar 02 2016 05:58
@abhishekchalla
Hi, I am trying to create the random quote generator, however I am unable to recieve the json data
http://codepen.io/abhishekchalla/pen/mPbePe
iamlimo
@iamlimo
Mar 02 2016 06:05
Help!!!
CamperBot
@camperbot
Mar 02 2016 06:05

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

iamlimo
@iamlimo
Mar 02 2016 06:06

What's wrong with my code?
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(gift)){
return myObj[gift];
}
else{
return "Not Found";
}
}

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

Raghuram
@Raghuram1994
Mar 02 2016 06:07

// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
What's wrong with my code?
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty("checkProp")===true){
return myObj[checkProp];
}
else { return "Not Found";}
return "Change Me!";
}

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

bitgrower
@bitgrower
Mar 02 2016 06:09
@Raghuram1994 -- you quote "checkProp" as a variable in your .hasOwnProperty ... it's a variable, you don't want to quote it ...
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 06:09
@iamlimo you don't have a variable named gift you have a variable named checkProp
iamlimo
@iamlimo
Mar 02 2016 06:10
@Raghuram1994 @bitgrower @abhishekKumar1 oh thanks. I will modify it
CamperBot
@camperbot
Mar 02 2016 06:10
iamlimo sends brownie points to @raghuram1994 and @bitgrower and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for raghuram1994
:star: 365 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
:star: 684 | @bitgrower | http://www.freecodecamp.com/bitgrower
Raghuram
@Raghuram1994
Mar 02 2016 06:10
got it bro tq @bitgrower
iamlimo
@iamlimo
Mar 02 2016 06:12
@Raghuram1994 it worked!
@Raghuram1994 thanks
CamperBot
@camperbot
Mar 02 2016 06:12
iamlimo sends brownie points to @raghuram1994 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for raghuram1994
iamlimo
@iamlimo
Mar 02 2016 06:13
but I do not understand what I did there
Schuyler Lewis
@spblewis
Mar 02 2016 06:18

So I'm on the 'seek and destroy algorithm. My code works, I'm just wondering if anyone knows a better way to get it done?

function destroyer(arr) {

var args = arr.slice.call(arguments, 1);
function seek(value) {
return value !== args[i];
}
for (i = 0; i < args.length; i++) {
arr = arr.filter(seek);
}
return arr;
}

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

Davinw
@Davinw
Mar 02 2016 06:20
@spblewis hmm, it's your seek function references your loop variable from another function
Markus Kiili
@Masd925
Mar 02 2016 06:20
@spblewis It is better to filter only once and put the loop or indexOf inside the callback.
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 06:20
@spblewis i used filter
like this
function destroyer(arr) {
  // Remove all the values
  var a="";
  for(i=1;i<arguments.length;i++)
    {
      a=arguments[i];
      arr=arr.filter(function(val){ return val!=a;});
    }

  return arr;
}

destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
Davinw
@Davinw
Mar 02 2016 06:22
function destroyer(arr) {
  var argArray = Array.prototype.slice.call(arguments);
  argArray.splice(0, 1);
  return arr.filter(function(element) {
    return argArray.indexOf(element) === -1;
  });
}
similar idea
but no loop
Michael Poutre
@M1kep
Mar 02 2016 06:23
@abhishekchalla you never included jquery
Schuyler Lewis
@spblewis
Mar 02 2016 06:23
how do I get the code to show up like that? much more readable...
Davinw
@Davinw
Mar 02 2016 06:23
help format
CamperBot
@camperbot
Mar 02 2016 06:23

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Markus Kiili
@Masd925
Mar 02 2016 06:23
@Davinw You can do (arguments,1) so no need to splice then.
Michael Poutre
@M1kep
Mar 02 2016 06:24
And @abhishekchalla take a look at this
Andrew Grabarnick
@leprekon91
Mar 02 2016 06:25
This message was deleted
Markus Kiili
@Masd925
Mar 02 2016 06:25
@spblewis Slicing arguments has optimization problems, so using for loop on turning arguments into an array is the preferred way:
function destroyer(arr) {
  var args = [];
  for (var i = 1; i < arguments.length; i++) args[i] = arguments[i];

  return arr.filter(function(val) {
    return args.indexOf(val)===-1;
  });
}
If you forget those problems, you can simplify the code further:
function destroyer(arr) {
  return arr.filter(function(val) {
    return Array.prototype.indexOf.call(this,val,1)===-1;
  },arguments);
}
Andrew Grabarnick
@leprekon91
Mar 02 2016 06:26
function sumPrimes(num) {
  var sum=0;
    for (var i = 0; i < num; i++) 
        if (isPrime(i)) 
            sum += i;
  return sum;
}
function isPrime(num) {
    if (num < 2) 
        return false;
    for (var i = 2; i < num; ++i) 
        if (num % i === 0) 
            return false;   
    return true;
}
Sum all Primes: When num is 977 the answer should be 73156 but i get 72179 instead, What am I missing?
Davinw
@Davinw
Mar 02 2016 06:27
@leprekon91 notice how the difference in your answer and the expected is 977? :)
@leprekon91 need to include the number itself if it's prime
Andrew Grabarnick
@leprekon91
Mar 02 2016 06:27
@Davinw duh...
M. Matthews
@mmatthews1981
Mar 02 2016 06:27
hey hey, anyone available to help debug Symmetric Difference?
Andrew Grabarnick
@leprekon91
Mar 02 2016 06:27
@Davinw thx dude
CamperBot
@camperbot
Mar 02 2016 06:27
leprekon91 sends brownie points to @davinw :sparkles: :thumbsup: :sparkles:
:star: 304 | @davinw | http://www.freecodecamp.com/davinw
Michael Poutre
@M1kep
Mar 02 2016 06:27
Well good night yall
Davinw
@Davinw
Mar 02 2016 06:28
@leprekon91 np! nice solution though :)
Ankit Panwar
@coderNoob
Mar 02 2016 06:28
@meredithmatthews I just finished it. Maybe I can be of some help
Andrew Grabarnick
@leprekon91
Mar 02 2016 06:28
@Davinw the perks of studying C-programming in College...
M. Matthews
@mmatthews1981
Mar 02 2016 06:29
function sym(args) {

  var arg = Array.prototype.slice.call(arguments);
  var res = [];
  var total = [];
  var first = arg.shift();

    function sd(num){
    for(var i = 0; i<num.length; i++) {

      if( arg[0].indexOf(num[i]) > -1 ) {
        arg[0].splice(arg[0].indexOf(num[i]),1);
      } else {
        res.push(num[i]);
      }
    }
    total = res.concat(arg[0]);
    res = [];
    arg = arg.shift();
    if(arg.length > 0) {
      sd(total);
    } else {
    return total;
    }
  }

  return sd(first);

}
@coderNoob this code worked great on a 2-array thing, but when I tried to make it recursive for n-arrays, I get the error "arg[0].indexOf is not a function"
Schuyler Lewis
@spblewis
Mar 02 2016 06:32
Thanks everyone. Not sure I understand the information I just asked for, but I'm sure I will eventually :+1:
Ankit Panwar
@coderNoob
Mar 02 2016 06:32
@meredithmatthews You used shift() and removed your first element from the array. Also, in the for loop you are looping up-to the length of the first element.
Markus Kiili
@Masd925
Mar 02 2016 06:33
@meredithmatthews .reduce() method is always a good option if you know how to do some thing with two array elements and wan't to generalize to variable number of elements.
@meredithmatthews With .reduce() the solution structure would be like this:
function sym(args) {
  args=Array.prototype.slice.call(arguments);
  return args.reduce(function(prev, curr){
    return ??? <- SymmDiff of two arrays prev and curr here
  }, []);
}
M. Matthews
@mmatthews1981
Mar 02 2016 06:38
@Masd925 That's great, but I don't how that actually helps my problem.
Markus Kiili
@Masd925
Mar 02 2016 06:38
This message was deleted
@meredithmatthews If your code works on two arrays, you can use that reduce code to solve the problem.
Marina
@chandra90
Mar 02 2016 06:42
hello! please help me! The task :"Stand in Line". What sould I do here?
function queue(arr, item) {
  // Your code here

  return item;  // Change this line
}
M. Matthews
@mmatthews1981
Mar 02 2016 06:42
@Masd925 it's not that the code works on two, it's that it worked before it was made into a recursive function.
kirbyedy
@kirbyedy
Mar 02 2016 06:43
@chandra90 you should add an item to the array and remove the first element
Markus Kiili
@Masd925
Mar 02 2016 06:44
@meredithmatthews If you don't get it to work recursively, try to put it back where it worked on two arrays, and use that reduce.
Marina
@chandra90
Mar 02 2016 06:44
@kirbyedy how?
M. Matthews
@mmatthews1981
Mar 02 2016 06:44
@Masd925 man, you really love that reduce, huh?
kirbyedy
@kirbyedy
Mar 02 2016 06:44
push adds item to the array, shift, removes the item from the array
Ankit Panwar
@coderNoob
Mar 02 2016 06:45
@meredithmatthews You should try to make a function that basically returns the elements from the first array that are not in the second array
Marina
@chandra90
Mar 02 2016 06:46
@kirbyedy thank you
CamperBot
@camperbot
Mar 02 2016 06:46
chandra90 sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 580 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
HaiderJaan
@HaiderJaan
Mar 02 2016 06:47

function queue(arr, item) {
// Your code here
queue([], 1).push(1);
queue(arr).shift(1);

return queue(arr).shift(1); // 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));
<!-- what's the problem in above code -->

kirbyedy
@kirbyedy
Mar 02 2016 06:48
I just posted two links about the exact same problem
look above
HaiderJaan
@HaiderJaan
Mar 02 2016 06:49
@kirbyedy who will help here
@HaiderJaan read this
Olawale Akinseye
@brainyfarm
Mar 02 2016 06:51
@HaiderJaan, you push item into arr, you then shift the arr
And return the shifted value.
See @kirbyedy MDN documentation links on how to use those.
Ivan
@MoOn5pe11
Mar 02 2016 06:56
I also stuck here... I can not performЖ queue([5,6,7,8,9], 1) should return 5.
function queue(arr, item) {
// Your code here
testArr.push(item);
return testArr.shift(); // Change this line
}
John Irle
@JohnIrle
Mar 02 2016 06:58
I would like some help with Drop it. I pass all but one test.
function drop(arr, func) {
  // Drop them elements.
  for (var i = 0; i <= arr.length; i++) {
    if (func(arr[0])) {
      break;
    } else {
      arr.shift();
    }
  }

  return arr;
}

drop([1, 2, 3, 4], function(n) {return n > 5; });
bitgrower
@bitgrower
Mar 02 2016 07:00
what is the name of the challenge ?
John Irle
@JohnIrle
Mar 02 2016 07:00
Drop it?
bitgrower
@bitgrower
Mar 02 2016 07:05
well, for one why do you loop while i is less than or equal to arr.length ?
demipixel
@demipixel
Mar 02 2016 07:06
I need help
How do I do permAlone
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:06
@doudeman you want to be using filter
for that bonfire
bitgrower
@bitgrower
Mar 02 2016 07:07
really ? hmmm ... they didn't even suggest that in the instructions ... makes a bit of sense tho' ...
c'mon, @demipixel ... don't believe ya ... :)
demipixel
@demipixel
Mar 02 2016 07:10
its annoying
and hard
bitgrower
@bitgrower
Mar 02 2016 07:11
c'mon you know better ... you know to say the name of the challenge & post your code at the very least ...
demipixel
@demipixel
Mar 02 2016 07:11
i have no code
the challenge is no repeats pls
Brian
@sludge256
Mar 02 2016 07:12
Use ES6 :trollface:
demipixel
@demipixel
Mar 02 2016 07:12
im tryin
bitgrower
@bitgrower
Mar 02 2016 07:12
touche, @sludge256
Brian
@sludge256
Mar 02 2016 07:13
I actually haven't done that one yet
Just giving you a hard time :P
Yea the music is going crazy
bitgrower
@bitgrower
Mar 02 2016 07:14
LOL ... just had someone set up a profile of a friend of mine on fb and try to scam me ...
reported their profile to fb -- fb acted pretty dang fast ...
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:14
@bitgrower Please keep the discussion on topic :)
Josh Fisk
@JoshFisk
Mar 02 2016 07:14
I do not understand the "No repeats please" challenge.
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:14
Yeah, that's a tough nut to crack
Josh Fisk
@JoshFisk
Mar 02 2016 07:15
The instructions do not seem to match the test results. I'm confused about it
bitgrower
@bitgrower
Mar 02 2016 07:15
JoshFisk ...actually, they do ... read the example they discuss in the instructions ...
Josh Fisk
@JoshFisk
Mar 02 2016 07:15
I did it by hand for this one
permAlone("aabb") should return 8.
How do you get 8 if you eliminate repeats?
bitgrower
@bitgrower
Mar 02 2016 07:16
because the letters are positionally relevant
HaiderJaan
@HaiderJaan
Mar 02 2016 07:16
@brainyfarm have you code of it ? if you have ten plz paste it here
bitgrower
@bitgrower
Mar 02 2016 07:16
a(1)a(2)b(1)b(2) is not the same as a(2)a(1)b(1)b(2) -- even though,, to the eye, they look the same ...
Brian
@sludge256
Mar 02 2016 07:17
You understand the problem though right?
Nevermind bitgrower is on it
bitgrower
@bitgrower
Mar 02 2016 07:17
LOL ... not really ... here to give me more bad times, @sludge256 ... ?
Josh Fisk
@JoshFisk
Mar 02 2016 07:18
So I'm to treat each letter as unique, but not let the same letter touch?
Brian
@sludge256
Mar 02 2016 07:18
I was going to give examples like you are ;)
HaiderJaan
@HaiderJaan
Mar 02 2016 07:18

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

queue(arr) = queue(item).push;

return queue(arr); // 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));
<!--I can't understand what i have to do in above code -->

Aniruddh Agarwal
@anrddh
Mar 02 2016 07:19
function queue(arr, item) {
  // Your code here

  queue(arr) = queue(item).push;

  return queue(arr);  // 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));
                                                                                                                                        <!--I can't understand what i have to do in above code -->
@HaiderJaan ^ pleasse format your code like this
Josh Fisk
@JoshFisk
Mar 02 2016 07:19
@bitgrower
baba
abab
So just these two manage to pull of 8 combinations, if I treat each letter as a unique thing
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:20
@HaiderJaan which bonfire?
bitgrower
@bitgrower
Mar 02 2016 07:20
@JoshFisk go over the example they discuss in the instructions ... carefully ... and what I just said ... the 2 different a's are not interchangeable ...
Rami
@RNwebdk
Mar 02 2016 07:21
hii @bitgrower , how are you :)
?
bitgrower
@bitgrower
Mar 02 2016 07:22
seems it's hassle bitgrower night ... in the larger cosmos ...
Rami
@RNwebdk
Mar 02 2016 07:22
:P
bitgrower
@bitgrower
Mar 02 2016 07:23
how about you ?
Muse
@nokoli200
Mar 02 2016 07:23
if I accidentally closed out of a private chat how would I reopen it?
bitgrower
@bitgrower
Mar 02 2016 07:24
click on the person's profile and click the button that says "chat privately"
on their profile pic, that is ...
Rami
@RNwebdk
Mar 02 2016 07:25
fine thank you, it's early here, just delivered the kid in kindergarten
bitgrower
@bitgrower
Mar 02 2016 07:27
where are you, Oz ?
oh ... Denmark ...
Rami
@RNwebdk
Mar 02 2016 07:28
yup, what about you ? does not say on you profile :)
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:28
Hey guys, please take the conversation to a private chat :) This is a help room.
Rami
@RNwebdk
Mar 02 2016 07:29
well, this is not a private conversation :P you are reading it LOL!
just kidding
bitgrower
@bitgrower
Mar 02 2016 07:32
well .. @awesomeaniruddh ... looks like you lost your domain ...
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:34
Yes, I haven't bothered to renew it
Caleb Martin
@caleb272
Mar 02 2016 07:34
^ that sucks
bitgrower
@bitgrower
Mar 02 2016 07:35
looks like someone's already bought it and is willing to sell it back to you ... darn .. I was gonna look at your blog ... :)
anthonygallina1
@anthonygallina1
Mar 02 2016 07:35
hi @bitgrower
Rami
@RNwebdk
Mar 02 2016 07:35
is there a way to tell a website which images to load first ? i have about 30 images to load on my index page and the load time is getting very heavy on a phone
bitgrower
@bitgrower
Mar 02 2016 07:36

but dang ... congrats ... have both front & back certs ... nice goin' @awesomeaniruddh

hi @anthonygallina1 ! :)

anthonygallina1
@anthonygallina1
Mar 02 2016 07:36
:)
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:36
Yes, I got them before they added the API and React/D3 projects to the curriculum. I haven't gotten around to completing those though
anthonygallina1
@anthonygallina1
Mar 02 2016 07:37
@bitgrower ya I was just looking at the buy this domain link my self.
bitgrower
@bitgrower
Mar 02 2016 07:37
@RNwebdk -- there may be, sounds familiar ... have you checked some of the webdev blogs ?
anthonygallina1
@anthonygallina1
Mar 02 2016 07:38
@bitgrower might just be parked?
bitgrower
@bitgrower
Mar 02 2016 07:38
I'm surprised bootstrap doesn't do some sort of image optimization, as well ...
Rami
@RNwebdk
Mar 02 2016 07:38
@bitgrower i tried to google at little, but i don't know what i'm looking for.
Aniruddh Agarwal
@anrddh
Mar 02 2016 07:38
@bitgrower Hmm, well it's not designed to do that :) It simply provides you with elements you can use for quickly prototyping as well as a grid
bitgrower
@bitgrower
Mar 02 2016 07:39
well ... it uses some jquery, & i would think with the jquery it could do some interesting sizing of the images'n'things ...
Tautvydas Banys
@TautBanys
Mar 02 2016 07:39
wiki pig latin
CamperBot
@camperbot
Mar 02 2016 07:39

:point_right: algorithm pig latin [wiki]

Problem Explanation:

  • You need to create a program that will translate from English to Pig Latin. Check the instructions for converting to Pig Latin from the initial description or the wiki page. It might not be obvious but you need to remove all the consonants up to the first vowel in the case there letter does not start with a vowel.
:pencil: read more about algorithm pig latin on the FCC Wiki
bitgrower
@bitgrower
Mar 02 2016 07:40
yeah ... figuring out what to search for can be a challenge at times ... let's see if I can get something which might help ....
Rami
@RNwebdk
Mar 02 2016 07:40
appreciate that :)
bitgrower
@bitgrower
Mar 02 2016 07:41
see if this search looks interesting: image loading optimization
Rami
@RNwebdk
Mar 02 2016 07:42
:thumbsup:
thanks @bitgrower
CamperBot
@camperbot
Mar 02 2016 07:42
rnwebdk sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 685 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 02 2016 07:42
you do know you have to report back your newfound expertise, right ?
ooh ... maybe you could write an FCC medium post about it, or comment in the subreddit ... !!!
Irina Sokolovskaja
@ierhyna
Mar 02 2016 07:50
wiki sorted union
CamperBot
@camperbot
Mar 02 2016 07:50

:point_right: algorithm sorted union [wiki]

Problem Explanation:

  • The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
:pencil: read more about algorithm sorted union on the FCC Wiki
HaiderJaan
@HaiderJaan
Mar 02 2016 07:52

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

queue(arr) = queue(item).push;

return queue(arr); // 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));
<!--Guys whats the problem in my code -->

Rami
@RNwebdk
Mar 02 2016 07:53
@HaiderJaan please format your code when posting it
function queue(arr, item) {
  // Your code here

  queue(arr) = queue(item).push;

  return queue(arr);  // 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));
 <!--Guys whats the problem in my code -->
HaiderJaan
@HaiderJaan
Mar 02 2016 07:55
@RNwebdk REference erroor : invalid assignment left-hand side ............is coming
Rami
@RNwebdk
Mar 02 2016 07:57
@HaiderJaan challenge name ?
kirbyedy
@kirbyedy
Mar 02 2016 07:57
@HaiderJaan you just have to push the item into array and the shift then first element, thats it
Cris Nagandang
@louger143
Mar 02 2016 07:59
hi guys, kinda stuck up. I'm doing the random quote challenge. But it seems I always end up (“No 'Access-Control-Allow-Origin' header is present on the requested resource”)
kirbyedy
@kirbyedy
Mar 02 2016 07:59
so yourarray = item.push
but in the correct syntax
@louger143 I personally hard coded the quotes, but post the link to your pen, and we will try to help
bitgrower
@bitgrower
Mar 02 2016 08:02
@louger143 -- yeah, read up on CORS and using cross-domain xmlhttprequests ... I am told (haven't tried it yet) -- that the solution is to use something called JSONP ...
kirbyedy
@kirbyedy
Mar 02 2016 08:02
+1
bitgrower
@bitgrower
Mar 02 2016 08:03
I haven't actually solved the problem of cross domain requests -- just that those are the pointers I've been given to explore ...
kirbyedy
@kirbyedy
Mar 02 2016 08:04
yes
bitgrower
@bitgrower
Mar 02 2016 08:04
I was trying to get some of the early JSON API challenges to run on codepen ... someone gave me one where I could get the cat photos, but I was trying to get the challenge where it displayed the json when you clicked the button ... I figured getting THAT to work could be very handy in future ziplines ...
kirbyedy
@kirbyedy
Mar 02 2016 08:04
I personally used that callback=? thingy
bitgrower
@bitgrower
Mar 02 2016 08:05
not familiar with that @kirbyedy
details! details! We want details!!! ... you can't just tease us like that, you know ... :)
kirbyedy
@kirbyedy
Mar 02 2016 08:07
well apparently that callback=? is used in your json line and than it bypasses the cors restriction
not sure if I am right, this is how I understood the crap
bitgrower
@bitgrower
Mar 02 2016 08:08
ah okay ... I guess the next great challenge in api stuffs is getting all your async requests to play in harmony ... :)

it's funny ... looking at the sorted union challenge ... I look at my code and I am both impressed and saddened ...

...at first I look at the reduce code I use and go ... "wow, I did that?" ... then I see some places where I go ... eh? So why didn't I do THAT???

in fact ... it really looks like I "tried" to use reduce ... it worked, but the way I did it seemed like I didn't even need to bother with reduce ... LOL ...
bitgrower
@bitgrower
Mar 02 2016 08:13
ah well ... thanks @kirbyedy -- will have to explore the great callback phenom tomorrow ... :)
CamperBot
@camperbot
Mar 02 2016 08:13
bitgrower sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 581 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
kirbyedy
@kirbyedy
Mar 02 2016 08:16
you at work ? @bitgrower
jirkae
@jirkae
Mar 02 2016 08:20

Hello, please does anyone can help me with require.js?

quirejs.config({
    baseUrl: 'js',
    shim: {
        'jcf.select': {
            deps: ['jcf'],
            exports: 'jcf.modules.Select'
        },
        'jcf.checkbox': {
            deps: ['jcf'],
            exports: 'jcf.modules.Checkbox'
        }
    }
});

// test
require(['jcf', 'jcf.select', 'jcf.checkbox'], function(jcf) {
        jcf.replaceAll();
});

but the checkbox dont see jcf. Thanks

Ankit Panwar
@coderNoob
Mar 02 2016 08:32
How to turn an array into an array of objects?
As in put the elements of that array as objects in another array.
Markus Kiili
@Masd925
Mar 02 2016 08:46
@coderNoob "as objects in another array". How that differs from the original array?
Try to write an example of what you wan't to transform into what.
David Bruskin
@kidimi
Mar 02 2016 09:09
I screwed up and now I literally can't get past "Factorialize a Number!" I stupidly didn't heed the warning about a "possible" infinite loop. I disengaged the protection (// noprotect on Line 1) and, indeed my browser crashed. But now, everytime I just go to the page where the evil unprotected code exists, the page immediately freezes and the browser crashes, as if it's loading the window contents without being asked. Is there anything I can do, or is there something an admin-type-person can do -- go through a backdoor -- and erase the bad code so I can get back onto the page? Thanks!
Muhammed Ibrahim
@MuhammedKhamis
Mar 02 2016 09:11
What should I do after finishing JavaScript tutorials ??
Kat
@Topzie
Mar 02 2016 09:11
This code works, but it doesn't pass the test/challenge. Why is that? Btw you can ignore the comments, I tried different approaches.
function titleCase(str) {
  var str1 = str.toLowerCase().split(' ');

  str="";
  for (var i=0; i<str1.length; i++){
    str += str1[i].charAt(0).toUpperCase() + str1[i].substring(1) + " ";

  }

// var newString = str.join(" ");
//  return newString;

  $.trim(str); //get rid of the last space
  return str;
}

titleCase("HERE IS MY HANDLE HERE IS MY SPOUT");
David Bruskin
@kidimi
Mar 02 2016 09:11
Correction: I can get past the page, but I would still like to fix the Factorialize page so I can complete that challenge.
Muhammed Ibrahim
@MuhammedKhamis
Mar 02 2016 09:11
I mean how to use js in web ??
Robert Uivarosi
@URobert
Mar 02 2016 09:43
@Topzie what is the name of that challenge ?
Kat
@Topzie
Mar 02 2016 09:44
@URobert Title Case a Sentence
Gabriel Brunette-Savard
@gabrielsavard
Mar 02 2016 09:44

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

testObj["an entree"];
testObj['the drink'];

i get error testObj is undefined
any one see the errors
Kat
@Topzie
Mar 02 2016 09:46
@gabrielsavard I think you have to assign them to new vars:--> var entree = testObj["an entree"];
HaiderJaan
@HaiderJaan
Mar 02 2016 09:47

function queue(arr, item) {
// Your code here
var it = arr[0];
arr[0] = arr[1];
arr[1] = arr[2];
arr[2] = arr[3];
arr[3] = arr[4];
arr[4] = item;
return it; // 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));
<!--Please help me what's rhe problem in above code -->

Aniruddh Agarwal
@anrddh
Mar 02 2016 09:47
@HaiderJaan which Bonfire?
Kat
@Topzie
Mar 02 2016 09:48
@URobert I know there are other ways to solve this, but I think this is also a legimate way. All the examples pass the test.
HaiderJaan
@HaiderJaan
Mar 02 2016 09:48
@awesomeaniruddh stand in line
Robert Uivarosi
@URobert
Mar 02 2016 09:48
@Topzie yes. It is interesting. I saw it works, I'm trying to figure out why it doesn't pass the challege
Aniruddh Agarwal
@anrddh
Mar 02 2016 09:49
@Topzie
function titleCase(str) {
  var str1 = str.toLowerCase().split(' ');

  str="";
  for (var i=0; i<str1.length; i++){
    str += str1[i].charAt(0).toUpperCase() + str1[i].substring(1) + " ";

  }

// var newString = str.join(" ");
//  return newString;

  str = $.trim(str); //get rid of the last space
  return str;
}

titleCase("sHoRt AnD sToUT");
That does it
You weren't assigning the returned string back to str from $.trim()
@HaiderJaan can you link me please?
Robert Uivarosi
@URobert
Mar 02 2016 09:54
@Topzie I changed your trim line with a simple slice:
  str = str.slice(0, -1);//get rid of the last space
HaiderJaan
@HaiderJaan
Mar 02 2016 09:54
@awesomeaniruddh ??? plz tell me if there any solution
Aniruddh Agarwal
@anrddh
Mar 02 2016 09:54
@HaiderJaan
function queue(arr, item) {
  // Your code here
  arr.push(item);
  var num = arr[0];
  arr.shift();
  return num;  // 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
That's how you'd do it
HaiderJaan
@HaiderJaan
Mar 02 2016 09:55
Thanks @awesomeaniruddh
CamperBot
@camperbot
Mar 02 2016 09:55
haiderjaan sends brownie points to @awesomeaniruddh :sparkles: :thumbsup: :sparkles:
:star: 540 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
Kat
@Topzie
Mar 02 2016 09:58
@awesomeaniruddh Thank you, but what do you mean? My point is that my code works. I've put in all the examples and they all get capitalised. @URobert Thank you, perhaps I'm not supposed to use jQuery.
CamperBot
@camperbot
Mar 02 2016 09:58
topzie sends brownie points to @awesomeaniruddh and @urobert :sparkles: :thumbsup: :sparkles:
:star: 541 | @awesomeaniruddh | http://www.freecodecamp.com/awesomeaniruddh
:star: 649 | @urobert | http://www.freecodecamp.com/urobert
Coogy
@Coogy
Mar 02 2016 09:59

Hoping someone can shed some light here... I just completed the "profile lookup" challenge and got my code to run properly, but I know I did a roundabout way of it. Can someone look at my code and explain how I could have done this a bit better?

function lookUp(firstName, prop){
// Only change code below this line
var value = "";
firstNames = [];

for (var j = 0; j < contacts.length; j++) {
firstNames.push(contacts[j].firstName);
}

if (!(firstName in firstNames)) {
value = "No such contact";
}

for (var i = 0; i < contacts.length; i++) {
if (firstName != contacts[i].firstName) {
continue;
} else if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
value = contacts[i][prop];
} else if (firstName == contacts[i].firstName && !contacts[i].hasOwnProperty(prop)) {
value = "No such property";
}
}
return value;
// Only change code above this line
}

...also how do I make my code look less ugly in chat :-P
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 09:59
bot format
CamperBot
@camperbot
Mar 02 2016 09:59

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Abhishek Kumar
@abhishekKumar1
Mar 02 2016 10:00
@Coogy use this ^^^
Coogy
@Coogy
Mar 02 2016 10:00
```
oops
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 10:01
@Coogy you can edit your comment too from right side
Kat
@Topzie
Mar 02 2016 10:03
@awesomeaniruddh You were also right, I see what you mean now. :)
Coogy
@Coogy
Mar 02 2016 10:07
finally got it :smile:
function lookUp(firstName, prop){
// Only change code below this line
  var value = "";
  firstNames = [];

  for (var j = 0; j < contacts.length; j++) {
    firstNames.push(contacts[j].firstName);
  }

  if (!(firstName in firstNames)) {
    value = "No such contact";
  }

  for (var i = 0; i < contacts.length; i++) {
    if (firstName != contacts[i].firstName) {
      continue;
    } else if (firstName == contacts[i].firstName && contacts[i].hasOwnProperty(prop)) {
      value = contacts[i][prop];
    } else if (firstName == contacts[i].firstName && !contacts[i].hasOwnProperty(prop)) {
      value = "No such property";
    } 
  }
  return value;
// Only change code above this line
}
Ankit Panwar
@coderNoob
Mar 02 2016 10:12
@Masd925 In the exact change BF, I need to turn the cid array into an object array.
iamlimo
@iamlimo
Mar 02 2016 10:21
Help
CamperBot
@camperbot
Mar 02 2016 10:21

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. ex: find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Markus Kiili
@Masd925
Mar 02 2016 10:22
@coderNoob cid is an array of arrays, and so is the return value.
Ankit Panwar
@coderNoob
Mar 02 2016 10:23
@Masd925 So I need not turn it into object ?
iamlimo
@iamlimo
Mar 02 2016 10:24
How do I fix this?
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
// Add record here
];
Markus Kiili
@Masd925
Mar 02 2016 10:24
@coderNoob Arrays are objects. No need to transform anything (content is wrong of course).
Ankit Panwar
@coderNoob
Mar 02 2016 10:29
@Masd925 So far all I have is the total from the cid and the change and I'm totally lost as how to approach this thing. Please help me out.
@iamlimo You can simply add another record like
var myMusic = [
 { 
    // Previous record
 }
 {
    "artist": "Pink Floyd",
    "title": "Wish You Were here",
    "release_year": 1976,
    "formats": [
          "CS",
          "8T",
          "LP"
      ],
     "gold": true
  }
];
Rami
@RNwebdk
Mar 02 2016 10:33
can someone help me with Nesting For Loops challenge
it says multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040
my code returns 28
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
    for(var i=0; i < arr.length; i++){
      for(var j=0; j < arr[i].length; j++){
        product += arr[i][j];
      }
    }
  // Only change code above this line
  return product -1;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Ankit Panwar
@coderNoob
Mar 02 2016 10:33
@RNwebdk Show us your code.
Rami
@RNwebdk
Mar 02 2016 10:34
was working on it :)
Junn Eric
@juntyms
Mar 02 2016 10:34
hi I'm stuck on accessing nested arrays in json
Markus Kiili
@Masd925
Mar 02 2016 10:35
@coderNoob I started like this:
var NOTES = {"ONE HUNDRED":100,"TWENTY":20,"TEN":10,"FIVE":5,"ONE":1,"QUARTER":0.25,"DIME":0.10,"NICKEL":0.05,"PENNY":0.01};
  var DELTA = 0.0000001;
  var changeLeft = cash-price;
  cid.reverse();
Junn Eric
@juntyms
Mar 02 2016 10:36

// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.type.trees.list[1]; // Change this line

iamlimo
@iamlimo
Mar 02 2016 10:36
@coderNoob like this
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
"artist":"love",
"title": "love",
"release_year": 2016,
];
Markus Kiili
@Masd925
Mar 02 2016 10:36
@coderNoob Then I iterated through cid and checked if I can pay some change from the notes being iterated.
Ankit Panwar
@coderNoob
Mar 02 2016 10:36
@iamlimo You left out the { } around your second artist.
Junn Eric
@juntyms
Mar 02 2016 10:36
@iamlimo you have missing code
,{"artist":"love",
"title": "love",
"release_year": 2016,}
@iamlimo ,{"artist":"love",
"title": "love",
"release_year": 2016, "formats":["LP","CS"]}
Ankit Panwar
@coderNoob
Mar 02 2016 10:37
@Masd925 You reversed cid to make the matching with your NOTES more convenient?
Markus Kiili
@Masd925
Mar 02 2016 10:38
@coderNoob Yes, because you pay with largest notes first.
iamlimo
@iamlimo
Mar 02 2016 10:39
@coderNoob @juntyms thanks it worked
CamperBot
@camperbot
Mar 02 2016 10:39
iamlimo sends brownie points to @codernoob and @juntyms :sparkles: :thumbsup: :sparkles:
:star: 342 | @codernoob | http://www.freecodecamp.com/codernoob
:star: 222 | @juntyms | http://www.freecodecamp.com/juntyms
Markus Kiili
@Masd925
Mar 02 2016 10:42
@coderNoob Delta is for the rounding errors. You could use pennies in your calculations to avoid rounding errors too.
Ankit Panwar
@coderNoob
Mar 02 2016 10:48
@Masd925 NOTES in your code is object and cid is an array of an array. How do I compare them ?
Markus Kiili
@Masd925
Mar 02 2016 10:50
@coderNoob NOTES is for transforming note names to values. Because cid elements have note name and money amount.
Ankit Panwar
@coderNoob
Mar 02 2016 10:51
@Masd925 Got it ( I think). Thank you.
CamperBot
@camperbot
Mar 02 2016 10:51
codernoob sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1113 | @masd925 | http://www.freecodecamp.com/masd925
rexler
@rexler
Mar 02 2016 10:54
@RNwebdk You're almost correct but you're adding the results instead of multiplying them. You need to change your line from product += to product *=
MD Alsaffar
@Cyberistic
Mar 02 2016 11:12
help Golf Code
CamperBot
@camperbot
Mar 02 2016 11:12

:point_right: checkpoint golf code [wiki]

Details

We will now use our knowledge about else if statements and comparison with equality, less and greater operators.

In the game of golf each hole has a par for the average number of strokes needed to sink the ball. Depending on how far above or below par your strokes are, there is a different nickname.

Your function will be passed a par and strokes. Return strings according to this table (based on order of priority - top (highest) to bottom (lowest)):

Strokes Return
1 "Hole-in-one!"
<= par - 2 "Eagle"
par - 1 "Birdie"
par "Par"
par + 1 "Bogey"
par + 2 "Double Bogey"
>= par + 3 "Go Home!"

par and strokes will always be numeric and positive.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.
:pencil: read more about checkpoint golf code on the FCC Wiki

Nenad
@nexon91
Mar 02 2016 11:19
  function end(str, target) {
  // "Never give up and good luck will find you."
  // -- Falcor
  if (str == target.substr(str,target)){
  return true;
  } else return false;
}

end("He has to give me a new name", "me");
What shoud I do to make it work? Thanks
Codemzy
@codemzy
Mar 02 2016 11:22
@nexon91 what is the challenge for? I'm guessing based on the function name you are looking to see if str ends with target? At the minute in your if statement you are seeing if the whole of str matches a substring of target... I think it should be the other way around, see if target matches a substr of str, and then that substr should start whatever the length of target is from the end, and go the end of str? If that makes sense lol
@nexon91 so basically you need to get the end of your str, of the same length as target, and then compare that to see if it matches target
Nenad
@nexon91
Mar 02 2016 11:26
Chellenge is Confirm the Ending... Thx,I will check now if I can solve it...
Meghana
@meghanasarikonda
Mar 02 2016 11:27
hello pls help me
js
<function rot13(str) { // LBH QVQ VG!
  var x;
  var string="";
  for(var i=0;i<str.length;i++){
  x=str.charCodeAt(i);
  string.fromCharCode(65);
}
  return str;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");>
im getting str.fromCharCode is not a function
matthew3454
@matthew3454
Mar 02 2016 11:28
Can someone help me with this code? Your assistance will be greatly appreciated. I don't know what to put inside arr.sort();. I know that I'm supposed to put something like compareFunctioninside it, but I don't know where to go from there........ Here is my code:
function where(arr, num) {  
arr.push(num);  
arr.sort(compareFunction);  
for(i = 0; i < arr.length; i++){  
  if(arr[i] === num){ 
    return i; 
  } 
} 
} 

where([40, 60], 50);
Meghana
@meghanasarikonda
Mar 02 2016 11:30
@matthew3454 use write a function inside it
matthew3454
@matthew3454
Mar 02 2016 11:31
@meghanasarikonda okay. I'll try that out.
Meghana
@meghanasarikonda
Mar 02 2016 11:32
@matthew3454 which is given in helpful links
Array.sort()
Codemzy
@codemzy
Mar 02 2016 11:33
@meghanasarikonda you need String with a capital S for fromCharCode
@meghanasarikonda if you want to save the result in a variable you could do... var letter = String.fromCharCode(65);
Meghana
@meghanasarikonda
Mar 02 2016 11:35
@codemzy did i have to declare the String with var
js
<function rot13(str) { // LBH QVQ VG!
  var x;
  var String="";
  for(var i=0;i<str.length;i++){
  x=str.charCodeAt(i);
  String.fromCharCode(65);
}
  return str;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");>
Codemzy
@codemzy
Mar 02 2016 11:35
@meghanasarikonda no, its not applying it to your string var... its just its own function String.fromCharCode(); is its own function you just pass in the number you want to convert
Meghana
@meghanasarikonda
Mar 02 2016 11:36
@codemzy yeah i got that
Codemzy
@codemzy
Mar 02 2016 11:36
@meghanasarikonda so you can get rid of var String="";

@meghanasarikonda if you do

  var letter = String.fromCharCode(65);
}
  return letter;
}

You will see the letter returned, just so you know its working :thumbsup:

Meghana
@meghanasarikonda
Mar 02 2016 11:41
@codemzy yeah i understood
thanks
matthew3454
@matthew3454
Mar 02 2016 11:42
@meghanasarikonda I got this much farther......arr.sort(function ();
arr.sort(function ()); @meghanasarikonda
Meghana
@meghanasarikonda
Mar 02 2016 11:42
@matthew3454
<function compareNumbers(a, b) {
  return a - b;
}>
use this code
matthew3454
@matthew3454
Mar 02 2016 11:43
@meghanasarikonda thanks!. So compareNumbers is hard coded to compare numbers?
CamperBot
@camperbot
Mar 02 2016 11:43
matthew3454 sends brownie points to @meghanasarikonda :sparkles: :thumbsup: :sparkles:
:star: 263 | @meghanasarikonda | http://www.freecodecamp.com/meghanasarikonda
Meghana
@meghanasarikonda
Mar 02 2016 11:46
@codemzy thanks
CamperBot
@camperbot
Mar 02 2016 11:46
meghanasarikonda sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 683 | @codemzy | http://www.freecodecamp.com/codemzy
Codemzy
@codemzy
Mar 02 2016 11:46
@meghanasarikonda :thumbsup:
A-Alex-A
@A-Alex-A
Mar 02 2016 11:46

Hi!

function sumAll(arr) {
  var sum = (Math.max(arr[0],arr[1]) - Math.min(arr[0],arr[1]) + 1) * (arr[0] + arr[1]) / 2;
  return sum;
}

Here i use sum formula for sequence. array.reduce implies generating all numbers in a range and then sum an array of those numbers?

Meghana
@meghanasarikonda
Mar 02 2016 11:47
This message was deleted
@codemzy
js
<function rot13(str) { // LBH QVQ VG!
  var value="";
  var arr=[];
  for(var i=0;i<str.length;i++){
  var x=str.charCodeAt(i);
  value+=String.fromCharCode(x+13);

}
  return value;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
>
matthew3454
@matthew3454
Mar 02 2016 11:48
@meghanasarikonda Why is there a SyntaxError: Unexpected token )?
function where(arr, num) {  
arr.push(num);  
arr.sort( function compareNumbers(a, b)) {
  return a - b;
};  
for(i = 0; i < arr.length; i++){  
  if(arr[i] === num){ 
    return i; 
  } 
} 
} 

where([40, 60], 50);
Brendan Kinahan
@BKinahan
Mar 02 2016 11:48
@matthew3454 it's highlighted in red there, the extra ) on the third line
@matthew3454 it belongs after } on the 5th line
Meghana
@meghanasarikonda
Mar 02 2016 11:49
@codemzy please look into this im getting different answer
matthew3454
@matthew3454
Mar 02 2016 11:49
@BKinahan Yes and when I remove it the SyntaxError says missing ) after argument list
Brendan Kinahan
@BKinahan
Mar 02 2016 11:49
@matthew3454 see my second message ;)
matthew3454
@matthew3454
Mar 02 2016 11:49
okay
Brendan Kinahan
@BKinahan
Mar 02 2016 11:49
@matthew3454 the entire function is an argument of the sort() method
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 11:50
@matthew3454 because you have to close sort()
rexler
@rexler
Mar 02 2016 11:50
@matthew3454 You can't pass a function declaration into another function. Are you trying to pass in the result of the function compareNumbers
Meghana
@meghanasarikonda
Mar 02 2016 11:50
@matthew3454 yes the same correction by BKinahan
matthew3454
@matthew3454
Mar 02 2016 11:51
@meghanasarikonda @BKinahan @abhishekKumar1
function where(arr, num) {  
arr.push(num);  
arr.sort( function compareNumbers(a, b) {
  return a - b;
}; )

for(i = 0; i < arr.length; i++){  
  if(arr[i] === num){ 
    return i; 
  } 
} 
} 

where([40, 60], 50);
Brendan Kinahan
@BKinahan
Mar 02 2016 11:51
@matthew3454 after the }, not after the ;
matthew3454
@matthew3454
Mar 02 2016 11:52
@BKinahan gotcha
Meghana
@meghanasarikonda
Mar 02 2016 11:52
@matthew3454 after before }give )
matthew3454
@matthew3454
Mar 02 2016 11:52
@BKinahan Thanks peeps @meghanasarikonda @abhishekKumar1
CamperBot
@camperbot
Mar 02 2016 11:52
matthew3454 sends brownie points to @bkinahan and @meghanasarikonda and @abhishekkumar1 :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave meghanasarikonda points
Meghana
@meghanasarikonda
Mar 02 2016 11:52
@matthew3454
});
CamperBot
@camperbot
Mar 02 2016 11:52
:star: 366 | @abhishekkumar1 | http://www.freecodecamp.com/abhishekkumar1
:star: 984 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 02 2016 11:52
@matthew3454 it expands like this: arr.sort(); -> arr.sort(callback); -> arr.sort(function(args){});
matthew3454
@matthew3454
Mar 02 2016 11:53
@BKinahan I'll write that down. Thank you.
CamperBot
@camperbot
Mar 02 2016 11:53
matthew3454 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: matthew3454 already gave bkinahan points
matthew3454
@matthew3454
Mar 02 2016 11:54
it worked
Meghana
@meghanasarikonda
Mar 02 2016 11:54
pls look into my code
js
<function rot13(str) { // LBH QVQ VG!
  var value="";
  var arr=[];
  for(var i=0;i<str.length;i++){
  var x=str.charCodeAt(i);
  value+=String.fromCharCode(x+13);

}
  return value;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");>
Abhishek Kumar
@abhishekKumar1
Mar 02 2016 11:56
@meghanasarikonda think about the ascii value of Z,Y etc that will go beyond 90
Codemzy
@codemzy
Mar 02 2016 11:56
@meghanasarikonda what are you getting back? I know that some of the letters you have to -13 if they are below a certain part in the charCode numbering
I mean above sorry
George Kiknadze
@kiknaio
Mar 02 2016 11:56
help Roman Numeral Converter
CamperBot
@camperbot
Mar 02 2016 11:56

:point_right: algorithm roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a roman numeral.
:pencil: read more about algorithm roman numeral converter on the FCC Wiki
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 11:59

Can someone tell what the main difference using jquery .append() or .html()

I am trying to figure it ut why I am getting all the daata mixed in my Twitch TV

George Kiknadze
@kiknaio
Mar 02 2016 12:00
@Abel1987 main difference is .html() removes all other stuff from selected html
and .append() adds after selected item
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 12:01
umm, I want to create a div for each user... but I am getting it all mixed
may I show you what i am doing?
George Kiknadze
@kiknaio
Mar 02 2016 12:01
yeah sure
Riekert
@ReaperZa
Mar 02 2016 12:01
Hey guys... struggling a bit...
got the following code. all tests good but the last two things fail.
This message was deleted
oh my bad...
George Kiknadze
@kiknaio
Mar 02 2016 12:02
maybe it's better idea to write this function with switch statemenet
Riekert
@ReaperZa
Mar 02 2016 12:03
function golfScore(par, strokes) {
  // Only change code below this line
  if (par <= 5 && strokes == 1)
    {
      return "Hole-in-one!";
    }
  else if (par <=5 && strokes <= 2)
    {
      return "Eagle";
    }
  else if (par <=5 && strokes <= 3)
    { 
      return "Birdie";
     }
  else if (par == strokes)
    { 
      return "Par";
    }
  else if (strokes == par + 1)
    { 
      return "Bogey";
    }
  else if (strokes == par + 2)
    {
      return "Double Bogey";
    }
  else if (strokes >= par + 3)
    { 
      return "Go Home";
    }


  // Only change code above this line
}

// Change these values to test
golfScore(4, 120);
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 12:04

http://codepen.io/DiazPedroAbel/pen/KzpdPp?editors=1010

As you can see if you switch between listChannels[i] 1 or 2 you can see two examples of offline and online

So now, that is working aparently I set a for loop to check all my list, and then is when I am getting all the data mixed
George Kiknadze
@kiknaio
Mar 02 2016 12:06
I don't really get
let me explain by example
@Abel1987

<div class="a">George</div>

//with .html()
$('.a').html('<p>George</p>')
//This will change div class to p and there will be
<p>George</p>

//-----------------
// now with .append()
<div class="a">George</div>

$('.a').append('Kiknadze');

//it will be 
<div class="a">George Kiknadze</div>
A-Alex-A
@A-Alex-A
Mar 02 2016 12:10
function diff(arr1, arr2) {
var newArr = [];
// Same, same; but different.

  newArr1 = arr2.filter(function(x){
    return arr1.indexOf(x) === -1;
  });
  newArr2 = arr1.filter(function(x){
    return arr2.indexOf(x) === -1;
  });
  newArr = newArr1.concat(newArr2);

return newArr;
}
any feedback?
The output is correct but can not proceed to the next problem.
Is it necessary to use some loop?
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 12:15
@kiknag ok got it, but I cannot see what is not working on my code.
Markus Kiili
@Masd925
Mar 02 2016 12:17
@A-Alex-A You can lose the variable by return newArr1.concat(newArr2);. Also you should use var on those newArr variables.
Riekert
@ReaperZa
Mar 02 2016 12:17
Sorted my issue... I was being an idiot :P
Markus Kiili
@Masd925
Mar 02 2016 12:18
@ReaperZa There are no idiots here. Some just have thicker skull than others.
A-Alex-A
@A-Alex-A
Mar 02 2016 12:18
@Masd925 why i loose smth with concat of 2 array?
@Masd925 you mean i can return expression?
Markus Kiili
@Masd925
Mar 02 2016 12:20
@A-Alex-A I mean this:
function diff(arr1, arr2) {
  var newArr1 = arr2.filter(function(x){
     return arr1.indexOf(x) === -1;
  });
  var newArr2 = arr1.filter(function(x){
     return arr2.indexOf(x) === -1;
  });
  return newArr1.concat(newArr2);
}
A-Alex-A
@A-Alex-A
Mar 02 2016 12:20
@Masd925 thank you!
CamperBot
@camperbot
Mar 02 2016 12:20
a-alex-a sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1114 | @masd925 | http://www.freecodecamp.com/masd925
George Kiknadze
@kiknaio
Mar 02 2016 12:21
help Roman Numeral Converter
CamperBot
@camperbot
Mar 02 2016 12:21

:point_right: algorithm roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a roman numeral.
:pencil: read more about algorithm roman numeral converter on the FCC Wiki
A-Alex-A
@A-Alex-A
Mar 02 2016 12:22
is there a way to multiply string like in python "x"*3 == "xxx"? without loop:D
Markus Kiili
@Masd925
Mar 02 2016 12:23
@A-Alex-A Recursion ;)
@A-Alex-A ES6 has .repeat() method.
Omar Adulbaki Alsarbaji
@omar-sh
Mar 02 2016 12:27
Hi , can you give your opinion with this code it's about the roman numbers I coded it after I wrote the solution on the paper but now I feel my code is so stupid :/
function convert(num) {
  var x={
            1:"I",2:"II",3:"III",4:"IV",
            10:"X",20:"XX",30:"XXX",9:"IX",
            5:"V",50:"L",500:"D",
            100:"C",200:"CC",300:"CCC",
            1000:"M",2000:"MM",3000:"MMM",
            40:"XL",400:"CD",90:"XC",900:"CM"
        };
     if(x[num]){
       return x[num];
     }
  if(num===0){
    return"";
  }
   else if(num>=6 && num<=8){
     var t=num-5;
     return x[5]+x[t];
   }
 else if(num>=60 && num<=80 && num%10===0){
    r=num-50;
   return x[50]+x[r];
 }
 else if(num>=600 && num<=800 && num%10===0){
    r=num-500;
   return x[500]+x[r];
 }
  else if(num>10 && num<100){
    var w = num%10;
    w=convert(w);
    var e=Math.floor(num/10);
    var c =e%10;
    c=c*10;
    c=convert(c);
    return c+w ;
  }
  else if(num>100 && num<1000){
    w =num%10; 
  w=convert(w);
    e=Math.floor(num/10);
    c=e%10;
    c=c*10;
      c=convert(c)
    e=Math.floor(num/100);
    d=e%10;
    d=d*100;
    d=convert(d);
    return d+c+w;

  }
  else if(num>1000){
       w =num%10; 
  w=convert(w);
    e=Math.floor(num/10);
    c=e%10;
    c=c*10;
      c=convert(c)
    e=Math.floor(num/100);
    d=e%10;
    d=d*100;
    d=convert(d);
    e=Math.floor(num/1000);
    n=e%10;
    n=n*1000;
    n=convert(n);
  return n+d+c+w;
}
}


convert(68);
A-Alex-A
@A-Alex-A
Mar 02 2016 12:28
but repeat can't be used here?
Markus Kiili
@Masd925
Mar 02 2016 12:28
@A-Alex-A You can I think.
@omar-sh You can solve it on couple of lines by starting with these arrays and iterating them through NUM and checking how many times the corresponding number fits into num and generating the result on the fly:
var NUM = [1000,900,500,400,...];
var ROM = ['M', 'CM', 'D', 'CD',...];
You can use loop or reduce.
Brendan Kinahan
@BKinahan
Mar 02 2016 12:33
@A-Alex-A you can use ES6 stuff in FCC. You'll get a linter warning about esversion but you can just ignore that (or add the esversion message to make the error go away)
Omar Adulbaki Alsarbaji
@omar-sh
Mar 02 2016 12:34
@A-Alex-A , Hmmm nice , thanks , what about my code , it's not good right?!
CamperBot
@camperbot
Mar 02 2016 12:34
omar-sh sends brownie points to @a-alex-a :sparkles: :thumbsup: :sparkles:
:star: 288 | @a-alex-a | http://www.freecodecamp.com/a-alex-a
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 12:37
Ops, I had a crash in codepen and the only thing I could do was close the webpage and open it again but I am getting a previous version of my work, 1 hour ago, and I saved it 3 minutes before the crash...
Markus Kiili
@Masd925
Mar 02 2016 12:38
@A-Alex-A A bit long and hard to understand, but if it works you got something right.
Pedro Abel Díaz Sánchez
@coderHook
Mar 02 2016 12:43
Is there any way to restore a previous codepen? I lost an hour of code and I saved the data 3 minutes ago
A-Alex-A
@A-Alex-A
Mar 02 2016 12:46
function convert(num) {
 return num.toString().split("");
}
I am solving roman numbers,
if I split number, what's an easy way to convert number without writing if-else code?
Aditya Kapoor
@adityakapoor60
Mar 02 2016 12:46
Hi everyone. I'm stuck with this bit of code here in the card challenge in javascript frontend programming. I'm quite sure the logic is okay. Can't figure out what's going wrong though

var count = 0;

function cc(card) {
// Only change code below this line

switch(card)
{
case 2:
count++;
break;
case 3:
count++;
break;
case 4:
count++;
break;
case 5:
count++;
break;
case 6:
count++;
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
count --;
break;
case 'J':
count --;
break;
case 'Q':
count --;
break;
case 'K':
count --;
break;
case 'A':
count --;
break;

}

switch (count){

 case (count>0):
   return count +" "+"Bet";
 case (count<= 0):
   return count +" "+"Hold";

}

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Googled a bit. Found the bug. Thanks anyway!
Alex N.
@N0bl3
Mar 02 2016 12:51
Hi everyone
@adityakapoor60 please format your code using
```
Omar Adulbaki Alsarbaji
@omar-sh
Mar 02 2016 12:54
@Masd925 thank you I think I wrote my code in a bad way
CamperBot
@camperbot
Mar 02 2016 12:54
omar-sh sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1115 | @masd925 | http://www.freecodecamp.com/masd925
A-Alex-A
@A-Alex-A
Mar 02 2016 12:55
@Masd925 i don't get the idea of arrays for roman numbers
if i have 4553, 1000 fits 4 times, but i can't write MMMM?
Au
@aqban
Mar 02 2016 12:56
This message was deleted
iamlimo