These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Aug 2016
Joseph
@revisualize
Aug 14 2016 00:02
@k0decraft I just opened the issue.
RIles Le Roy
@iamriles
Aug 14 2016 00:02
hey can someone help me with the weather app project I don't really understand how to get navigator.geolocation.getCurrentPosition(); to return an object that reads {lat: somenumber , lon: somenumber}
Taur'e Anthony
@k0decraft
Aug 14 2016 00:02
@revisualize Awesome !
Joseph
@revisualize
Aug 14 2016 00:04
@k0decraft Thank you.
CamperBot
@camperbot
Aug 14 2016 00:04
revisualize sends brownie points to @k0decraft :sparkles: :thumbsup: :sparkles:
:cookie: 274 | @k0decraft |http://www.freecodecamp.com/k0decraft
Moisés Man
@moigithub
Aug 14 2016 00:06
@iamriles it uses a callback function...
check the documentation.. there are a example there
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation#Getting_the_current_position
Taur'e Anthony
@k0decraft
Aug 14 2016 00:08
@revisualize Yep.
Joseph
@revisualize
Aug 14 2016 00:08
I need to figure out what I should work on today. I need to finish a network diagram for the whole campus of my work. But, damn that sucks.
Taur'e Anthony
@k0decraft
Aug 14 2016 00:08
@revisualize How far along are you regarding the challenges here?
Joseph
@revisualize
Aug 14 2016 00:10
I've completed everything up to the Intermediate Algorithm Challenges and 7 of the Intermediate Challenges, minus projects. I've even worked through previous challenges to either turn them into ES6 or to optimize the code better.
Taur'e Anthony
@k0decraft
Aug 14 2016 00:10
@revisualize Nice !
amycunninghamm
@amycunninghamm
Aug 14 2016 00:12
please help, I'm on Concatenating Strings with the Plus Equals Operator and I'm not sure what I'm doing wrong??
Diego Mayer
@Chrono79
Aug 14 2016 00:12
@amycunninghamm show your code
amycunninghamm
@amycunninghamm
Aug 14 2016 00:12

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr = "This is the first sentence. ";
ourStr += "This is the second sentence.";

Diego Mayer
@Chrono79
Aug 14 2016 00:13
@amycunninghamm your var is myStr, not ourStr
amycunninghamm
@amycunninghamm
Aug 14 2016 00:13
silly mistake, thank you so much @Chrono79
CamperBot
@camperbot
Aug 14 2016 00:13
amycunninghamm sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1815 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Aug 14 2016 00:13
:+1:
ahmed abouhay
@abohay
Aug 14 2016 00:14
function truncateString(str, num) {
  var all ;
  if ( str.length > num && num > 3 ){
    all = str.slice ( 0 , num-3) + "...";
  }else {
    all = str;
  }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
any one could help
Diego Mayer
@Chrono79
Aug 14 2016 00:15
help truncate a string
CamperBot
@camperbot
Aug 14 2016 00:15

:point_right: algorithm truncate a string [wiki]

Algorithm Truncate a String

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

:checkered_flag: Problem Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add ... to the end. If it is not that long then we keep it as is.

Relevant Links

:pencil: read more about algorithm truncate a string on the FCC Wiki

Diego Mayer
@Chrono79
Aug 14 2016 00:16

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

@abohay you need to analize the case based on str.length
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:17
guys i cant understand word blanks.....its beyond me
Diego Mayer
@Chrono79
Aug 14 2016 00:17
@Naxell have you read mad libs link?
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:17
yes but its still dont get it
Diego Mayer
@Chrono79
Aug 14 2016 00:18
@Naxell you have to make a sentence using the parameters of your function plus some filler words (and spaces)
Review this challenge too: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Joseph
@revisualize
Aug 14 2016 00:19
String concatenation with variables
ahmed abouhay
@abohay
Aug 14 2016 00:19
@Chrono79 i don't know what you mean
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:19
@Chrono79 ok let me try
Diego Mayer
@Chrono79
Aug 14 2016 00:19
@abohay separate your if in a nested if
You have to do 2 different things if num <=3 or not
Joseph
@revisualize
Aug 14 2016 00:21
@Chrono79 I need to go back through that lesson and optimize the code that I wrote for it.
Lin
@linsri
Aug 14 2016 00:21
Hi guys, I am lost for Check for Palindromes. I got everything solved except for "palindrome("almostomla") should return false." I don't know why.
function palindrome(str) {
  // Good luck!
  var newStr = str.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
  for (i = 0; i < newStr.length; i++) {
     if (newStr[i] === newStr[(newStr.length - 1) - i]) {
       return true;
     } else {
       return false;
     }   
  }    
}
Diego Mayer
@Chrono79
Aug 14 2016 00:22
@linsri the problem is you're returning true at the first match, so it exits the loop (and the function)
@revisualize you can do it :+1:
Lin
@linsri
Aug 14 2016 00:23
@Chrono79 should I switch the return true and return false around?
Diego Mayer
@Chrono79
Aug 14 2016 00:23
@linsri not exactly, when can you say it's a palindrome?
Joseph
@revisualize
Aug 14 2016 00:24
@linsri Can I recommend visualizing your code execution?
Lin
@linsri
Aug 14 2016 00:24
@revisualize I don't know what is that. Can you please explain it to me?
Joseph
@revisualize
Aug 14 2016 00:24
One moment.
ahmed abouhay
@abohay
Aug 14 2016 00:25
@Chrono79
```
Diego Mayer
@Chrono79
Aug 14 2016 00:25
@linsri what do you use your loop for?
Lin
@linsri
Aug 14 2016 00:25

@Chrono79
palindrome("eye") should return a boolean.
palindrome("eye") should return true.
palindrome("_eye") should return true.
palindrome("race car") should return true.
palindrome("not a palindrome") should return false.
palindrome("A man, a plan, a canal. Panama") should return true.
palindrome("never odd or even") should return true.
palindrome("nope") should return false.
palindrome("almostomla") should return false.
palindrome("My age is 0, 0 si ega ym.") should return true.
palindrome("1 eye for of 1 eye.") should return false.
palindrome("00 (: /-\ :) 0-0") should return true.
palindrome("five|\
/|four") should return false.

everything except almostomla checked out

ahmed abouhay
@abohay
Aug 14 2016 00:25
function truncateString(str, num) {
  var all ;
  if ( str.length > num ){
    all = str.slice ( 0 , num-3) + "...";
  }else if ( num >= 3 ) {
    all = str.slice (0, num+3) +"...";
  }else{
    return str;
  }
    return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Okay, I'm going to walk my arse home.
Diego Mayer
@Chrono79
Aug 14 2016 00:26
@linsri that's because that's the only not palindrome whose first and last letters match
@abohay no, nested ifs are like this:
if(str.length>num) {
  if(num<=3) { //<= not >=
    ...
  } else {
    ...
  }
} else {
  ...
}
ahmed abouhay
@abohay
Aug 14 2016 00:31
function truncateString(str, num) {
  var all ;
  if ( str.length > num ){
   if (num <= 3){
         all = str.slice ( 0 , num-3) + "...";
   }
    else {
    all = str.slice (0, num+3) +"...";
    }
  }else {
    return str;
  }
  return all;
}

truncateString("A-tisket a-tasket A green and yellow basket", 11);
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:31
go to hell words blanks.......
ahmed abouhay
@abohay
Aug 14 2016 00:31
@Chrono79
friscodisco
@friscodisco
Aug 14 2016 00:31
@linsri you need initialize your 'i' variable like this: for (var i = 0; then it will return true
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:32
i will avoid that...
Stephen James
@sjames1958gm
Aug 14 2016 00:32
@abohay if num <= 3 slice exactly num if num > 3 slice num-3 (missing my glasses)
Diego Mayer
@Chrono79
Aug 14 2016 00:33
@sjames1958gm num-3? (I mean num >3 part)
amycunninghamm
@amycunninghamm
Aug 14 2016 00:34
hi I'm stuck on Word Blanks... I'm confused on the instruction "wordBlanks("dog", "big", "ran", "quickly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib)."
Diego Mayer
@Chrono79
Aug 14 2016 00:34
@abohay fix this: all = str.slice (0, num+3) +"...";
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:35
@amycunninghamm welcome to my world!!!
Diego Mayer
@Chrono79
Aug 14 2016 00:35
@amycunninghamm you have to create a new sentence using the function parameters and some words and spaces
For instance:
result = "Hi, my name is "+name;
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:35
@amycunninghamm i avoid that
amycunninghamm
@amycunninghamm
Aug 14 2016 00:35
but I have to get past it somehow!! @Naxell
yeah but how do i insert 'myNoun' and stuff into the sentence @Chrono79
Marc Droz
@b1tc0de
Aug 14 2016 00:36
iterating for loops odd numbers i tried this... dont work
for (var o = 1; o < 10; o %= 2) {
  myArray.push(o);
}
Yeyo Selso Poche
@Naxell
Aug 14 2016 00:36
@well when you pass... give some hits
@amycunninghamm
Marc Droz
@b1tc0de
Aug 14 2016 00:36
what is the correct way?
Diego Mayer
@Chrono79
Aug 14 2016 00:36
@b1tc0de what is %= ?
Marc Droz
@b1tc0de
Aug 14 2016 00:37
lol divisable?
Diego Mayer
@Chrono79
Aug 14 2016 00:37
you have to change o value there, try o+=2 or o=o+2
Marc Droz
@b1tc0de
Aug 14 2016 00:37
i have no idea honestly
Stephen James
@sjames1958gm
Aug 14 2016 00:38
@b1tc0de %= is remainder so the remainder of 0 divided by 2 is 0, so it will loop forever
Marc Droz
@b1tc0de
Aug 14 2016 00:39
gotcha, o+=2 worked, thanks @Chrono79 and @sjames1958gm
CamperBot
@camperbot
Aug 14 2016 00:39
b1tc0de sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1816 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 2575 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Diego Mayer
@Chrono79
Aug 14 2016 00:39
@sjames1958gm nvm, it runs
Any idea on what would %= be useful?
amycunninghamm
@amycunninghamm
Aug 14 2016 00:40
thank you @Chrono79 !
CamperBot
@camperbot
Aug 14 2016 00:40
amycunninghamm sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: amycunninghamm already gave chrono79 points
Diego Mayer
@Chrono79
Aug 14 2016 00:48
@linsri you still there? Have you solved it?
Lin
@linsri
Aug 14 2016 00:49
@Chrono79 It took me the longest time, but I just did. Thank you! I now understand that if the loop hits return it would stop looping. Thank you again.
CamperBot
@camperbot
Aug 14 2016 00:49
linsri sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1817 | @chrono79 |http://www.freecodecamp.com/chrono79
Marc Droz
@b1tc0de
Aug 14 2016 00:49
@Chrono79 x = 10 and y = 5, calculate x %= y, and display x: it will result in 0 every time...i think still don't know the name of the assignment operator
Lin
@linsri
Aug 14 2016 00:51
@friscodisco it worked without the "var". The thing I misunderstood was about the loop exiting after it hits return true. But thank you for contributing!
CamperBot
@camperbot
Aug 14 2016 00:51
linsri sends brownie points to @friscodisco :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @friscodisco |http://www.freecodecamp.com/friscodisco
Diego Mayer
@Chrono79
Aug 14 2016 00:52
@linsri anyway, put the var, it's better
llamatarianism
@llamatarianism
Aug 14 2016 00:52
@Chrono79 %= is useful for making sure something is less than something else
here's an example:
Lin
@linsri
Aug 14 2016 00:53
@revisualize Didn't really get that, but I finally figured it out. It exited the loop after returning true instead of keep going. But thank you for the contribution though. :)
CamperBot
@camperbot
Aug 14 2016 00:53
linsri sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1618 | @revisualize |http://www.freecodecamp.com/revisualize
Marc Droz
@b1tc0de
Aug 14 2016 00:53
thanks @llamatarianism for clarifying
CamperBot
@camperbot
Aug 14 2016 00:53
b1tc0de sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1169 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Aug 14 2016 00:53
def rotate(list, num_times):
    num_times %= len(list)
    while num_times:
        list = list[1:] + [list[0]]
        num_times -= 1
    return list
Lin
@linsri
Aug 14 2016 00:54
@Chrono79 oh, it's good practice to do that? Gotcha. Will fix my habit. :) Thank you again~
CamperBot
@camperbot
Aug 14 2016 00:54
linsri sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: linsri already gave chrono79 points
Marc Droz
@b1tc0de
Aug 14 2016 00:54
cool
llamatarianism
@llamatarianism
Aug 14 2016 00:54
that way
if you pass in some HUGE number
like, let's say you do rotate([1, 2, 3, 4], 1e+100)
instead of actually rotating it 1e+100 times
it won't rotate it at all
Donatas
@Lieutenant4
Aug 14 2016 00:55
hey, how to convert assignmetns fro a,b,c to the += operator?
llamatarianism
@llamatarianism
Aug 14 2016 00:56

@Lieutenant4

x = x + 1;

can be converted into

x += 1;
should be enough info
Diego Mayer
@Chrono79
Aug 14 2016 00:56
@llamatarianism thanks, I'll check that code later, dinning right now
CamperBot
@camperbot
Aug 14 2016 00:56
chrono79 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1170 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Donatas
@Lieutenant4
Aug 14 2016 00:57
says that X is not defined
llamatarianism
@llamatarianism
Aug 14 2016 00:58
well obviously you don't literally use x
but based on that info
var foo = 5;
how would I add 1 to foo?
Donatas
@Lieutenant4
Aug 14 2016 00:58
oh yea:DDD
true
@llamatarianism thanks bro
CamperBot
@camperbot
Aug 14 2016 00:59
lieutenant4 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1171 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Joseph
@revisualize
Aug 14 2016 01:10
:cookie:
:musical_note: New Order
llamatarianism
@llamatarianism
Aug 14 2016 01:12
lst = [4, 3, 2, 1]
lst.sort()
new order.
Joseph
@revisualize
Aug 14 2016 01:14
Yeah. Not the same.
@llamatarianism I listen to bands that were big hits before you were even a glimmer in someone eye.
The Cure, New Order, Tricky, Depeche Mode, Massive Attack, Portishead .... the list goes on and on.
llamatarianism
@llamatarianism
Aug 14 2016 01:17
those sure are some names
depeche sounds like a janky apache. I imagine a depeche helicopter is an apache without the rotary blade on its tail, so it uncontrollably spins and is generally useless.
Joseph
@revisualize
Aug 14 2016 01:17
Hehe
Speaking of Depeche Mode. They just came on my music box.
Nestor Figliuolo
@Makaan
Aug 14 2016 01:19
Hi guys, someone did the "No repeats please" problem?
llamatarianism
@llamatarianism
Aug 14 2016 01:20
@Makaan si
c0d0er
@c0d0er
Aug 14 2016 01:21
could anybodayexplain this: Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1. why the last index of the array is is length -1? this info is from the following code:
var arr = [10,9,8,7,6];
for (var i=0; i < arr.length; i++) {
   console.log(arr[i]);
}
Nestor Figliuolo
@Makaan
Aug 14 2016 01:23
@llamatarianism como lo planteaste?
llamatarianism
@llamatarianism
Aug 14 2016 01:23
I don't actually speak spanish :P
@xiaji1 arr[0] is 10, arr[1] is 9, arr[2] is 8, arr[3] is 7, arr[4] is 6.
arr.length - 1 == 4
c0d0er
@c0d0er
Aug 14 2016 01:25
@llamatarianism thanks
CamperBot
@camperbot
Aug 14 2016 01:25
xiaji1 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1172 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Nestor Figliuolo
@Makaan
Aug 14 2016 01:25
@llamatarianism yeah i thought so, you did it recursively or iterative?
llamatarianism
@llamatarianism
Aug 14 2016 01:25
doesn't matter too much
it's not much harder to do it one way than the other
oh wait
no repeats please?
Orhan Atesmen
@myrnin
Aug 14 2016 01:26
how do I assign "a" to be equal to "b"
llamatarianism
@llamatarianism
Aug 14 2016 01:26
sorry, I confused it for "repeat a string"
yeah, I did it recursively
Nestor Figliuolo
@Makaan
Aug 14 2016 01:26
@myrnin the literal "b" or a variable named b?
@llamatarianism ok, i'll try that, thanks
CamperBot
@camperbot
Aug 14 2016 01:27
makaan sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1173 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Orhan Atesmen
@myrnin
Aug 14 2016 01:27
@Makaan sorry, both being variables
llamatarianism
@llamatarianism
Aug 14 2016 01:27
the general outline for what I did was:
Nestor Figliuolo
@Makaan
Aug 14 2016 01:27
you want to make a copy of b in a? or a reference?
Orhan Atesmen
@myrnin
Aug 14 2016 01:28
a should have a value of 7
b should have a value of 7
a should be assigned to b with =
llamatarianism
@llamatarianism
Aug 14 2016 01:28
permutations [] = [[]]
permutations [x] = [[x]]
permutations xs =
  for x in xs:
    x + (permutations (xs with x removed))
Nestor Figliuolo
@Makaan
Aug 14 2016 01:28
a=b; then
Orhan Atesmen
@myrnin
Aug 14 2016 01:28
I assume it is not var a = b;
llamatarianism
@llamatarianism
Aug 14 2016 01:28
@myrnin you only use var for creating new variables
var x = 5;
x = 6;
Nestor Figliuolo
@Makaan
Aug 14 2016 01:29
@myrnin what said :package:
@llamatarianism i'll try that, thanks again
CamperBot
@camperbot
Aug 14 2016 01:29
makaan sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:warning: makaan already gave llamatarianism points
llamatarianism
@llamatarianism
Aug 14 2016 01:29
@Makaan to clarify: by + I actually meant cons, but I thought you might not know what cons is
cons 1 [2, 3] == [1, 2, 3]
don't literally add them, that'd be weird
Orhan Atesmen
@myrnin
Aug 14 2016 01:31
oh I was trying to assign b to a instead of a to b. Thanks guys
Eric Hartline
@wildlifehexagon
Aug 14 2016 01:31
I'm working on the Wherefore Art Thou algorithm challenge and I'm confused as to why this isn't working. I'm guessing I'm not using Object.keys correctly, but I'm not sure exactly how. Could someone help steer me in the right direction?
function whatIsInAName(collection, source) {
  return collection.filter(function(item) {
      Object.keys(source).forEach(function (key) {
          if (!item.hasOwnProperty(key) || item[key] !== source[key]) {
              return false;
          }
    });
    return true;
      });
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Nestor Figliuolo
@Makaan
Aug 14 2016 01:32
@llamatarianism you mean concatenate both, right?
@myrnin no problem
llamatarianism
@llamatarianism
Aug 14 2016 01:35
"cons" is slightly different to concatenating or prepending
concat [1] [2, 3] == [1, 2, 3]
concat 1 [2, 3] == error
cons [1] [2, 3] == [[1], 2, 3]
cons 1 [2, 3] == [1, 2, 3]
Nestor Figliuolo
@Makaan
Aug 14 2016 01:38
@llamatarianism ohhh right, i get it
llamatarianism
@llamatarianism
Aug 14 2016 01:43
@wildlifehexagon what are the arguments that forEach takes?

that is, in your code

Object.keys(source).forEach(<argument>);

what is <argument>?

ahmed abouhay
@abohay
Aug 14 2016 01:46
@Chrono79 @sjames1958gm thanks
CamperBot
@camperbot
Aug 14 2016 01:46
abohay sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1818 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 2576 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Eric Hartline
@wildlifehexagon
Aug 14 2016 01:47
@llamatarianism Admittedly I may be in over my head here. I was trying to pull the keys from each item in the object
Stephen James
@sjames1958gm
Aug 14 2016 01:48
@wildlifehexagon Return false from forEach is only going to return out of the forEach.
@wildlifehexagon so always it will return true.
Rather than forEach research array.every
llamatarianism
@llamatarianism
Aug 14 2016 01:51
@wildlifehexagon the argument to forEach is a function.
so return returns from that function
not from whatIsInAName
Eric Hartline
@wildlifehexagon
Aug 14 2016 01:54
@sjames1958gm I'll look into array.every, thanks
CamperBot
@camperbot
Aug 14 2016 01:54
wildlifehexagon sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2577 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Eric Hartline
@wildlifehexagon
Aug 14 2016 01:56
@llamatarianism Ahhh so I may have one too many functions here. Clearly I need to read up more on forEach as well. Thank you
CamperBot
@camperbot
Aug 14 2016 01:56
wildlifehexagon sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1174 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
llamatarianism
@llamatarianism
Aug 14 2016 01:57
if you're fine with using ES6 stuff
a for of loop achieves the same thing
for (let key of Object.keys(source)) {
  // this is still the same function, so `return` works fine.
}
or just use a normal (gross) for loop
var keys = Object.keys(source);
for (var i = 0; i < keys.length; i++) {
  var key = keys[i];
}
Eric Hartline
@wildlifehexagon
Aug 14 2016 01:58
@llamatarianism Interesting. I haven't dabbled much with ES6 yet but I'm intrigued. I noticed in others' examples that most were using for inbut I wanted to see if I could do it with Object.keys
llamatarianism
@llamatarianism
Aug 14 2016 01:59
I used Array.prototype.every like @sjames1958gm said
Tim
@x-yz
Aug 14 2016 02:06
what's 'gross' about a for loop?
llamatarianism
@llamatarianism
Aug 14 2016 02:07
a plain old initialisation; condition; next for loop?
it's incredibly imperative
Tim
@x-yz
Aug 14 2016 02:07
yeah
llamatarianism
@llamatarianism
Aug 14 2016 02:07
it's pretty much just a bunch of unclear boilerplate
the classic
(var i = 0; i < array.length; i++)
for loop
is really just a way to iterate through each item of an array
which is completely obfuscated by :point_up: that
JGamboa
@JGamboa81
Aug 14 2016 02:08
@rfrancisG I was having the same problem, pretty much wrote the code the same.
Does anyone have a good way to clarify what is being asked for with the switch statements? The pseudocode example is not very helpful for me.
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (answer) {
    case 1:
      console.log("alpha");
      break;  
    case 2:
      console.log("beta");
      break;
    case 3:
      console.log("gamma");
      break;
    case 4: 
      console.log("delta");
      break;
  }


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

// Change this value to test
caseInSwitch(1);
silver537
@silver537
Aug 14 2016 02:11

@x-yz

(var i = 0, j = 1, k = 2; i < array.length+j+k; i++, j++, k++)

becomes annoying

llamatarianism
@llamatarianism
Aug 14 2016 02:11
@JGamboa81 you're supposed to return that value
not log it to the console
and you're switching on answer, which you know for a fact is ""
you're supposed to switch on val
which could be anything
JGamboa
@JGamboa81
Aug 14 2016 02:12
These are the instructions:
Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"
Norvin Burrus
@ndburrus
Aug 14 2016 02:13

@JGamboa81 :sparkles:

  • answer should be replaced with the function caseInSwitch variable
  • the example code, here:
    case value1:
      statement1;  case value1:

is helping us translate the information in the table.
the left column values are the cases, while the right column values are the statements.
so, the following results from the 1st data row:

case 1: 
answer = "alpha";
JGamboa
@JGamboa81
Aug 14 2016 02:13
The way I , when 1 is passed in as the value, it should return "alpha"
@ndburrus You mean val?
Norvin Burrus
@ndburrus
Aug 14 2016 02:14
@JGamboa81 yes.
comment/s updated - see above
JGamboa
@JGamboa81
Aug 14 2016 02:14
@ndburrus Thanks, let me try
CamperBot
@camperbot
Aug 14 2016 02:14
jgamboa81 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1582 | @ndburrus |http://www.freecodecamp.com/ndburrus
Tim
@x-yz
Aug 14 2016 02:14
how would you use a for of loop to iterate through an array and how is it different than for (i = 0; i < len; i++)?
llamatarianism
@llamatarianism
Aug 14 2016 02:16
for (let x of xs) {
  dostuff
}
JGamboa
@JGamboa81
Aug 14 2016 02:16
@ndburrus Fantastic! It works!
llamatarianism
@llamatarianism
Aug 14 2016 02:16
shorter
less ugly
makes it clear that I want to iterate through the items of the array
silver537
@silver537
Aug 14 2016 02:17
it works for any type of iteration?
llamatarianism
@llamatarianism
Aug 14 2016 02:17

cuz y'know, if I did this:

for (var i = 0; i < xs.length; i++) {
  // stuff
}

that stuff could easily just be

someVar += i;

or something else. there's nothing forcing me to iterate through the items of the array with a loop like that, it just happens to be the most common use.

it also supports destructuring
Chris Hutchinson
@pablanopete
Aug 14 2016 02:17
Guys I'm stuck in the mud lol.
Chris Hutchinson
@pablanopete
Aug 14 2016 02:18
Use the .shift() function to remove the first item from myArray, assigning the "shifted off" value to removedFromMyArray.
llamatarianism
@llamatarianism
Aug 14 2016 02:18
const xs = [[0, 1], [1, 1], [1, 2], [2, 3], [3, 5]];

for (let [x, y] of xs) {
  console.log(x + y);
}
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:18
someone help me with this please
silver537
@silver537
Aug 14 2016 02:18
@hutchie25 wait for the rain. you'll be fine
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:18
i know what to do but unable to frame it
llamatarianism
@llamatarianism
Aug 14 2016 02:18
@silver537 yeah, it works with anything that has Symbol.iterator, whatever that means.
it works with anything iterable.
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:18
how can we check less than or equal with just === we need to use if along with it
llamatarianism
@llamatarianism
Aug 14 2016 02:18
<=
silver537
@silver537
Aug 14 2016 02:19
@llamatarianism so that would return, [1, 2,3,5,8]?
llamatarianism
@llamatarianism
Aug 14 2016 02:19
var x = 5;
var y = 6;
console.log(x <= y);
Norvin Burrus
@ndburrus
Aug 14 2016 02:19
@JGamboa81 nice work! :palm_tree:
llamatarianism
@llamatarianism
Aug 14 2016 02:19
@silver537 it wouldn't return anything, but it would log those values, yes
silver537
@silver537
Aug 14 2016 02:19
that's what i meant. -.-
please me with this please
silver537
@silver537
Aug 14 2016 02:20
@llamatarianism (let [x, y] of xs)
wouldnt be the best way to do it right? because what if you had [[1,2,3],[1,2]]?
Joseph
@revisualize
Aug 14 2016 02:20
@swapnildaddikar Your condition is correct.
Norvin Burrus
@ndburrus
Aug 14 2016 02:21

@swapnildaddikar we want to use the format/syntax of the example code, here:

function isEqual(a,b) {
  return a === b;
}

notice that there is no else.
also, note: "all comparison operators return a boolean true or false value."

swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:21
yes but
it returns true or false
for that i have to check condition
silver537
@silver537
Aug 14 2016 02:21
if would just log; [[3,3],3]?
Joseph
@revisualize
Aug 14 2016 02:21
@swapnildaddikar You should not use any if or else statements
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:21
yes exactly
Joseph
@revisualize
Aug 14 2016 02:21
@swapnildaddikar Look at the instructions. re-read them.
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:21
ok
Tim
@x-yz
Aug 14 2016 02:21
a === b returns either true or false
its asking you true or false is argument 1 equal to argument 2
llamatarianism
@llamatarianism
Aug 14 2016 02:22
@silver537 jagged arrays are uncommon
Joseph
@revisualize
Aug 14 2016 02:22
@x-yz NO IT ISN"T!
Tim
@x-yz
Aug 14 2016 02:22
its not?
Joseph
@revisualize
Aug 14 2016 02:22
It is not.
Shit.
llamatarianism
@llamatarianism
Aug 14 2016 02:22
a lot of people like the fact that in dynamically typed languages, you can have items of mismatched types in lists
Norvin Burrus
@ndburrus
Aug 14 2016 02:22
@swapnildaddikar comment/s updated above
llamatarianism
@llamatarianism
Aug 14 2016 02:22
but it really isn't very useful
Tim
@x-yz
Aug 14 2016 02:22
oh sorry isLess lol
i looked at norvin's code
silver537
@silver537
Aug 14 2016 02:23
@llamatarianism it would only be useful in objects. right?
Joseph
@revisualize
Aug 14 2016 02:23
As I stated. The condition is correct.
llamatarianism
@llamatarianism
Aug 14 2016 02:23
objects aren't lists
Norvin Burrus
@ndburrus
Aug 14 2016 02:24
@swapnildaddikar make sense?
silver537
@silver537
Aug 14 2016 02:24
i have a problem with reading too fast. :(
or just skimming through
i read "mismatched types" and automatically started typing. ha
llamatarianism
@llamatarianism
Aug 14 2016 02:24
another thing is that in any language with a decent type system, you'll be able to define sum types
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:25
im nt getting it hw to write it
i can understnad what that === does
:worried:
Tim
@x-yz
Aug 14 2016 02:25
you don't need the if or the else
silver537
@silver537
Aug 14 2016 02:25
so then you're saying lower level languages are more efficient.
llamatarianism
@llamatarianism
Aug 14 2016 02:26
when did I say that?
silver537
@silver537
Aug 14 2016 02:26
im assuming
llamatarianism
@llamatarianism
Aug 14 2016 02:27
I'm not talking about low level languages
most languages with sum types are pretty high level
silver537
@silver537
Aug 14 2016 02:27
what are sum types?
llamatarianism
@llamatarianism
Aug 14 2016 02:27
I'm talking about stuff like the ML family
type ('a, 'b) either =
| Left of 'a
| Right of 'b

let xs = [Left 5; Right "foo"; Left 6; Right "bar"; Right "baz"]
(* val xs : (int, string) either list *)
swapnildaddikar
@swapnildaddikar
Aug 14 2016 02:28
cool i got it thanks
llamatarianism
@llamatarianism
Aug 14 2016 02:29
either is an algebraic data type that is either 1 type or another type
in this case, either an int or a string
and you can do that with however many types
type who_even_gives_a_damn =
| Int of int
| Float of float
| String of string
| TwoIntegers of int * int
| Whatever
silver537
@silver537
Aug 14 2016 02:31
lol you seem bored with programming
llamatarianism
@llamatarianism
Aug 14 2016 02:32
nah, I was just implying that anyone who needs a sum of 4 different types, plus an extra nothing clause, probably doesn't care anymore
silver537
@silver537
Aug 14 2016 02:32
javascript doesn't have that
right?
llamatarianism
@llamatarianism
Aug 14 2016 02:32
nah, cuz JS doesn't have real types.
you can pass whatever to whatever
silver537
@silver537
Aug 14 2016 02:33
so what would be the more ideal language for software development?
llamatarianism
@llamatarianism
Aug 14 2016 02:33
idk, depends what you're doing.
silver537
@silver537
Aug 14 2016 02:33
simple automation stuff
Tim
@x-yz
Aug 14 2016 02:33
fortran
llamatarianism
@llamatarianism
Aug 14 2016 02:33
like, little scripts?
just use bash or perl or something
Norvin Burrus
@ndburrus
Aug 14 2016 02:35

@swapnildaddikar these may be helpful: :sparkles:

Operator Description
Equal ( == ) Returns true if the operands are equal.
Not equal ( != ) Returns true if the operands are not equal.
Strict equal ( === ) Returns true if the operands are equal and of the same type. See also Object.is and sameness in JS.

silver537
@silver537
Aug 14 2016 02:35
how about a DAW app?
llamatarianism
@llamatarianism
Aug 14 2016 02:35
digital audio workstation?
silver537
@silver537
Aug 14 2016 02:35
yea
llamatarianism
@llamatarianism
Aug 14 2016 02:35
no clue
silver537
@silver537
Aug 14 2016 02:35
it implements many languages i assume?
llamatarianism
@llamatarianism
Aug 14 2016 02:35
yeah you could do it in all kinds of stuff
the .NET languages are popular for making GUIs
Tim
@x-yz
Aug 14 2016 02:36
vba for all your excel macro needs
silver537
@silver537
Aug 14 2016 02:36
well for now im interested in the guts of the program
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:37
hey guys kind of stucked on a challenge now
i have no clue how to aproach this
let me send it
silver537
@silver537
Aug 14 2016 02:38
damn.. i need to know what each language is good for and what they are bad for.
like javascript is good for the web and servers, but not so good in software.
Norvin Burrus
@ndburrus
Aug 14 2016 02:38

@swapnildaddikar we need to select a different/appropriate operator! :sparkles:

how can we check less than or equal with just === we need to use if along with it

Rony Vidaur
@RonyVidaur
Aug 14 2016 02:38
first of all, how do I paste code here so it can look like on the editor?
sorry
Norvin Burrus
@ndburrus
Aug 14 2016 02:38
''' @RonyVidaur
  • using Shift + enter will give you additional line feeds (space) for pasting your code. also, the backticks (`) key is located to the left of the number one (#1) key.
  • further, you may find the two buttons (chat/compose & markdown - the chat/compose button alternates modes) to the right of the text entry area helpful.
  • you can also edit (reply, quote, edit, delete) text after it's been entered by clicking on the three (3) dots to the right of the text entry area (it will appear when you hover to the right of the time stamp). or, you can press the up arrow/key.
CamperBot
@camperbot
Aug 14 2016 02:38
:bulb: to format code use backticks! ``` more info
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:39
@ndburrus thanks man
CamperBot
@camperbot
Aug 14 2016 02:39
ronyvidaur sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1583 | @ndburrus |http://www.freecodecamp.com/ndburrus
Ken Haduch
@khaduch
Aug 14 2016 02:39
help format
CamperBot
@camperbot
Aug 14 2016 02:39

: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 thecode`.

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

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

Norvin Burrus
@ndburrus
Aug 14 2016 02:39
@RonyVidaur you're welcome! enjoy! :palm_tree:
llamatarianism
@llamatarianism
Aug 14 2016 02:39
@silver537 just PM me a language and I'll tell you what it's known for
Ken Haduch
@khaduch
Aug 14 2016 02:39
@RonyVidaur --- more info ^^^^^^^^^^^^^ here
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:40
```
oh damn lol
sorry I was testing
Norvin Burrus
@ndburrus
Aug 14 2016 02:41

@llamatarianism how about RENE? or VALGOL? :sparkles:

@silver537 just PM me a language and I'll tell you what it's known for

:)

llamatarianism
@llamatarianism
Aug 14 2016 02:41
ok:
any language I've heard of
Tim
@x-yz
Aug 14 2016 02:42
whats the best framework for web apps?
Ryan
@rmo005
Aug 14 2016 02:42
Hey all - having some trouble with the "Stand in Line" challenge
Norvin Burrus
@ndburrus
Aug 14 2016 02:42
@llamatarianism ok, what about LAIDBACK?
llamatarianism
@llamatarianism
Aug 14 2016 02:42
@x-yz there isn't one
Tim
@x-yz
Aug 14 2016 02:43
whats the most hipster?
llamatarianism
@llamatarianism
Aug 14 2016 02:43
express JS
or if we're talking about FP hipsters, yesod
@ndburrus stop suggesting esoteric languages :P
Norvin Burrus
@ndburrus
Aug 14 2016 02:43
@llamatarianism just kidding... ok. :+1:
Tim
@x-yz
Aug 14 2016 02:43
yesod is too hipster for me
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:44

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

// Only change code below this line
function updateRecords(id, prop, value) {
//from here is my own code
var element = collection[id];
if (element.hasOwnPropery(prop)){
if(prop === "tracks" && value !== null ){
//here I should be able to push the element into the right position on the JSON object
}

}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

Tim
@x-yz
Aug 14 2016 02:44
hasOwnPropery
Norvin Burrus
@ndburrus
Aug 14 2016 02:45
This message was deleted
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:45
```js
Norvin Burrus
@ndburrus
Aug 14 2016 02:45
@rmo005 code?
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:45
@ndburrus record collection
sorry for the mess above guys

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

// Only change code below this line
function updateRecords(id, prop, value) {
//from here is my own code
var element = collection[id];
if (element.hasOwnPropery(prop)){
if(prop === "tracks" && value !== null ){
//here I should be able to push the element into the right position on the JSON object
}

}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");

man
Ryan
@rmo005
Aug 14 2016 02:46
@ndburrus figured it out! Thanks for the response though
CamperBot
@camperbot
Aug 14 2016 02:46
rmo005 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1584 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Aug 14 2016 02:47
@rmo005 you're welcome! excellent job! anytime! :palm_tree:
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:47

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

// Only change code below this line
function updateRecords(id, prop, value) {
  //from here is my own code
  var element = collection[id];
    if (element.hasOwnPropery(prop)){
        if(prop === "tracks" && value !== null ){
          //here I should be able to push the element into the right position on the JSON object
        }

    }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
there it is, basically guys it would be great if you can give me advice
in how to approach the problem
Tim
@x-yz
Aug 14 2016 02:48
hasOwnPropery isn't a thing
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:48
@x-yz oh snap you're right
@ndburrus Record Collection is its name
Tim
@x-yz
Aug 14 2016 02:50
you can use bracket notation to reference a key within an object
or, reference a key within an object using a variable i should say
or assign values to it
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:53

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

// Only change code below this line
function updateRecords(id, prop, value) {
  //from here is my own code
  var element = collection[id];
    if (element.hasOwnProperty(prop)){
        if(prop === "tracks" && value !== null ){
//here I should be able to push the element into the right position on the JSON object
          id[tracks].push(value);
        }

    }

  return collection;
}

// Alter values below to test your code
updateRecords(1245, "tracks", "imatrack");
@x-yz you think Im on the right way?
Tim
@x-yz
Aug 14 2016 02:54
getting there, but where is id stored?
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:56
id comes as an argument
sorry where i use id[tracks]
Joseph
@revisualize
Aug 14 2016 02:57

@RonyVidaur If I have an object that has an element with an array with three elements.

var myObj = {
    myArr: ["a","b","c"]
 }

How do I access "b"?
How do I add "d" to the end of myArr?

Rony Vidaur
@RonyVidaur
Aug 14 2016 02:57
is actually id["tracks"]
@revisualize myArr1
sorry
myArr[ 1 ]
Joseph
@revisualize
Aug 14 2016 02:58
Incorrect.
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:58
@revisualize :O how do I? I should go back to study right
Joseph
@revisualize
Aug 14 2016 02:58
I'm asking you.
Because answering that question will show you what you're doing incorrectly.
Rony Vidaur
@RonyVidaur
Aug 14 2016 02:59
 myObj.myArr[1]
is that right?
Joseph
@revisualize
Aug 14 2016 02:59
Great! You accessed the object then the array.
Now How do I add "d" to the end of the array?
Rony Vidaur
@RonyVidaur
Aug 14 2016 03:00
``` js
Joseph
@revisualize
Aug 14 2016 03:01
@RonyVidaur After you answer that question. Can you look at your code and see what you're doing incorrectly?
Rony Vidaur
@RonyVidaur
Aug 14 2016 03:01
myObj.myArr.push(someValue);
Joseph
@revisualize
Aug 14 2016 03:01
Great.
Rony Vidaur
@RonyVidaur
Aug 14 2016 03:01
@revisualize definetly
i realize it now
man you're great
thank you @revisualize
CamperBot
@camperbot
Aug 14 2016 03:01
ronyvidaur sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1619 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 14 2016 03:01
someValue is actually supposed to be "d" but you get the idea.
Rony Vidaur
@RonyVidaur
Aug 14 2016 03:02
oh yeah "d" I forgot
for real you're the man
Omar
@Omar-Abdelaal
Aug 14 2016 03:02
I don't understand how to make the Word Blanks????
Joseph
@revisualize
Aug 14 2016 03:03
@Omar-Abdelaal It is string concatenation with variables.
Rony Vidaur
@RonyVidaur
Aug 14 2016 03:03
@revisualize It started working! I just need to add my other code for other kind of values and I'll be done
thanks a lot
Omar
@Omar-Abdelaal
Aug 14 2016 03:05
file:///C:/Users/%D9%90%D9%90%D9%90Amoon/Desktop/Untitled.png
Marc Droz
@b1tc0de
Aug 14 2016 03:08
help, challenge "Nesting for Loops", this is the best i could do thinking on my own, still no clue what i am doing...sad...
CamperBot
@camperbot
Aug 14 2016 03:08
no wiki entry for: challenge nesting for loops this is the best i could do thinking on my own still no clue what i am doingsad
Marc Droz
@b1tc0de
Aug 14 2016 03:08

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

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
returns null
the sad part is i don't know what i am doing wrong or right, this is getting difficult and i'm just starting
Joseph
@revisualize
Aug 14 2016 03:11
@b1tc0de www.pythontutor.com try to visualize your code.
Marc Droz
@b1tc0de
Aug 14 2016 03:16
im trying it out, looks good but i'm still stuck lolol
Joseph
@revisualize
Aug 14 2016 03:17
@b1tc0de I don't understand why you have three for loops.
Marc Droz
@b1tc0de
Aug 14 2016 03:18
just got it from some examples googleing
Joseph
@revisualize
Aug 14 2016 03:18
@b1tc0de You only need two for loops.
Marc Droz
@b1tc0de
Aug 14 2016 03:19
ok, testing...
Mateusz Szymański
@matszym
Aug 14 2016 03:20
@b1tc0de it doesnt return null, it returns NaN. Loks like you are trying to multiply by something else than number
Milo Hartsoe
@MiloATH
Aug 14 2016 03:20
@b1tc0de initialize i and o and u with keyword var
friesenet21
@friesenet21
Aug 14 2016 03:20
function sumPrimes(num) {
  var isPrime = [];
  for(var x= 2; x<num;x++){
    isPrime.push(x);
  }
  console.log(isPrime);
  for(var i = 2; i<=num; i++){
    if(isPrime[i]){
      for(var j = Math.pow(i,2); j<=num; Math.pow(i)+j){
        isPrime[j] = false;
      }
    }
  }
  return isPrime;
}
sumPrimes(10);
Milo Hartsoe
@MiloATH
Aug 14 2016 03:21
help sumPrimes
CamperBot
@camperbot
Aug 14 2016 03:21
no wiki entry for: sumprimes
Milo Hartsoe
@MiloATH
Aug 14 2016 03:21
help sum primes
CamperBot
@camperbot
Aug 14 2016 03:21
no wiki entry for: sum primes
friesenet21
@friesenet21
Aug 14 2016 03:21
hello
sum primes
sum all primes
Milo Hartsoe
@MiloATH
Aug 14 2016 03:22
@friesenet21 the push doesn't set the index
pushing puts the object to the next index
not a boolean at that index
isPrime doesn't return true or false. isPrime is an array
also you need to return the sum of primes, not the array
friesenet21
@friesenet21
Aug 14 2016 03:26
The returned array is not all primes either. I'm looking at this pseudocode.
Milo Hartsoe
@MiloATH
Aug 14 2016 03:27
ohh, I see what you are doing
the problem is the if(isPrime[i]) line
intially those are set to numbers
also Math.pow(i)+j doesn't really do anything to assign a var
friesenet21
@friesenet21
Aug 14 2016 03:29
and then the loops are suppose to negate non primes?
Milo Hartsoe
@MiloATH
Aug 14 2016 03:29
instead of pushing x push true/false
friesenet21
@friesenet21
Aug 14 2016 03:30
oh sorry I had j++ instead of Math.pow(i)+j
Milo Hartsoe
@MiloATH
Aug 14 2016 03:30
Also add a for loop at then end to add all the indices with a true value;
+=j
use +=j not j++
Yeyo Selso Poche
@Naxell
Aug 14 2016 03:33
uuuppf javascript no has end.....more far we go more difficult come
Milo Hartsoe
@MiloATH
Aug 14 2016 03:33
j+=j
So three things: j+=j, push(true), and a for loop at the end to get the sum
@friesenet21
rfrancisG
@rfrancisG
Aug 14 2016 03:35
Hi people I was having trouble with the "Selecting from many options with the switch statement". For some reason it doesn't like my code
switch (val){
6
case 1:
7
console.log("alpha");
8
break;
9
case 2:
10
console.log("beta");
11
break;
12
case 3:
13
console.log("gamma");
14
break;
15
case 4:
16
console.log("delta");
17
}
18
// Only change code above this line
19
return answer;
20
}
21

22
// Change this value to test
23
caseInSwitch(1);
Tony Ko
@htkoca
Aug 14 2016 03:37
there seems to be a } at line 17 and a } at line 20
somewhat hard to read, try copying inside the code box in its entirety
@rfrancisG
Milo Hartsoe
@MiloATH
Aug 14 2016 03:39
need a break for case 4
rfrancisG
@rfrancisG
Aug 14 2016 03:39
That was because the computer put it thete.
Milo Hartsoe
@MiloATH
Aug 14 2016 03:40
also you need to assign answer not log the output
answer="alpha"; ...
llamatarianism
@llamatarianism
Aug 14 2016 03:40
why is there a bunch of seemingly random numbers
Milo Hartsoe
@MiloATH
Aug 14 2016 03:40
line numbers
llamatarianism
@llamatarianism
Aug 14 2016 03:40
well they're not really random. it's 1 every 2 lines, and they're increasing by 1.
Milo Hartsoe
@MiloATH
Aug 14 2016 03:41
The person is using an online text editor
llamatarianism
@llamatarianism
Aug 14 2016 03:41
well yeah
but that doesn't explain the number insertion
@rfrancisG in what way does it "not like it"
it'd be helpful if you explained the actual issue
Milo Hartsoe
@MiloATH
Aug 14 2016 03:42
@rfrancisG you need to assign a balue to answer
*value
rfrancisG
@rfrancisG
Aug 14 2016 03:42
1 = alpha
Norvin Burrus
@ndburrus
Aug 14 2016 03:42
@rfrancisG :sparkles:
  • ok, we need to handle the table data. the values in the left table column are the cases, while the right column values are the result value (answer) assignments.
Milo Hartsoe
@MiloATH
Aug 14 2016 03:42
answer = "alpha";
rfrancisG
@rfrancisG
Aug 14 2016 03:43
2 = beta 3 = delta
Milo Hartsoe
@MiloATH
Aug 14 2016 03:43
switch (val){
case 1:
answer = 'alpha';
break;
case 2:
answer = 'beta';
...
}
@rfrancisG make sense?
Greg Brewton
@Bus42
Aug 14 2016 03:51

// 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"
};

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

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

I don't even know what to ask
doesn't work, I don't know why
no clue where to even start
slack-jawed and lost
this is great help. thanks
Milo Hartsoe
@MiloATH
Aug 14 2016 04:04
result isn't assigned @Bus42
use result = lookup[val]
Mateusz Szymański
@matszym
Aug 14 2016 04:05
@Naxell There is a point, when its no longer true. Just carry on :)
Tim
@x-yz
Aug 14 2016 04:06
oh god 'Friendly Date Range' tests your patience
friesenet21
@friesenet21
Aug 14 2016 04:06
@MiloATH I got a little farther thank you
CamperBot
@camperbot
Aug 14 2016 04:06
friesenet21 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 316 | @miloath |http://www.freecodecamp.com/miloath
friesenet21
@friesenet21
Aug 14 2016 04:07

function sumPrimes(num) {
  var isPrime = [];
  for(var x= 2; x<num;x++){
    isPrime.push(x);
  }
  for(var i = 2; i<=num; i++){
    if(isPrime[i]){
      for(var j = Math.pow(i,2); j<=num; j+=i){
        isPrime[j] = false;
      }
    }
  }
  console.log(isPrime);
  return isPrime.reduce(function(a,b){
    return a+b;
  });
}
sumPrimes(10);
Milo Hartsoe
@MiloATH
Aug 14 2016 04:07
@friesenet21 no problem, does it work?
friesenet21
@friesenet21
Aug 14 2016 04:07
I still think its line 9
Milo Hartsoe
@MiloATH
Aug 14 2016 04:08
use push(true);
not push(x)
  for(var x= 2; x<num;x++){
    isPrime.push(x);
  }
  for(var x= 2; x<num;x++){
    isPrime.push(true);
  }
friesenet21
@friesenet21
Aug 14 2016 04:10
the logged array only has booleans which returns 6 true
Milo Hartsoe
@MiloATH
Aug 14 2016 04:10
can't use the reduce function to sum
you need to sum the indexes of true vals in the array
This message was deleted
var total=0;
for(var k=0;k<isPrime.length;k++){
if(isPrime[k]){
total+=k;
}
}
return total;
friesenet21
@friesenet21
Aug 14 2016 04:13
what if the indices do not all represent prime ie true, true, true, true, false, true, false, true, false, false, false 2,3,4,5,7,9
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:19
guys
can someone help me with counting cards problem in javascript?
anyone?
please
Milo Hartsoe
@MiloATH
Aug 14 2016 04:22
@swapnildaddikar what code do you have.
?
help counting cards
CamperBot
@camperbot
Aug 14 2016 04:22

:point_right: challenge counting cards [wiki]

Challenge Counting Cards

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

:checkered_flag: Problem Explanation:

In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called card counting.

Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.

Value Cards
+1 2, 3, 4, 5, 6
0 7, 8, 9
-1 10, 'J', 'Q', 'K','A'

You will write a card counting function. It will receive a card parameter and increment or decrement the global count variable according to the card's value (see table). The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player's decision (Bet or Hold) should be separated by a single space.

Emil Aasa
@emilaasa
Aug 14 2016 04:24
@friesenet21 Are you doing the sumPrimes challenge?
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:24
someone please review my code ...im getting wrong answer buts still saying its right
Milo Hartsoe
@MiloATH
Aug 14 2016 04:26
@swapnildaddikar where is your code>
link?
friesenet21
@friesenet21
Aug 14 2016 04:26
@emilaasa yes
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:27
yes please wait @MiloATH
please check this
Milo Hartsoe
@MiloATH
Aug 14 2016 04:28
@swapnildaddikar that code works
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:28
yes
exactly
now there is a problem
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
my code just checks the 1st number in the sequence
it will return 1 Bet
for that sequence
Milo Hartsoe
@MiloATH
Aug 14 2016 04:29
No it returns 5 bet
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:29
how are u inputting it?
Emil Aasa
@emilaasa
Aug 14 2016 04:30
So you are supposed to sum all the numbers that are prime up to the provided number.
sumPrimes(10) should return 17 (2 + 3 + 5 + 7)
Tim
@x-yz
Aug 14 2016 04:30
the output of "1 Bet" is from the function call at the bottom of the code
cc(2);
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:30
OHH OMG
Tim
@x-yz
Aug 14 2016 04:30
your code works
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:30
cc(2,3,4,5,6);
Milo Hartsoe
@MiloATH
Aug 14 2016 04:30
^
swapnildaddikar
@swapnildaddikar
Aug 14 2016 04:30
i was inputting it like this
like a array with []
thanks a lot man
@thanks @x-yz
@MiloATH
thanks
Emil Aasa
@emilaasa
Aug 14 2016 04:32
@friesenet21 First you need a correct isPrime() predicate function
Milo Hartsoe
@MiloATH
Aug 14 2016 04:32
@emilaasa the code is correct as an array
@friesenet21 code you reprint the code to chat
friesenet21
@friesenet21
Aug 14 2016 04:34
This message was deleted
function sumPrimes(num) {
  var isPrime = [],
      y=0;
  for(var x= 2; x<num;x++){
    isPrime.push(true);
  }
  for(var i = 2; i<=num; i++){
    if(isPrime[i]){
      for(var j = Math.pow(i,2)+y; j<=num; j+=i){
        isPrime[j] = false;
      }
    }
  }
  console.log(isPrime);
  var total=0;
for(var k=0;k<isPrime.length;k++){
if(isPrime[k]){
total+=k;
}
}
return total;
}
sumPrimes(10);
I'm working on line 8
Milo Hartsoe
@MiloATH
Aug 14 2016 04:36
change j<=num/
to j<num
since index num doesn't exist
@friesenet21
friesenet21
@friesenet21
Aug 14 2016 04:37
ok still the same result
Milo Hartsoe
@MiloATH
Aug 14 2016 04:38
line 8 if(isPrime[i]) is correct
friesenet21
@friesenet21
Aug 14 2016 04:38
missing a few prime
4 instead of 11, 15 instead of 17 etc.
Donatas
@Lieutenant4
Aug 14 2016 04:40

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

can someone check what's wrong with this?

Milo Hartsoe
@MiloATH
Aug 14 2016 04:40
@fccbcae16c6 you need to add space between words
Donatas
@Lieutenant4
Aug 14 2016 04:41
@MiloATH lol, thanks :D
CamperBot
@camperbot
Aug 14 2016 04:41
lieutenant4 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 319 | @miloath |http://www.freecodecamp.com/miloath
Milo Hartsoe
@MiloATH
Aug 14 2016 04:41
@Lieutenant4 no problem
but was meant for someone else
fccbcae16c6
@fccbcae16c6
Aug 14 2016 04:42
@MiloATH was the way i did it not right? because i made sure to add spaces
Milo Hartsoe
@MiloATH
Aug 14 2016 04:43
you added spaces in the input not the function
Emil Aasa
@emilaasa
Aug 14 2016 04:43
@friesenet21 I had a different strategy and made a isPrime predicate function and then filtered on that + reduced
Milo Hartsoe
@MiloATH
Aug 14 2016 04:43
@emilaasa that is easier, but not as fast
both work
Emil Aasa
@emilaasa
Aug 14 2016 04:44
I wouldn't use JS to filter primes for performance :)
Milo Hartsoe
@MiloATH
Aug 14 2016 04:45
@emilaasa lol
friesenet21
@friesenet21
Aug 14 2016 04:45
@emilaasa haha
Emil Aasa
@emilaasa
Aug 14 2016 04:45
I just find multiple loops super hard to understand
I just stare at them and then my brain just... stops
fccbcae16c6
@fccbcae16c6
Aug 14 2016 04:46
@MiloATH would i use an escape sequence for that?
Emil Aasa
@emilaasa
Aug 14 2016 04:47
@MiloATH Yeah I know they are understandable, I just don't like them vs a more functional style. Personal preference! :>
friesenet21
@friesenet21
Aug 14 2016 04:48
@MiloATH ahh yes python tutor it is!
@emilaasa it is hard to say what is "good" code
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 04:49
I think the tests pass if you just add spaces
fccbcae16c6
@fccbcae16c6
Aug 14 2016 04:49
@MiloATH thank you :)
CamperBot
@camperbot
Aug 14 2016 04:49
fccbcae16c6 sends brownie points to @miloath :sparkles: :thumbsup: :sparkles:
:cookie: 320 | @miloath |http://www.freecodecamp.com/miloath
Emil Aasa
@emilaasa
Aug 14 2016 04:49
@MiloATH That's for sure! I err on the side of easy to understand and let the smart guys worry about performance :)
sometimes simple is better
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 04:52
do functional style( map, sort) is slower than loops really?
labeebahmad414
@labeebahmad414
Aug 14 2016 04:53

Hi, everyone

I thought it would be much helpful if you could tell me about which IDE you use and for what reasons.
I use Netbeans with Google Chrome as FreeCodeCamp's editor is not sufficient, it does not have watches functionality to follow how value of variable changes during execution.

So what do you use and why?

Darth Skywalker
@adityaparab
Aug 14 2016 04:54
@harindu95 : It is!
Ariel Moctezuma
@KyleMoctezuma
Aug 14 2016 04:54
having trouble with a challenge "Escape Sequences in Strings"
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 04:54
Ariel Moctezuma
@KyleMoctezuma
Aug 14 2016 04:54
is this corret var myStr = "Firstline\n\SecondLine\\rThirdLine";
friesenet21
@friesenet21
Aug 14 2016 04:54
@harindu95 there not as slow as getting multiple crashes from a loop.
Emil Aasa
@emilaasa
Aug 14 2016 04:54
@harindu95 They can be. JS arrays can have gaps in them for example, so you can't make a Array.filter function that doesn't check the indicies etc
Darth Skywalker
@adityaparab
Aug 14 2016 04:55
however, it's not that much of a big deal while you're dealing with small collections, say sets of 100s or even 1000s.
@harindu95
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 04:55
I think they can be optimized by the interpreter more than just a for loop
so they might not even have a performance penalty, not sure this is the case for javascript
Emil Aasa
@emilaasa
Aug 14 2016 04:56
They could be if they were more like a arrays in other programming languages
Darth Skywalker
@adityaparab
Aug 14 2016 04:58

@harindu95 : I had created a demo for this on repl.it.
Case that is considered is finding sum of all numbers in a range. (Say 1 to 10 which is 55)
YOu can do this by arithmetic progression. (Math formular) or using a for loop or using Array.prototype.reduce.

Take a look

https://repl.it/ClFd/10

Run this and see how significantly performance is affected. You can change value of _min and _max to adjust range.

Emil Aasa
@emilaasa
Aug 14 2016 04:59
BUT, when you are writing stuff for the web this is something I would worry about after profiling
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:00
@adityaparab that is not a bench mark per say
Darth Skywalker
@adityaparab
Aug 14 2016 05:01
@harindu95 : Does anything even exist that can be considered as a true benchmark? Everything is subjective. :)
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:01
haha yeah
still a single loop or just comparing reduce is not a bench mark
how about map? i think it's similar speed to forEach at least
Emil Aasa
@emilaasa
Aug 14 2016 05:02
@harindu95 Also pure functional programming languages can have the luxury of assuming that the functions you pass to filter etc does not have side effects. In JS you can pass a function that mutates the current array to a filter function... Which can be problematic. =)
So either you write your js engine assuming that people wont do naughty things or you have to check for these things
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:04
I don't think any language checks functions are pure or not. Except for haskell or lisp maybe
Darth Skywalker
@adityaparab
Aug 14 2016 05:05
@harindu95 : .map can use used. For sure. (So can forEach or even filter, if you really want to). However, there is a reason these functions have specific names. map is best suited for altering the contents. We don't wanna alter them. So it's a semantic decision at best. And not a logical. Logically, you can use whatever you want. :)
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:05
lol
M. Alkotob
@twirlimp
Aug 14 2016 05:05
aloha
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:05
I am not saying map is suitable for the problem you showed
but we didnt compare map or sort or filter
just reduce
:P
M. Alkotob
@twirlimp
Aug 14 2016 05:06
I don't usually ask, but this algo problem isn't checking out
Its supposed to delete elements but for some reason
Emil Aasa
@emilaasa
Aug 14 2016 05:06
@harindu95 Haha ok
M. Alkotob
@twirlimp
Aug 14 2016 05:06
it's not deleting the repeated instances
Darth Skywalker
@adityaparab
Aug 14 2016 05:07
@harindu95 : Be it map, filter or even splice. It IS going to spawn a loop internally. Functions like sort spawn multiple loops so that is where the said benchmark violates. For single loop spawining functions that call the passed in callback, I believe that wont alter the performance much.
@harindu95 : I know! Reduce sucks. I don't like it personally :P
Emil Aasa
@emilaasa
Aug 14 2016 05:07
@twirlimp Let's see some code!
M. Alkotob
@twirlimp
Aug 14 2016 05:08
Ok I'll just copy paste

function destroyer(poop) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);

var pro = Array.prototype.slice.call(argsxamarin/xamarin-android@a16673d);
var rest = args.slice(1);
console.log("pro:"+pro);
console.log("rest:"+rest + "\n");

for(var j=0; j<pro.length;j++)
  for(var i=0; i<rest.length; i++)
  if(pro[j] == rest[i])
    pro.splice(j,1);

console.log("final:"+pro);
console.log("................");
return pro;
}

That went bad
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:08
@adityaparab True , but I am saying let's say in python
M. Alkotob
@twirlimp
Aug 14 2016 05:08
How do I keep the formatting?
Emil Aasa
@emilaasa
Aug 14 2016 05:09
help formatting
CamperBot
@camperbot
Aug 14 2016 05:09

: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 thecode`.

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

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

Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:09
you can optimized functional style with c libraries
M. Alkotob
@twirlimp
Aug 14 2016 05:09

```function destroyer(poop) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);

var pro = Array.prototype.slice.call(argsxamarin/xamarin-android@a16673d);
var rest = args.slice(1);
console.log("pro:"+pro);
console.log("rest:"+rest + "\n");

for(var j=0; j<pro.length;j++)
  for(var i=0; i<rest.length; i++)
  if(pro[j] == rest[i])
    pro.splice(j,1);

console.log("final:"+pro);
console.log("................");
return pro;
}```

I'll try again
oh oops
function destroyer(poop) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);

  var pro = Array.prototype.slice.call(args[0]);
  var rest = args.slice(1);
  console.log("pro:"+pro);
  console.log("rest:"+rest + "\n");


    for(var j=0; j<pro.length;j++)
      for(var i=0; i<rest.length; i++)
      if(pro[j] == rest[i])
        pro.splice(j,1);

  console.log("final:"+pro);
  console.log("................");
  return pro;
}
ok
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
example input^
the first arg is the main array, the extra paramters are what to find and remove
I made sure the extraction is working
however in the processing, it doesn't process the repeated cases.
Darth Skywalker
@adityaparab
Aug 14 2016 05:11
@twirlimp : You have an indeterminate semantic error. Do you see it? you're .spliceing the array inside the loop. So your pro gets shorter so the indexes are bound to jumble
M. Alkotob
@twirlimp
Aug 14 2016 05:11
I see
Darth Skywalker
@adityaparab
Aug 14 2016 05:12
2nd, you wanna remove the items from main array. You're splicing pro array. So that means items are getting removed from your pro array and not main array
M. Alkotob
@twirlimp
Aug 14 2016 05:12
the pro is a copy of the main one
Darth Skywalker
@adityaparab
Aug 14 2016 05:12
Oh!
M. Alkotob
@twirlimp
Aug 14 2016 05:12
I am not really sure what's passed by instance or reference
Darth Skywalker
@adityaparab
Aug 14 2016 05:12
my bad!
M. Alkotob
@twirlimp
Aug 14 2016 05:12
so that way I make sure
Darth Skywalker
@adityaparab
Aug 14 2016 05:13
then scratch the 2nd problem
yes, but the first is still there.
M. Alkotob
@twirlimp
Aug 14 2016 05:13
ok I'll decrement I geuss
and it worked!
Darth Skywalker
@adityaparab
Aug 14 2016 05:13
No, as long as you're modifing the array inside, you're bound to run into such issues
M. Alkotob
@twirlimp
Aug 14 2016 05:13
I see
Well then I'll think of a better solution
Darth Skywalker
@adityaparab
Aug 14 2016 05:14
it is indeterminate. So that would fail at certain conditions not known now.
M. Alkotob
@twirlimp
Aug 14 2016 05:14
maybe a new array without the ones to remove
Darth Skywalker
@adityaparab
Aug 14 2016 05:14
@twirlimp : Yes, that is best
Also a hint : you don't have to run a loop to see if the element exists in the array
M. Alkotob
@twirlimp
Aug 14 2016 05:15
Yes I can do an indexOf
Darth Skywalker
@adityaparab
Aug 14 2016 05:15
you can use .indexOf(value) or .includes(value)
M. Alkotob
@twirlimp
Aug 14 2016 05:15
I was just pissed because the array filter hadn't worked
chaitanya ashtekar
@chaitanyaashtekar
Aug 14 2016 05:15
@adityaparab namaskar _/\_
M. Alkotob
@twirlimp
Aug 14 2016 05:15
there was a main loop that used a filterMaker function
Darth Skywalker
@adityaparab
Aug 14 2016 05:15
if you use .filter your code would be even shorter!
@chaitanyaashtekar : Greetings
M. Alkotob
@twirlimp
Aug 14 2016 05:16
You pass a value to the filterMaker and it returns a filter function to compare against
I thought it was the problem so I made something more intricate
or actually more simple
Darth Skywalker
@adityaparab
Aug 14 2016 05:17
@twirlimp That is fine. Whichever method you want to use. As long as you understand what you're doing
M. Alkotob
@twirlimp
Aug 14 2016 05:17
:)
Emil Aasa
@emilaasa
Aug 14 2016 05:20
@twirlimp I have a fancy filter solution in es6 if you want to see it
chaitanya ashtekar
@chaitanyaashtekar
Aug 14 2016 05:26
@emilaasa i do
Emil Aasa
@emilaasa
Aug 14 2016 05:26
'esversion:6';
function destroyer(arr) {
  let args = [...arguments].slice(1);
  return arr.filter(el => !args.includes(el));
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
M. Alkotob
@twirlimp
Aug 14 2016 05:27
that's
more compact than I imagined
XD
Darth Skywalker
@adityaparab
Aug 14 2016 05:28
I came up with it originally :P
M. Alkotob
@twirlimp
Aug 14 2016 05:28
is there a specific reason you used [...arguments] instead of arguements?
Emil Aasa
@emilaasa
Aug 14 2016 05:28
arguments is a pseudo array
M. Alkotob
@twirlimp
Aug 14 2016 05:28
what is el anyway?
Emil Aasa
@emilaasa
Aug 14 2016 05:28
It does not have the Array.prototype methods
M. Alkotob
@twirlimp
Aug 14 2016 05:29
I see
Emil Aasa
@emilaasa
Aug 14 2016 05:29
el is just what I chose to call my elements that the filter walked thru
Darth Skywalker
@adityaparab
Aug 14 2016 05:29
function destroyer(...args) {      
  return args[0].filter(n => args.slice(1).indexOf(n) === -1)
}
M. Alkotob
@twirlimp
Aug 14 2016 05:29
so I can use ...args to specify indefinite paramters?
cool
I should come for help more
I learn more than I came here for
Darth Skywalker
@adityaparab
Aug 14 2016 05:30
.includes not natively supported on IE, Edge and Android native browser unless you use some kinda polyfill So it's better to fall back to indexOfover .includes for now
Emil Aasa
@emilaasa
Aug 14 2016 05:30
True, or polyfill =)
M. Alkotob
@twirlimp
Aug 14 2016 05:30
I imagine a programmer will get fired from some job in the future
because one of their clients use outdated Edge
and he used .includes()
Darth Skywalker
@adityaparab
Aug 14 2016 05:31
Edge is very advance mate
M. Alkotob
@twirlimp
Aug 14 2016 05:31
I meant an outdated version of it
:P
waves white flag
Darth Skywalker
@adityaparab
Aug 14 2016 05:32
The most advance version of IE is called edge. there is no outdated edge as of now. It is the first time Edge is being released :P
M. Alkotob
@twirlimp
Aug 14 2016 05:32
hence "future"
coughs
Darth Skywalker
@adityaparab
Aug 14 2016 05:32
okay! white flag :P
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:33
i think edge is evergreen
Darth Skywalker
@adityaparab
Aug 14 2016 05:33
Edge is good. It's not fully ready yet
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:33
lol :D
Hop Van Vu
@HopVuVan
Aug 14 2016 05:33
Hi guys. I have an issue in course "Target a Specific Child of an Element Using jQuery".ready(function()%20%7B%0A%20%20%20%20%24(%22%23target1%22).css(%22color%22%2C%20%22red%22)%3B%0A%20%20%20%20%24(%22%23target1%22).prop(%22disabled%22%2C%20true)%3B%0A%20%20%20%20%24(%22%23target4%22).remove()%3B%0A%20%20%20%20%24(%22%23target2%22).appendTo(%22%23right-well%22)%3B%0A%20%20%20%20%24(%22%23target5%22).clone().appendTo(%22%23left-well%22)%3B%0A%20%20%20%20%24(%22%23target1%22).parent().css(%22background-color%22%2C%20%22red%22)%3B%0A%20%20%20%20%24(%22%23right-well%22).children().css(%22color%22%2C%20%22orange%22)%3B%0A%24(%22.well%3Anth-child(2)%22).addClass(%22animated%20bounce%22)%3B%0A%20%20%7D)%3B%0Afcces%0A%0A%3C!--%20Only%20change%20code%20above%20this%20line.%20--%3E%0A%0A%3Cdiv%20class%3D%22container-fluid%22%3E%0A%20%20%3Ch3%20class%3D%22text-primary%20text-center%22%3EjQuery%20Playground%3C%2Fh3%3E%0A%20%20%3Cdiv%20class%3D%22row%22%3E%0A%20%20%20%20%3Cdiv%20class%3D%22col-xs-6%22%3E%0A%20%20%20%20%20%20%3Ch4%3E%23left-well%3C%2Fh4%3E%0A%20%20%20%20%20%20%3Cdiv%20class%3D%22well%22%20id%3D%22left-well%22%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target1%22%3E%23target1%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target2%22%3E%23target2%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target3%22%3E%23target3%3C%2Fbutton%3E%0A%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3Cdiv%20class%3D%22col-xs-6%22%3E%0A%20%20%20%20%20%20%3Ch4%3E%23right-well%3C%2Fh4%3E%0A%20%20%20%20%20%20%3Cdiv%20class%3D%22well%22%20id%3D%22right-well%22%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target4%22%3E%23target4%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target5%22%3E%23target5%3C%2Fbutton%3E%0A%20%20%20%20%20%20%20%20%3Cbutton%20class%3D%22btn%20btn-default%20target%22%20id%3D%22target6%22%3E%23target6%3C%2Fbutton%3E%0A%20%20%20%20%20%20%3C%2Fdiv%3E%0A%20%20%20%20%3C%2Fdiv%3E%0A%20%20%3C%2Fdiv%3E%0A%3C%2Fdiv%3E%0A). Any one can help me?. This is my code: <script>
$(document).ready(function() {
$("#target1").css("color", "red");
$("#target1").prop("disabled", true);
$("#target4").remove();
$("#target2").appendTo("#right-well");
$("#target5").clone().appendTo("#left-well");
$("#target1").parent().css("background-color", "red");
$("#right-well").children().css("color", "orange");
$(".well:nth-child(2)").addClass("animated bounce");
});
</script>
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:33
so no outdated version
Darth Skywalker
@adityaparab
Aug 14 2016 05:33
For the first time, Microsoft has done something that works in the realm of web browsers lol
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:35
hear hear :D
DJ
@qualitymanifest
Aug 14 2016 05:35

@HopVuVan check the instructions:

Make the second child in each of your well elements bounce. You must target the children of element with the target class.

Sean104
@Sean104
Aug 14 2016 05:37
Can anyone help me with a question that i have.
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:39
@Sean104 ask it
Sean104
@Sean104
Aug 14 2016 05:40

Make Unique Objects by Passing Parameters to our Constructor
The constructor we have is great, but what if we don't always want to create the same object?

To solve this we can add parameters to our constructor. We do this like the following example:

var Car = function(wheels, seats, engines) {
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};
Now we can pass in arguments when we call our constructor.

var myCar = new Car(6, 3, 1);

This code will create an object that uses the arguments we passed in and looks like:

{
wheels: 6,
seats: 3,
engines: 1
}
Now give it a try yourself! Alter the Car constructor to use parameters to assign values to the wheels, seats, and engines properties.

Then call your new constructor with three number arguments and assign it to myCar to see it in action.

var Car = function() {
//Change this constructor
this.wheels = 4;
this.seats = 5;
this.engines = 1;
};

//Try it out here
var myCar;

Claudio Restifo
@Marmiz
Aug 14 2016 05:41
@Sean104 you may want to format that code in chat, so it's easier to read.
explain format
Sean104
@Sean104
Aug 14 2016 05:41
ok
Claudio Restifo
@Marmiz
Aug 14 2016 05:41
explain format
CamperBot
@camperbot
Aug 14 2016 05:41

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Claudio Restifo
@Marmiz
Aug 14 2016 05:41
thank you @camperbot
CamperBot
@camperbot
Aug 14 2016 05:41
marmiz sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 2201 | @camperbot |http://www.freecodecamp.com/camperbot
Claudio Restifo
@Marmiz
Aug 14 2016 05:42
@Sean104 So your code will loke like this in chat:
@Sean104
Make Unique Objects by Passing Parameters to our Constructor
The constructor we have is great, but what if we don't always want to create the same object?

To solve this we can add parameters to our constructor. We do this like the following example:

var Car = function(wheels, seats, engines) {
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};
Now we can pass in arguments when we call our constructor.


var myCar = new Car(6, 3, 1);

This code will create an object that uses the arguments we passed in and looks like:

{
  wheels: 6,
  seats: 3,
  engines: 1
}
Now give it a try yourself! Alter the Car constructor to use parameters to assign values to the wheels, seats, and engines properties.

Then call your new constructor with three number arguments and assign it to myCar to see it in action.
var Car = function() {
  //Change this constructor
  this.wheels = 4;
  this.seats = 5;
  this.engines = 1;
};

//Try it out here
var myCar;
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:42
@Sean104 you should use three parameters
basically the given example
and call with three arguments : var myCar = new Car(3,4,5) ;
I don't understand freecodecamp teaching style
most just work if you copy them in to the code lol
M. Alkotob
@twirlimp
Aug 14 2016 05:44
Ah
Well honestly that's how programmers learn irl
They copy from stackoverflow
Sean104
@Sean104
Aug 14 2016 05:44
oh i see i was having trouble with var myCar = newCar
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:45
haha but what's the point of showing it next to the problem
M. Alkotob
@twirlimp
Aug 14 2016 05:45
@harindu95 But there are also advanced things
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:45
at least they would learn to google right?
M. Alkotob
@twirlimp
Aug 14 2016 05:45
What have you tried so far?
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:45
@twirlimp guess I hvnt tried that far
M. Alkotob
@twirlimp
Aug 14 2016 05:45
Well the reason I like it
is because it guides me towards the right features to learn
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:46
until twitch project which i havnt doen yet
M. Alkotob
@twirlimp
Aug 14 2016 05:46
so I can google them yes,
Claudio Restifo
@Marmiz
Aug 14 2016 05:46
@harindu95 The real learning fase in FCC is on the challenges. There won't be any code there, just you and your ability to search for an answer
M. Alkotob
@twirlimp
Aug 14 2016 05:46
but I would also have to Google what to learn
@Marmiz yes and the algorithms are time consuming
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:46
:) lol but doesnt it look rediculous?
Claudio Restifo
@Marmiz
Aug 14 2016 05:46
@harindu95 You basically learn to "learn from yourself"
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:46
may be just remove the help section and tell campers to search the net
M. Alkotob
@twirlimp
Aug 14 2016 05:47
@harindu95 But why?
I mean if someone wants to cheat
let them cheat
this isn't high scool
Claudio Restifo
@Marmiz
Aug 14 2016 05:47
@harindu95 Not really, since programming is a constant learning job. In 2 years we all gonna have to learn something new to keep on working. Therefore we have to learn our way ourselves :D
M. Alkotob
@twirlimp
Aug 14 2016 05:47
I'd rather have the explanation and examples next to me
The point is not memorization imo
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:47
It's not abt cheating. If anyone wants to learn , they can't since
1
  1. there is not enough material
M. Alkotob
@twirlimp
Aug 14 2016 05:48
Oh I see
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:48
2.it's still in short term memory to pass the test
Sean104
@Sean104
Aug 14 2016 05:48
thanks for the help
M. Alkotob
@twirlimp
Aug 14 2016 05:48
Well the short term memory part I am not sure about
Since there are later longer challenges
So it's natural the intros are simple
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:48
@Sean104 it's nothing
Chris Cullen
@123xylem
Aug 14 2016 05:48
function pairwise(arr, arg) {
return  arr.reduce(function(acc, item,ind){

  {if (item+acc<arg){ //if curr val +prev vals < arg then ...
  acc+=ind;//add these correct index values to the acc
 return acc;}}});//returns value of indexes accumulated


}

pairwise([1,4,2,3,0,5], 7);
Hi, Im trying to return the index vals of the values that add up to arg only.. But it returns undefined... Any idea what im doing wrong? I watched some reduce tutorials but Im struggling to apply it creatively!
Claudio Restifo
@Marmiz
Aug 14 2016 05:49
@harindu95 Well, if you think you have a better method/ solution; there's a suggestion area in the forum :)
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 05:50
@Marmiz what about just showing whole section about subject( eg:- jquery) then give challenges
I hv heard freecodecamp used videos but many dislike it. wonder why :P
@123xylem you don't have to enclose if in brackets
Chris Cullen
@123xylem
Aug 14 2016 05:55
@harindu95 well the function needs brackets
@harindu95 o right double brackets
still doesnt change it
Hop Van Vu
@HopVuVan
Aug 14 2016 05:57
@qualitymanifest Thanks guy. issue resolved :)
CamperBot
@camperbot
Aug 14 2016 05:57
hopvuvan sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1350 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Aug 14 2016 05:58
@HopVuVan cool :+1:
gitgenie
@gitgenie
Aug 14 2016 06:00
hi guys, here is my code for "no repeats please" challenge . I dont know why its failing for few conditions. Can someone please tell me why?

```function permAlone(str) {
var arr = str.split(''), permutations = [], uniqueArray =[], re = /(.)\1+/g;
function getPerm(arr,n){
var localArr = arr.slice(0);
var i;
var swap;
var temp;
if(n==1){
permutations.push(localArr.join(""));
return;
}
for(i=0;i<n;i++){
getPerm(localArr,n-1);
swap = (n%2 ? i: 0);
temp = localArr[swap];
localArr[swap] = localArr[n-1];
localArr[n-1] = temp;
}
}
getPerm(arr,arr.length);

uniqueArray = permutations.filter(function(item){return !item.match(re); });

return uniqueArray .length;

}

permAlone('aabb');```

Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:04
@123xylem when the code doesn't enter into if in reduce, it returns an undefined as the prev to next iteration
0 1 0
1 4 1
5 2 2
undefined 3 3
undefined 0 4
undefined 5 5
undefined
=> undefined
Chris Cullen
@123xylem
Aug 14 2016 06:07
@harindu95 ah so it is doing its job but it keeps going until it has seen it all and at that point the if is wrong (so undefined)?
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:07
prev | current | index
0 1 0
1 4 1
5 2 2
undefined 3 3
undefined 0 4
undefined 5 5
undefined
=> undefined
:) the program doesn't enter if(prev+curr<arg)
coz it doesnt have a else cause it returns undefined
@123xylem
Chris Cullen
@123xylem
Aug 14 2016 06:09
ok i see
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:10
xD
Chris Cullen
@123xylem
Aug 14 2016 06:10
so I need a way of stopping the loop before it returns undefined?
function pairwise(arr, arg) {
return  arr.reduce(function(acc, item,ind){

 if (item+acc<arg){ //if curr val +prev vals < arg then ...
  acc+=ind;//add these correct index values to the acc
 return acc+=ind;}//returns value of indexes accumulated

 else return "oops";});


}

pairwise([1,4,2,3,0,5], 7);
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:10
@123xylem btw it isn't a loop so it must return something
Chris Cullen
@123xylem
Aug 14 2016 06:10
now it returns oops
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:10
otherwise yeah
xD
return should return the element for the output array
silver537
@silver537
Aug 14 2016 06:11
WHAT?!? did i just read there isnt enough material?!?!? And that people learn from copying other people's work?? Wtf is this.
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:11
haha ^-^
@silver537 are you telling me there is enough material? :P
silver537
@silver537
Aug 14 2016 06:13
Theres MORE than enough. Wtf kind of fucked up world you livin on?
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:14
lol I don't think you understand what i am saying
do you ?
lol everyone else didnt disagree on that
silver537
@silver537
Aug 14 2016 06:14
Well your world proves theres not enough material. How limited are your resources? ??
Harindu Dilshan ( Kavinda Pitiduwa Gamage)
@harindu95
Aug 14 2016 06:17
I am saying the material on the freecodecamp is limited
not on the web
edison sim
@Edisonsim
Aug 14 2016 06:17
how do you write a function that use push?
function simplePush(arr, 3) { }
silver537
@silver537
Aug 14 2016 06:18
Wiki stand in line
CamperBot
@camperbot
Aug 14 2016 06:18

:point_right: challenge stand in line [wiki]

Challenge Stand In Line

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

:checkered_flag: Problem Explanation:

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

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

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

Relevant Links

silver537
@silver537
Aug 14 2016 06:18
.theres your resource
edison sim
@Edisonsim
Aug 14 2016 06:20
write a function simplePush that takes in two arguments. The first argument will be an array. The second will either be a string or number. The function should PUSH the second argument into the first argument. Then return the first argument (which should now have the second argument PUSHed into it)
but not sure how to write it
Markus Kiili
@Masd925
Aug 14 2016 06:20
@Edisonsim Function declaration should have parameters (not values), like function myFunction(arr,item){arr.push(item);}
@Edisonsim Function call has arguments (values), like myFunction([1],2);
silver537
@silver537
Aug 14 2016 06:23
Just put this code. return arr.push (item)
edison sim
@Edisonsim
Aug 14 2016 06:25
Hmm okay giving it a try coz im using atom and jasmine to do the test for some assignment which not sure how lol
Chris Cullen
@123xylem
Aug 14 2016 06:25
for(j=)0;j<arr.length;j++){
    if(arr[j]+arr[j](PREVIOUS J VALUE??)< 10){
        console.log (BOTH ARRJ VALUES);
    }
How do i say if first val of j + second val of j<10 then show the values?
edison sim
@Edisonsim
Aug 14 2016 06:31

function simplePush( 1, 2) {
if (simplePush.push(1,2))
return simplePush.push (1,2)

};
doesnt work

silver537
@silver537
Aug 14 2016 06:32
wth is this? (j=)0;
Sorin Ruse
@sorinr
Aug 14 2016 06:33
@123xylem try arr[j]+arr[j-1]
Chris Cullen
@123xylem
Aug 14 2016 06:34
@sorinr ok what does j-1 mean? I used a count var but I like your idea better
r2d2
@UsamaHameed
Aug 14 2016 06:34

@123xylem

for(j=1;j<arr.length;j++){
    if(arr[j - 1]+arr[j]< 10){
        console.log (BOTH ARRJ VALUES);
    }

Do something like this

Sorin Ruse
@sorinr
Aug 14 2016 06:35
@123xylem PREVIOUS J VALUE
Chris Cullen
@123xylem
Aug 14 2016 06:35
@sorinr thanks!
CamperBot
@camperbot
Aug 14 2016 06:35
123xylem sends brownie points to @sorinr :sparkles: :thumbsup: :sparkles:
:cookie: 658 | @sorinr |http://www.freecodecamp.com/sorinr
r2d2
@UsamaHameed
Aug 14 2016 06:35
@123xylem important that you start j from 1
Chris Cullen
@123xylem
Aug 14 2016 06:35
@UsamaHameed u can literally write both?
r2d2
@UsamaHameed
Aug 14 2016 06:36
What do you mean?
edison sim
@Edisonsim
Aug 14 2016 06:36
write a function simplePush that takes in two arguments. The first argument will be an array. The second will either be a string or number. The function should PUSH the second argument into the first argument. Then return the first argument (which should now have the second argument PUSHed into it) function simplePush( 1, 2) {
if (simplePush.push(1,2))
return simplePush.push (1,2)
};
but doesnt seem to work
Chris Cullen
@123xylem
Aug 14 2016 06:36
is the term BOTH a real thing??? ..................and u start from 1 so first j-1 exists i guess...
@UsamaHameed
Faaiz
@goprime10
Aug 14 2016 06:36
Hello everyone!!!
edison sim
@Edisonsim
Aug 14 2016 06:37
do i need to declare var?
r2d2
@UsamaHameed
Aug 14 2016 06:37
@123xylem NO. You edit the console.log yourself. I didn't see it :P
@123xylem Yes that is right. Start from 1
silver537
@silver537
Aug 14 2016 06:37
@Edisonsim copy and paste this:
function simplePush(arr, item){
  return arr.push(item);
}
r2d2
@UsamaHameed
Aug 14 2016 06:38
You can write console.log("The sum of " + arr[j - 1] + " and " + arr[j] + " is less than 10.") @123xylem
edison sim
@Edisonsim
Aug 14 2016 06:40
@silver537 doesnt work still
Screen Shot 2016-08-14 at 2.40.01 PM.png
Chris Cullen
@123xylem
Aug 14 2016 06:43
@UsamaHameed gotya thanls
thanks @UsamaHameed
CamperBot
@camperbot
Aug 14 2016 06:43
123xylem sends brownie points to @usamahameed :sparkles: :thumbsup: :sparkles:
:cookie: 463 | @usamahameed |http://www.freecodecamp.com/usamahameed
r2d2
@UsamaHameed
Aug 14 2016 06:44
:+1:
silver537
@silver537
Aug 14 2016 06:45
@Edisonsim
function simplePush(arr, item){
  arr.push(item)
  return arr;
}
edison sim
@Edisonsim
Aug 14 2016 06:45
@silver537 thanks finally
CamperBot
@camperbot
Aug 14 2016 06:45
edisonsim sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 489 | @silver537 |http://www.freecodecamp.com/silver537
Olly Sholotan
@Ollysho
Aug 14 2016 06:51
Hey guys I have a bit of a question not particularly FCC related
I'm learning the react framework and in it they use this bit of code
var newMood = this.state.mood == 'good' ? 'bad' : 'good';
Does anyone know what that's called/if it's just a react thing?
arif hussain
@arifhussain0
Aug 14 2016 06:52
hello
need help with confirm the ending exercise
r2d2
@UsamaHameed
Aug 14 2016 06:52
@Ollysho that is the ternary operator. Read about it
arif hussain
@arifhussain0
Aug 14 2016 06:52
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
var count=target.legth-1;
for (var i=str.length-1;i>str.length-target.length-1;i--)
{
if(str[i]!==target[count])
{
return false;
}
count--;
}
return true;
}
Markus Kiili
@Masd925
Aug 14 2016 06:52
@Ollysho ? is the ternary operator.
arif hussain
@arifhussain0
Aug 14 2016 06:52
this is the code
but it never returns true
Olly Sholotan
@Ollysho
Aug 14 2016 06:53
Ternary! Thanks guys :D
arif hussain
@arifhussain0
Aug 14 2016 06:53
where am i going wrong
Olly Sholotan
@Ollysho
Aug 14 2016 06:53
@Masd925 and @UsamaHameed thanks!
CamperBot
@camperbot
Aug 14 2016 06:53
ollysho sends brownie points to @masd925 and @usamahameed :sparkles: :thumbsup: :sparkles:
:cookie: 464 | @usamahameed |http://www.freecodecamp.com/usamahameed
:star2: 2293 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 14 2016 06:53
@Masd925 ? and : is the ternary operator
arif hussain
@arifhussain0
Aug 14 2016 06:53
but it never returns true
r2d2
@UsamaHameed
Aug 14 2016 06:53
I feel so small
var count=target.legth-1; typo here @arifhussain0
Markus Kiili
@Masd925
Aug 14 2016 06:55
@silver537 Yes.
Chris Cullen
@123xylem
Aug 14 2016 06:56
var random=[];
var count= 0;
for(j=0;j<arr.length;j++){

if(arr[j]+count<=arg){
    random.push(j);
        count+=arr[j];
        console.log (arr[j],count,random);
    }

    else {count=0;
    arr[j]= (last arr[j] before last if failed)//THIS BIT ANY IDEAS? Or is it even possible?
    count+=arr[j];
}
}
How do i make my else take off from thwere the first if failed?
arif hussain
@arifhussain0
Aug 14 2016 06:56
oh! so stupid of me :P
edison sim
@Edisonsim
Aug 14 2016 06:56
write a function findElem that takes in two arguments. The first argument is will be an array. The second argument will be an integer. The function should then return the element that corresponds to the second argument. For example, if first argument is ['a','b','c'] and second argument is 2, findElem should return 'b'.
not really understand wat this say
silver537
@silver537
Aug 14 2016 06:58
intermundos
@intermundos
Aug 14 2016 06:58
@Edisonsim you should find element of the given array at a specified position
edison sim
@Edisonsim
Aug 14 2016 06:59
@silver537 @intermundos thanks
CamperBot
@camperbot
Aug 14 2016 06:59
edisonsim sends brownie points to @silver537 and @intermundos :sparkles: :thumbsup: :sparkles:
:cookie: 3 | @intermundos |http://www.freecodecamp.com/intermundos
:warning: edisonsim already gave silver537 points
edison sim
@Edisonsim
Aug 14 2016 07:00
im not really good at javascript when come to read wat it say
silver537
@silver537
Aug 14 2016 07:00
maybe translating it?
edison sim
@Edisonsim
Aug 14 2016 07:01
haha it not about the english as in im not sure wat to write it
write the function*
silver537
@silver537
Aug 14 2016 07:01
you're gonna have to go back to the basics.
llamatarianism
@llamatarianism
Aug 14 2016 07:07
@Edisonsim
findElem(['a', 'b', 'c'], 2) === 'b'
['a', 'b', 'c'][1] === 'b'
['a', 'b', 'c'][2] === 'c'
intermundos
@intermundos
Aug 14 2016 07:10
@Edisonsim patience and practice my friend. And lots of reading.
edison sim
@Edisonsim
Aug 14 2016 07:15
wat javascript book good to read? @intermundos ?
@llamatarianism thanks but im not using it just taking it as a note and understand it
CamperBot
@camperbot
Aug 14 2016 07:16
edisonsim sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1175 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:18
guys

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

// Only change code below this line
function updateRecords(id, prop, value) {
 //just for the tracks and works
  if(prop === "tracks" && value !== ""){
     collection[id][prop].push(value);
    //DONE 
  }
  //HERE im supposed to create the prop on the array and then add the value
  else if(prop === "tracks" && value !== "" && collection[id].hasOwnProperty === false ) { 

    collection[id].push(prop);
    collection[id][prop] = value;
  }
  else {
    delete collection[id][prop];
  }
  //working with artist 
  if(prop === "artist" && value !== ""){
    collection[id][prop] = value;
  }else if (prop === "artist" && value === "" ) {
    delete collection[id][prop];
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5430, "tracks", "Take a chance on Me");
almost everything is working on the Record Collection challenge
the only thing that doesnt works is when you try to add a track to the object
silver537
@silver537
Aug 14 2016 07:21
Youre pushing into a nonexistent array....
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:22
why? @silver537
silver537
@silver537
Aug 14 2016 07:23
.hasownproperty is not evaluating anything either.
Seems like you went too fast on this one.
0.0
In other words your first if is broken.
Second if is also broken
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:25
@silver537 yeah? but the first one works tho, can you give me a clue about what am I doing wrong?
silver537
@silver537
Aug 14 2016 07:26
The first one pushes into a nonexistent property. You have to declare the array property first before pushing.
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:27
id is just the name of the argument that Im giving to the function, its value is for example 2548
silver537
@silver537
Aug 14 2016 07:27
Look at object id 5439. Theres no tracks property. None of your if conditions checks if the tracks property exists. Nor does any of them create one if the tracks prop doesnt exist.
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:28
yeah that is exactly the issue
so I thought I could
access the object by doing collection[id].hasOwnProperty("tracks")
silver537
@silver537
Aug 14 2016 07:29
Bingo.
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:29
to check if the property exist
silver537
@silver537
Aug 14 2016 07:30
Now if it returns false, create an empty tracks array.
Should be the first thing to evaluate.
Rony Vidaur
@RonyVidaur
Aug 14 2016 07:30
oh I see let me try it real quick
@silver537 oh and I see now what you were saying about hasownproperty, i didnt give it any arguments