These are chat archives for FreeCodeCamp/HelpJavaScript

8th
Aug 2016
Alexios Pantavos
@AlexiosP
Aug 08 2016 00:01
@kirahmadlare > hi there, how can I access the multiple array? for example [[1,2,34],2,[3,3]] How can I access them all or transfer them in one array?
Nested for loops:
var array = [[1,2,34],2,[3,3]];
for(var i=0; i<array.length; i++) {
for(var j=0; j<array[i].length; j++) {
// array[i][j]
}
}
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:02
@AlexiosP thanks I thought there;s another way for it.
CamperBot
@camperbot
Aug 08 2016 00:02
kirahmadlare sends brownie points to @alexiosp :sparkles: :thumbsup: :sparkles:
:cookie: 318 | @alexiosp |http://www.freecodecamp.com/alexiosp
nmaca
@nmaca
Aug 08 2016 00:03
Im having trouble with title case a sentence
This message was deleted
My code so far:

function titleCase(str) {
var strSplit = str.toLowerCase().split(" ");
for (i = 0; i<str.length; i++) {

return strSplit[i].join(" ");
}

}

titleCase("I'm a little tea pot");

i know how to split up the initial string, but i can't figure out how to deal with the strings in the arrays
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:05
@revisualize Oh, I never figured out that 4x and 9x should be put to tables too. I made an if-else hassle.
@revisualize How about two arrays? Integer values and roman numerals. No need for that const keys then.
Christian
@Neralizer
Aug 08 2016 00:13
```

function palindrome(str) {
  str.replace(/!@#$%^&*/ , ''); //Replacing non-alphanumeric characters
  str.toLowerCase(); //Changing all characters to lower case

  //Reverse String Algorithm
  var array = str.split("");
  array.reverse();
  var newstr = array.join("");

  //If newstr is equal to str, return true
  if (newstr = str) {
    return true;
  }
  return false;
}



palindrome("eye");
working on checking for palindromes, but getting errors when trying to check if str is equal to palindrome str, or newstr
why can't I check to see if one variable is equal to another? is there a separate operator for that?
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:16
@Neralizer try to use regex
Christian
@Neralizer
Aug 08 2016 00:17
a regular expression?
specify for me, in place of a variable?
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:19
@Neralizer what i did to solve the problem is to remove all the spaces and check if the EYE = REVERSE of EYE
Christian
@Neralizer
Aug 08 2016 00:19
right, isn't that what I have?
str is eye, newstr is reverse of eye
Tim
@x-yz
Aug 08 2016 00:20
function diffArray(arr1, arr2) { var newArr1 = arr1.filter(function(val) { return arr2.indexOf(val) == -1 ? true : false; }); var newArr2 = arr2.filter(function(val) { return arr1.indexOf(val) == -1 ? true : false; }); return newArr1.concat(newArr2); }
c0d0er
@c0d0er
Aug 08 2016 00:20
Hi, could anybody help to answer me this question: is "x+=y" 100% equal to "x=x+y"?
Tim
@x-yz
Aug 08 2016 00:21
i cant markdown
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:21
@Neralizer ccheck the condition it should be if(newstr == str)
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:22
@christian Change to split(" ")
Christian
@Neralizer
Aug 08 2016 00:22
well the == got rid of the error message
Tim
@x-yz
Aug 08 2016 00:23
function diffArray(arr1, arr2) { var newArr1 = arr1.filter(function(val) { return arr2.indexOf(val) == -1 ? true : false; }); var newArr2 = arr2.filter(function(val) { return arr1.indexOf(val) == -1 ? true : false; }); return newArr1.concat(newArr2); }
argh
Spencer Arias
@slarias
Aug 08 2016 00:24
has anyone done the Comparison with the Greater Than Operator
It doesn't seem to work
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:24
@christian Oh it was ==. I should go to sleep.
Cage Echarte
@CageEcharte
Aug 08 2016 00:24
how do I assign a to b ?var a = 7;
var b = 7;
Christian
@Neralizer
Aug 08 2016 00:25
but still having issues
Christian
@Neralizer
Aug 08 2016 00:25

function palindrome(str) {
  str.replace(/!@#$%^&*_ / , ''); //Replacing non-alphanumeric characters
  str.toLowerCase(); //Changing all characters to lower case

  //Reverse String Algorithm
  var array = str.split("");
  array.reverse();
  var newstr = array.join("");

  //If newstr is equal to str, return true
  if (str == newstr) {
    return true;
  }
  return false;
}



palindrome("eye");
Joseph
@revisualize
Aug 08 2016 00:25
@CageEcharte What do the instructions state?
Christian
@Neralizer
Aug 08 2016 00:26
is something wrong with my replace method?
Cage Echarte
@CageEcharte
Aug 08 2016 00:26

@revisualize
Assign the value 7 to variable a.

Assign the contents of a to variable b.

Run tests (ctrl + enter)

Joseph
@revisualize
Aug 08 2016 00:26
a should be assigned to b with =
Side example: "Joseph" should be assigned to the variable name with =
var name = "Joseph";
Of course that example is done without name being initialized prior to the assignment.
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:26
@Neralizer some weirdness in replace...Why does the string look commented out
Christian
@Neralizer
Aug 08 2016 00:27
I think because the # is in there
and that's another way to comment, I think
but I erased it and am still having issues
Tim
@x-yz
Aug 08 2016 00:27
the problems with your regex i think @Neralizer
Cage Echarte
@CageEcharte
Aug 08 2016 00:27
@revisualize can you write the code for me ?
Joseph
@revisualize
Aug 08 2016 00:27
@CageEcharte No. Can you write the code for yourself?
Christian
@Neralizer
Aug 08 2016 00:28
is regex regular expression?
Tim
@x-yz
Aug 08 2016 00:28
yes
str.replace(/!@#$%^&*_ / , '');
Joseph
@revisualize
Aug 08 2016 00:28
@CageEcharte I gave you an extra example.
Cage Echarte
@CageEcharte
Aug 08 2016 00:28
@revisualize I would if I knew how to write it correctly
Greg Duncan
@GregatGit
Aug 08 2016 00:29

@Neralizer just take your code to https://repl.it/ - paste in

var str = "here!";
str = str.replace(/!@$%^&*_ / , ''); //Replacing non-alphanumeric characters

and play around with it till it works

Joseph
@revisualize
Aug 08 2016 00:29
@CageEcharte
How do you assign the value 7 to a variable num?
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:30
@GregatGit But isn't that missing a bunch of non-alphanum characters?
Christian
@Neralizer
Aug 08 2016 00:30
the slashes on the replace method contain all the characters being replaced, yeah?
Joseph
@revisualize
Aug 08 2016 00:31
@Neralizer Instead of removing all the non-alphanumeric characters. Why don't you keep the alphanumeric characters?
Greg Duncan
@GregatGit
Aug 08 2016 00:31
@BenjamWondafrash easily added
@Neralizer yes
Cage Echarte
@CageEcharte
Aug 08 2016 00:31
@revisualize idk var b = 7; ?
mingmingrr
@mingmingrr
Aug 08 2016 00:31
@BenjamWondafrash @GregatGit /\W/g works just as well
Joseph
@revisualize
Aug 08 2016 00:31
@CageEcharte num ?
@CageEcharte if you replace b with num. That does answer the question that I asked.
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:32
@mingmingrr Awww. Help him to find it himself. Don't just paste finished code.
Joseph
@revisualize
Aug 08 2016 00:33
@CageEcharte
How do you assign the value 7 to the variable num?
your answer: var num = 7; (corrected of course.)
How do you assign the value of a to the variable b?
mingmingrr
@mingmingrr
Aug 08 2016 00:33
@BenjamWondafrash cant really expect anyone to know all the meta sequences though
Christian
@Neralizer
Aug 08 2016 00:33
I'm going to mess around with the code for a bit, I'll come back to the chat. thanks for your help
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:34
@mingmingrr Guide him to regexp and tell him to look for alphanumeric and so on...
Joseph
@revisualize
Aug 08 2016 00:35

@CageEcharte
How do you assign the value 7 to the variable num?
your answer: var num = 7; (corrected of course.)
How do you assign the value of a to the variable b?

b = a;

Tim
@x-yz
Aug 08 2016 00:36
function diffArray(arr1, arr2) {
  var newArr1 = arr1.filter(function(val) {
    return arr2.indexOf(val) == -1 ? true : false;
  });
  var newArr2 = arr2.filter(function(val) {
    return arr1.indexOf(val) == -1 ? true : false;
  });
  return newArr1.concat(newArr2);
}
that works but doesnt use array.slice, which is in the helpful links... is there a better way w/ slice?
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:36
@mingmingrr In the task we were expected to learn one metachar. One. Not all of them.
Nick Irvine
@irvin3
Aug 08 2016 00:37
not sure if @TylerMoeller is still in here but if not would someone mind taking a look at my pomodoro clock code? I'm having an issue with
```
var sessionTime = $("#seshTime").text();
storing the value that is previously set in my code
Cage Echarte
@CageEcharte
Aug 08 2016 00:37
@revisualize thanks.. what do I do when it says... "Do not change code above the line?"
CamperBot
@camperbot
Aug 08 2016 00:37
cageecharte sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1573 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Aug 08 2016 00:38
@CageEcharte You don't change the code above that line.
// Code above the line.
// the line ------------------------- 
// Code below the line.
"Do not change code above the line."
Ergo, you can change code below the line.
Christian
@Neralizer
Aug 08 2016 00:42
still lost
function palindrome(str) {
  str = str.replace(/!@#$%^&*_/g , ""); //Replacing non-alphanumeric characters
  str = str.toLowerCase(); //Changing all characters to lower case

  //Reverse String Algorithm
  var array = bstr.split("");
  array.reverse();
  var newstr = array.join("");

  //If newstr is equal to str, return true
  if (str == newstr) {
    return true;
  }
  return false;
}



palindrome("eye");
I have no idea why my replace method is not working
it looks like every other replace method I have seen on three separate pages
Joseph
@revisualize
Aug 08 2016 00:42
@Neralizer what is bstr?
greg
@wearenotgroot
Aug 08 2016 00:42
@Neralizer shouldnt you use ---->str.split ?
Greg Duncan
@GregatGit
Aug 08 2016 00:43
@Neralizer you have a typo var array = bstr.split("");
Christian
@Neralizer
Aug 08 2016 00:43
sorry, forget bstr
Moisés Man
@moigithub
Aug 08 2016 00:43
* ^and $ are a special char on regex need to be escaped if u wanna it to be treaten as regular chars @Neralizer
Christian
@Neralizer
Aug 08 2016 00:43
that doesnt change anything
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:43
@Neralizer Google for a shorthand for alphanumeric characters in regexp
Greg Duncan
@GregatGit
Aug 08 2016 00:43
@irvin3 you have to disable the start button some how once it is pressed -
Moisés Man
@moigithub
Aug 08 2016 00:44
also..u making a sequence of chars.. if u have /abc/ means.. a followed by b foillowed by c literally @Neralizer
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:44
hi, i can't figure out how to access record like this:
arr([1, 2, 3, 1, 2], 3, 2, 3); the first value is array, how can I make them as one
Greg Duncan
@GregatGit
Aug 08 2016 00:44
@irvin3 something as simple as hide()
greg
@wearenotgroot
Aug 08 2016 00:44
@Neralizer you can chain method calle btw
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:45
@Neralizer But u want to replace ALL BUT alphanum. So we need to make it the opposite with a simple change...
Moisés Man
@moigithub
Aug 08 2016 00:45
@Neralizer if u wanna replace ANY of those chars on that list.. u need []
like /[abc]/g that mean.. a or b or c
Nick Irvine
@irvin3
Aug 08 2016 00:46
@GregatGit yea I still need to do that, but that isn't the immediate issue i dont think. If you change the session length with the buttons, the timer itself always resets to 25. probably because I set that earlier in the code but I thought the button were updating the value
Christian
@Neralizer
Aug 08 2016 00:46
@BenjamWondafrash if I swapped the sides of the replace method, wouldn't that replace all spaces with those alphanumeric characters?
Cage Echarte
@CageEcharte
Aug 08 2016 00:47
@revisualize thanks it's been a long day. lol
CamperBot
@camperbot
Aug 08 2016 00:47
cageecharte sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:warning: cageecharte already gave revisualize points
Christian
@Neralizer
Aug 08 2016 00:47
we haven't used this replace method before, right?
in a previous challenge or something?
Greg Duncan
@GregatGit
Aug 08 2016 00:48
@irvin3 don't get the sessionTime from the html but other way around
greg
@wearenotgroot
Aug 08 2016 00:48
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:48
@Neralizer Yes. I think replace was introduced here for a first time.
King Mhar Bayato
@kirahmadlare
Aug 08 2016 00:49
hi, i can't figure out how to access record like this:
arr([1, 2, 3, 1, 2], 3, 2, 3); the first value is array, how can I make them as one
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:49
@Neralizer Did u find rhe
Moisés Man
@moigithub
Aug 08 2016 00:49
Stephen James
@sjames1958gm
Aug 08 2016 00:49
@kirahmadlare Research the arguments object
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:50
@Neralizer Did u find the metacharactee for all alphanumeric characters?
Christian
@Neralizer
Aug 08 2016 00:50
what I'm getting from these pages is that there is shorthand like ^ to communicate what characters are going to be replaced
greg
@wearenotgroot
Aug 08 2016 00:50
@kirahmadlare var args = Array.prototype.slice.call(arguments); ---------->https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/arguments
Nick Irvine
@irvin3
Aug 08 2016 00:50
@GregatGit thats what i have been tinkering with, Ive spent a few hours trying to find a solution but havent been able to
Greg Duncan
@GregatGit
Aug 08 2016 00:50
@irvin3 so
var sessionTime = 25;
$("#seshTime").text(sessionTime);
Christian
@Neralizer
Aug 08 2016 00:50
alright, let's start with this
Greg Duncan
@GregatGit
Aug 08 2016 00:50
@irvin3 text or it might be html
Christian
@Neralizer
Aug 08 2016 00:51
regex and regexp are the same thing, yes?
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:51
@Neralizer They are short and blunt because of old bandwidtg limitations. Dial-ups
Moisés Man
@moigithub
Aug 08 2016 00:51
"regular expression"
Christian
@Neralizer
Aug 08 2016 00:51
they are both an object that describes a pattern of characters
Joseph
@revisualize
Aug 08 2016 00:51
@Neralizer Look, I personally don't like the idea of removing all non-alphanumeric characters then creating a huge list of characters that are not alphanumeric. I can just say. I want to keep characters that are alphanumeric by saying replace anything not alpha (A-z) or numeric (0-9) with nothing ("")
greg
@wearenotgroot
Aug 08 2016 00:51
@Neralizer not reggae thats for sure :)
Greg Duncan
@GregatGit
Aug 08 2016 00:52
@irvin3 then when someone changes the session time it adds/takes to the js then you update the html
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:53
@revisualize I am not trying to make him list them. There is a metacharacter to describe all alphanums.
Nick Irvine
@irvin3
Aug 08 2016 00:54
@GregatGit i think that is what i did with my add/subtract functions right?
var seshT = 25;
$('#seshMinus').click(function(){
  if(seshT>1){
  seshT--;
  $("#seshTime").text(seshT);
  $("#disp").text(seshT);
  }
})
Moisés Man
@moigithub
Aug 08 2016 00:54
"make it fail.. and fail sooner" is a way to learn
..then when u fail.. u at least will know how to fix
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:54
@Neralizer Lool for a list of metacharacters in regexp.
Christian
@Neralizer
Aug 08 2016 00:55
like /W
?
greg
@wearenotgroot
Aug 08 2016 00:55
\ :)
Christian
@Neralizer
Aug 08 2016 00:56
\W
Greg Duncan
@GregatGit
Aug 08 2016 00:56
@irvin3 seams good
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:56
@Neralizer YES!!!!!
Christian
@Neralizer
Aug 08 2016 00:56
okay
greg
@wearenotgroot
Aug 08 2016 00:56
\w ----> word characters(alphanumeric)
\W ----> non word characters(non-alphanumeric), note underscore(_) is considered as an alphanumeric
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:56
@Neralizer So what does \w include.
Christian
@Neralizer
Aug 08 2016 00:56

function palindrome(str) {
  str = str.replace(/\W /g , ""); //Replacing non-alphanumeric characters
  str = str.toLowerCase(); //Changing all characters to lower case

  //Reverse String Algorithm
  var array = str.split("");
  array.reverse();
  var newstr = array.join("");

  //If newstr is equal to str, return true
  if (str == newstr) {
    return true;
  }
  return false;
}



palindrome("eye");
Nick Irvine
@irvin3
Aug 08 2016 00:57
@GregatGit yea so my issue is just that I cant pull that value that the users sets and use it for my timer function
var sessionTime = $('#seshTime').text();
@GregatGit no matter what the user sets the seshtime value to, sessionTime always equals 25
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:57
@Neralizer Try your code with \W first.
@Neralizer Should get one error.
Christian
@Neralizer
Aug 08 2016 00:58
I get no errors
you mean with my code? or with all the things I'm checking
like _eye, and race car
Dan Couper
@DanCouper
Aug 08 2016 00:59
eye should go through, that should be an error
sorry, _eye
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:59
@Neralizer Run the tests
Christian
@Neralizer
Aug 08 2016 00:59
right, I did
I get wrong for _eye, race car
A man, a plan, a canal, Panama
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 00:59
@Neralizer Did u read what characters are alphanums?
Christian
@Neralizer
Aug 08 2016 00:59
all of those
Joseph
@revisualize
Aug 08 2016 01:00
@Neralizer What does \W signify?
Christian
@Neralizer
Aug 08 2016 01:00
all nonword characters
greg
@wearenotgroot
Aug 08 2016 01:00
@irvin3 are u using seshT or seshTime?
Joseph
@revisualize
Aug 08 2016 01:00
@Neralizer What are word characters?
Christian
@Neralizer
Aug 08 2016 01:00
I'm assuming letters?
Joseph
@revisualize
Aug 08 2016 01:01
@Neralizer Why are you assuming?
Christian
@Neralizer
Aug 08 2016 01:01
I don't know for sure
greg
@wearenotgroot
Aug 08 2016 01:01
test it
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:01
@Neralizer Just read first what are the alphanums. They are the word characters.
Joseph
@revisualize
Aug 08 2016 01:01
Google?
Moisés Man
@moigithub
Aug 08 2016 01:01
,... its timeto check the documentation :)
Joseph
@revisualize
Aug 08 2016 01:01
A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.
Tim
@x-yz
Aug 08 2016 01:02
underscore is a jerk
Christian
@Neralizer
Aug 08 2016 01:02
sweet
so why doesn't this work
Nick Irvine
@irvin3
Aug 08 2016 01:02
@wearenotgroot seshTime, thats the id of my html element
greg
@wearenotgroot
Aug 08 2016 01:02
@x-yz just misunderstood :)
Joseph
@revisualize
Aug 08 2016 01:02
Though, I'm not google. You should really learn how to google.
Christian
@Neralizer
Aug 08 2016 01:02
the replace method is replacing all non-word characters, globally, and replacing them with nothing
i know how to google
greg
@wearenotgroot
Aug 08 2016 01:03
@irvin3 oh i meant sessionTime
Christian
@Neralizer
Aug 08 2016 01:03
so why is it not working
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:03
@Neralizer Okay so alphanums included the tricky underscore.
Joseph
@revisualize
Aug 08 2016 01:03
_
Christian
@Neralizer
Aug 08 2016 01:03
but it shouldn't matter because _eye should return true
so even if i got rid of the underscore, it should work, no?
Nick Irvine
@irvin3
Aug 08 2016 01:04
@wearenotgroot well im trying to store the value of
$('#seshTime').text();
into var sessionTime
Joseph
@revisualize
Aug 08 2016 01:04
If you have "_eye" and reverse it it becomes "eye_" is "_eye" === "eye_" true?
Dan Couper
@DanCouper
Aug 08 2016 01:04
@Neralizer typo in this line str = str.replace(/\W /g , "”);
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:05
@Neralizer When u do \W you are saying : remove all but letters, numbers, underscore
greg
@wearenotgroot
Aug 08 2016 01:05
@irvin3 well you are updating seshT when the user increase/decrease the session, why not set sessionTime equal to seshT when you hit start?
Christian
@Neralizer
Aug 08 2016 01:05
yes @revisualize because I am removing the underscores beforehand
Dan Couper
@DanCouper
Aug 08 2016 01:05
@Neralizer still need to deal with underscore, but there is a typo
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:05
@DanCouper oh the extra space?
Dan Couper
@DanCouper
Aug 08 2016 01:05
yes
Christian
@Neralizer
Aug 08 2016 01:05
that actually solved a lot
thanks @DanCouper
CamperBot
@camperbot
Aug 08 2016 01:06
neralizer sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 181 | @dancouper |http://www.freecodecamp.com/dancouper
Joseph
@revisualize
Aug 08 2016 01:06
@Neralizer I just scrolled up to your function.. I don't see it.
Dan Couper
@DanCouper
Aug 08 2016 01:06
:thumbsup:
Christian
@Neralizer
Aug 08 2016 01:06
but I still have issues with _eye and the 0_0 (: /-\ :) 0-0
Greg Duncan
@GregatGit
Aug 08 2016 01:06
@irvin3 sessionTime is set at the start and never changes and is used by timer
c0d0er
@c0d0er
Aug 08 2016 01:06
hi, could anybody help me on this: why it shows: 1 != true // false;
0 != false // false. is 1==true and 0==false? or 1===true or 0===false?
Christian
@Neralizer
Aug 08 2016 01:06
@revisualize
greg
@wearenotgroot
Aug 08 2016 01:06
@GregatGit yeah that is what i notice
Christian
@Neralizer
Aug 08 2016 01:06

function palindrome(str) {
  str = str.replace(/\W/g , ""); //Replacing non-alphanumeric characters
  str = str.toLowerCase(); //Changing all characters to lower case

  //Reverse String Algorithm
  var array = str.split("");
  array.reverse();
  var newstr = array.join("");

  //If newstr is equal to str, return true
  if (str == newstr) {
    return true;
  }
  return false;
}



palindrome("eye");
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:07
@Neralizer scroll up to my last comment
Joseph
@revisualize
Aug 08 2016 01:07
@Neralizer Okay, Where are you replacing the _ with nothing?
Because, I don't see it.
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:08
@Neralizer u are aware of the \w and \W ?
Joseph
@revisualize
Aug 08 2016 01:08
ANYHOW. I'm going to go see if the washer is finally open.
greg
@wearenotgroot
Aug 08 2016 01:08
@Neralizer almost there :smile:
Nick Irvine
@irvin3
Aug 08 2016 01:08
@wearenotgroot @GregatGit I think I may have fixed it took away the variable for sessionTime and Breaktime and just used this
Christian
@Neralizer
Aug 08 2016 01:08
thanks for all your help everyone
Greg Duncan
@GregatGit
Aug 08 2016 01:08
@irvin3 you change var seshT but use a different one
Christian
@Neralizer
Aug 08 2016 01:08
yes, \w is all word characters
Nick Irvine
@irvin3
Aug 08 2016 01:08
var counter = 2;
$('#begin').click(function(){
  if(counter%2 === 0){
  timer(seshT);
  }
  else{
    timer(breakT);
  }
});
added seshT and breakt
Christian
@Neralizer
Aug 08 2016 01:09
\W is all non word characters
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:09
@Neralizer we just need to handle the underscore
Christian
@Neralizer
Aug 08 2016 01:09
okay
greg
@wearenotgroot
Aug 08 2016 01:09
@irvin3 add comments on the variable you declare so you know when and where they are use
Christian
@Neralizer
Aug 08 2016 01:10
because we are leaving all non-word characters, including the underscore, which counts as a nonword character
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:10
@Neralizer replace \W means replace ALL BUT letter, numbers, underscore.
Christian
@Neralizer
Aug 08 2016 01:10
right
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:10
@Neralizer so we just add underscore after W
Christian
@Neralizer
Aug 08 2016 01:11
i tried that out, but it gives me more errors
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:11
@Neralizer We have many characters listed so we need to use brackets.
Dan Couper
@DanCouper
Aug 08 2016 01:11
| means OR
jamesmillerho
@jamesmillerho
Aug 08 2016 01:12
/[\W_]/
Dan Couper
@DanCouper
Aug 08 2016 01:12
cat|dog
fat|thin
jamesmillerho
@jamesmillerho
Aug 08 2016 01:12
-.-"
greg
@wearenotgroot
Aug 08 2016 01:12
o.o
Christian
@Neralizer
Aug 08 2016 01:12
i got this to work
```
str = str.replace(/\W|_/g , "");
Dan Couper
@DanCouper
Aug 08 2016 01:12
:thumbsup:
Christian
@Neralizer
Aug 08 2016 01:12
wow
thanks @BenjamWondafrash @wearenotgroot
CamperBot
@camperbot
Aug 08 2016 01:13
neralizer sends brownie points to @benjamwondafrash and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:cookie: 292 | @benjamwondafrash |http://www.freecodecamp.com/benjamwondafrash
:star2: 1303 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Christian
@Neralizer
Aug 08 2016 01:13
that took absurdly long
Stephen James
@sjames1958gm
Aug 08 2016 01:13
@Neralizer Regex are non-intuitive.
Christian
@Neralizer
Aug 08 2016 01:13
i still don't get it
an object that describes a series of characters
so is the regex the method str.replace?
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:14
@Neralizer Good job. There is more regexp tasks later on😂.
greg
@wearenotgroot
Aug 08 2016 01:14
more reading and practice then?
Stephen James
@sjames1958gm
Aug 08 2016 01:14
This does the same by explictily saying not alpha or numeric [] means alternatives with ^ meaning not
str = str.replace(/[^A-Za-z0-9]/g , "");
@Neralizer Regular expression are not only for replace, but they are for matching character strings.
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:15
@Neralizer Old stuff. Slow modems and slow everything. Trying to send as little stuff over the wire as possible.
Christian
@Neralizer
Aug 08 2016 01:15
so that gets rid of everything but what we needed
so the regex is actually the stuff inside the brackets
Robinson L. Legaspi
@rob1121
Aug 08 2016 01:16
hello

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

// Your code above this line
return result;
}

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

Mad lib
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:17
@Neralizer Brackets belong to regexp
Christian
@Neralizer
Aug 08 2016 01:17
@BenjamWondafrash your saying regex is only used to minimize?
Robinson L. Legaspi
@rob1121
Aug 08 2016 01:17
i logic am i needed?
greg
@wearenotgroot
Aug 08 2016 01:17
@rob1121 hint! use function parameter and make a sentence with those and store(assign) it in the result variable
Stephen James
@sjames1958gm
Aug 08 2016 01:18
@Neralizer everything from first / to g is the regular expression.
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:18
@Neralizer I mean the code is cryptic because it is meant to be minimal.
Christian
@Neralizer
Aug 08 2016 01:18
got it
Robinson L. Legaspi
@rob1121
Aug 08 2016 01:18
ok thanks
Norvin Burrus
@ndburrus
Aug 08 2016 01:18
@rob1121 the exercise is asking for a sentence to be built using the 4 word types given. it may be easiest to begin by making a complete (spacing & punctuation) sentence, using the 4 words. to make sense, the complete sentence will require a few "filler" words. :sparkles:
Christian
@Neralizer
Aug 08 2016 01:18
it took like an hour to figure out the replace method and regex and 20 minutes to figure out the actual algorithm
Dan Couper
@DanCouper
Aug 08 2016 01:18
@Neralizer Regex is a language for matching patterns in text strings, & yes it’s the thing inside the brackets, but more specifically, JS uses the /’s to delimit it - var myRegex = /matchThis/. JS regex is not particularly good though, like, this for example is valid in better regex engines (u flag is unicode, x flag is extended, allowing comments and whitespace):
@acronym_chars ~r/
  # Start of string? Match first letter:
  ^\w
  # OR
  |
  # Match any letter immediately preceded by a space or punctuation char
  (?<=\s|\p{Punctution})\w
  # OR
  |
  # Match any uppercase letter immediately preceded by a lowercase letter.
  (?<=\p{Letter_lowecase})\p{Letter_uppercase}                                       
/ux
Christian
@Neralizer
Aug 08 2016 01:18
that was nonsense
haha well thanks y'all, much appreciated
it's dinner time, and @DanCouper , I'll raise one to newcastle getting promoted this year
Tim
@x-yz
Aug 08 2016 01:20
did you guys use a switch or a bunch of if statements for the roman numeral converter?
Christian
@Neralizer
Aug 08 2016 01:20
that's much better than brownie points
Dan Couper
@DanCouper
Aug 08 2016 01:20
:smile: it is very much better
This message was deleted
thank you @Neralizer
CamperBot
@camperbot
Aug 08 2016 01:21
dancouper sends brownie points to @neralizer :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @neralizer |http://www.freecodecamp.com/neralizer
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:22
@x-yz Neither. One array for numbers and one array for romanNumerals.
@Tim In same order of coursw.
Tim
@x-yz
Aug 08 2016 01:24
ok thanks @BenjamWondafrash
CamperBot
@camperbot
Aug 08 2016 01:24
x-yz sends brownie points to @benjamwondafrash :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @benjamwondafrash |http://www.freecodecamp.com/benjamwondafrash
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:24
@x-yz listed 1, 4, 5, 9 and 10, 40, 50, 90 up until 1000
Tim
@x-yz
Aug 08 2016 01:25
makes sense, i'll do it that way
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:26
@x-yz Now working on the actual conv. Taking the number and decreasing it until i reach zero.
Tim
@x-yz
Aug 08 2016 01:26
yeah i get it ;)
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:27
@x-yz I am doing the same task
Norvin Burrus
@ndburrus
Aug 08 2016 01:27
@rob1121 how are we doing?
Tim
@x-yz
Aug 08 2016 01:28
would a number like 2900 mess your thing up? i mean, would you get CMMM instead of MMCM?
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:30
@x-yz Good point. I am not done yet. I had a huge if-else hassle earlier. Dropped the ball.
@x-yz Is MMCM correct? I think it is not
Stephen James
@sjames1958gm
Aug 08 2016 01:32
MMCM is 2900
@x-yz Actually if you started from the wrong end you might end up with 2900 I's :)
Tim
@x-yz
Aug 08 2016 01:33
haha yeah
i thought MMCM was correct but im not a roman
ill have to watch an old movie to see how they handled 19xx
Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:34
@x-yz @sjames1958gm Yeah the numbers I listed are in descending order to make the looping easy.
Stephen James
@sjames1958gm
Aug 08 2016 01:35
MCMLVIII - is 1958
Tim
@x-yz
Aug 08 2016 01:38
so you should look for 900 before 1000...
or...?
Stephen James
@sjames1958gm
Aug 08 2016 01:38
No, the first M is 1000, then CM is 900
Tim
@x-yz
Aug 08 2016 01:38
nm
overthinking :)
Marc Droz
@b1tc0de
Aug 08 2016 01:39
help, challenge "Manipulating Complex Objects", Am I adding the new array in the wrong place?...
CamperBot
@camperbot
Aug 08 2016 01:39
no wiki entry for: challenge manipulating complex objects am i adding the new array in the wrong place
Tim
@x-yz
Aug 08 2016 01:39
or underthinking maybe
Marc Droz
@b1tc0de
Aug 08 2016 01:39

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  }
  [
  {
  "artist": "Top Chilltrap Hits",
  "title": "GoToSleep",
  "release_year": 1981,
  "formats": [
    "8-track",
    "Laser Disk",
    ".mp3"
  ]  
  }
    ]
];
Dan Couper
@DanCouper
Aug 08 2016 01:40
syntax error there
Tim
@x-yz
Aug 08 2016 01:40
}]
Dan Couper
@DanCouper
Aug 08 2016 01:41
myMusic = [{}[]];
Marc Droz
@b1tc0de
Aug 08 2016 01:41
who me? where is the syntax error if you could point me to it please
Dan Couper
@DanCouper
Aug 08 2016 01:41
[{}[]]
Tim
@x-yz
Aug 08 2016 01:41
formats is an array @DanCouper
Marc Droz
@b1tc0de
Aug 08 2016 01:42
imagine you are explaining it to an illiterate monkey trying to code
i don't get this stuff naturally
Dan Couper
@DanCouper
Aug 08 2016 01:45

:smile:


var myMusic = [
 // this is the first object, in an array:
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  } // this is the end of the first object.
  // it is in an array, and an array has values seperated by commas:
 // [1,2,3]
// [{foo: 1}, {bar: 2}]
// But, no comma here
// instead another array
  [ // this shouldn't be here
  {
  "artist": "Top Chilltrap Hits",
  "title": "GoToSleep",
  "release_year": 1981,
  "formats": [
    "8-track",
    "Laser Disk",
    ".mp3"
  ]  
  }
    ] // neither should this
];

```

Benjam Wondafrash
@BenjamWondafrash
Aug 08 2016 01:45
@b1tc0de What @DanCouper said. U have extra square brackets around your record.
Marc Droz
@b1tc0de
Aug 08 2016 01:46
awesome thanks @DanCouper for taking time to explain it that way, appreciate your time
CamperBot
@camperbot
Aug 08 2016 01:46
b1tc0de sends brownie points to @dancouper :sparkles: :thumbsup: :sparkles:
:cookie: 182 | @dancouper |http://www.freecodecamp.com/dancouper
Dan Couper
@DanCouper
Aug 08 2016 01:46
:thumbsup:
Lusako Njwaba
@lunjwaba1
Aug 08 2016 01:47
Hello people
I am having trouble with two problems and I think they are related.
One is the collection and the other is Profile lookup challenge
Here is my profile lookup solution:
function lookUpProfile(firstName, prop){
// Only change code below this line
  for(i=0; i < contacts.length; i++){
  if ((contacts[i].firstName === firstName) && (contacts[i].hasOwnProperty(prop))) {
      return contacts[i][prop];
  } else if(firstName !== contacts[i].firstName){
      return "No such contact";

  } else if(contacts[i].hasOwnProperty(prop) === false){
      return "No such property";

  }

  }
// Only change code above this line
}
Stephen James
@sjames1958gm
Aug 08 2016 01:51
@lunjwaba1 What happens if the firstName in contacts[0] != the firstName parameter?
Lusako Njwaba
@lunjwaba1
Aug 08 2016 01:51
The last two if statements work, but the first if doesnt
Michael Bomholt
@bomholtm
Aug 08 2016 01:52
hey guys is there a possibility to forbid function A to do stuff everytime function B does stuff? i have the problem that i have two functions doing kinda the same thing. but theyre are both needed. if they get both triggered at the same time it results in a bug :worried:
Lusako Njwaba
@lunjwaba1
Aug 08 2016 01:54
@sjames1958gm it return "No such contact"
Stephen James
@sjames1958gm
Aug 08 2016 01:54
@lunjwaba1 Is that correct?
Lusako Njwaba
@lunjwaba1
Aug 08 2016 01:54
*returns
Sabrina Ferguson
@itsacoyote
Aug 08 2016 01:54
@lunjwaba1 so you're looping through the contacts list. If the first contact you go through does not match or have a property, it will return "No such ...". A return inside the for loop terminates the for loop and you'll never get to the next contact in the contacts list. You'll want to do more calculations and checks before you return anything.
Lusako Njwaba
@lunjwaba1
Aug 08 2016 01:56
@itsacoyote Oh, ok. But why doenst it terminate at the first it statement?
*if
Stephen James
@sjames1958gm
Aug 08 2016 01:57
@lunjwaba1 If the firstName doesn't match it fails the first check and the returns no such contact.
@lunjwaba1 If you were going through a list of contacts searching for a specific name when would you declare you didn't have the contact?
Sabrina Ferguson
@itsacoyote
Aug 08 2016 01:59
@lunjwaba1 it does for the first test, lookUpProfile("Akira", "likes"). For the other tests, you have to go down to the next contact. But your return is stopping at the first contact. So if the contact doesn't match what you send in, you're going to get the "No such contact" or "No such property"
Return stops the for loop from going to the next contact and testing to see if contact matches.
Stephen James
@sjames1958gm
Aug 08 2016 02:00
@lunjwaba1 One hint, all code doesn't have to go in your for loop.
Lusako Njwaba
@lunjwaba1
Aug 08 2016 02:02
@itsacoyote @sjames1958gm Got it, thanks guys :smile:
CamperBot
@camperbot
Aug 08 2016 02:02
lunjwaba1 sends brownie points to @itsacoyote and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:cookie: 315 | @itsacoyote |http://www.freecodecamp.com/itsacoyote
:star2: 2406 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 08 2016 02:10
@lunjwaba1 :+1:
Tim
@x-yz
Aug 08 2016 02:12
these helpful hints have me second-guessing all my solutions to problems.
helpful links*
Maustschool
@Maustschool
Aug 08 2016 02:23
This message was deleted
This message was deleted
bradulz
@bradulz
Aug 08 2016 02:40
anyone know how I'd put a 2d array into a html table easily without having to use PHP?
Carrie
@yodermail
Aug 08 2016 02:41
Does anyone know how I would go about using javascript to access data from a google spreadsheet?
Carrie
@yodermail
Aug 08 2016 02:49
Thanks @ndburrus , not sure it's quite what I need though: I'm trying to figure out how to write javascript that searches and displays certain parts of a google spreadsheet based on the search terms
CamperBot
@camperbot
Aug 08 2016 02:49
yodermail sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star2: 1439 | @ndburrus |http://www.freecodecamp.com/ndburrus
bradulz
@bradulz
Aug 08 2016 02:52
@ndburrus yeah this is close but how do I do it for a table that already has the spaces to fit it in instead of creating it?
Carrie
@yodermail
Aug 08 2016 02:55
Yes, this looks just right @ndburrus ! Thank you!
CamperBot
@camperbot
Aug 08 2016 02:55
yodermail sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: yodermail already gave ndburrus points
Norvin Burrus
@ndburrus
Aug 08 2016 02:55
@yodermail you're welcome! enjoy! :palm_tree:
AFK3000
@AFK3000
Aug 08 2016 02:57
hello
i need some help with a exercise
convert celsius to fahrenheit
silver537
@silver537
Aug 08 2016 02:58
Post your code
AFK3000
@AFK3000
Aug 08 2016 02:58

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
var fahrenheit = 9/5+32;

// Only change code above this line
var celsius= fahrenheit-32 /9/5;
}

// Change the inputs below to test your code
convertToF(30);
var fahrenheit= 30 * 5/9 +32;

its all wrong
silver537
@silver537
Aug 08 2016 02:59
Pemdas
Norvin Burrus
@ndburrus
Aug 08 2016 03:00
@AFK3000 The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
we can rewrite the equation/formula to: Fahrenheit is (=) Celsius times() 9/5, plus (+) 32.
which is F = C
9/5 + 32,
or F = C(9/5) + 32. :sparkles:
reference instructions, here: The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.
alright, so we need to convert this formula to code!
can we see what to do?
AFK3000
@AFK3000
Aug 08 2016 03:01
Yup
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


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

// Change the inputs below to test your code
convertToF(30);
Norvin Burrus
@ndburrus
Aug 08 2016 03:03
@AFK3000 ok, first, let's attend to this
// Only change code above this line
so remove inappropriate code
here: var fahrenheit= 30 * 5/9 +32;
next, let's correct the code we have, here
"var fahrenheit = here 9/5+32;"
can we see what we need (ie what is missing)?
AFK3000
@AFK3000
Aug 08 2016 03:06
temperture
celsius
Norvin Burrus
@ndburrus
Aug 08 2016 03:06
@AFK3000 correct. let's fix this...
AFK3000
@AFK3000
Aug 08 2016 03:07
var fahrenheit = 30 * 5/9 + 32;
Norvin Burrus
@ndburrus
Aug 08 2016 03:08
@AFK3000 ...remember from above, we want this
F = C(9/5) + 32 :point_up: August 7, 2016 11:00 PM
bradulz
@bradulz
Aug 08 2016 03:09
$(#String(index1)+String(indey1)).html = 1; anyway I could get this to function properly? I'm trying to get the ID to be based off two other variables (x and y values)
AFK3000
@AFK3000
Aug 08 2016 03:09
function convertToF(celsius) {
  var fahrenheit= 30 * 5/9 + 32;
  // Only change code below this line


  // Only change code above this line
  return fahrenheit= c(9/5) + 32;
}

// Change the inputs below to test your code
convertToF(30);
var fahrenheit= 30 * 5/9 +32;
Norvin Burrus
@ndburrus
Aug 08 2016 03:10
@AFK3000 ok, the code at the very bottom is unnecessary. we can remove it, here var fahrenheit= 30 * 5/9 +32;
you may want to reset (to retrieve the original code). it looks like some lines were deleted.
then add correct code :) it's only 1 line.
AFK3000
@AFK3000
Aug 08 2016 03:11
function convertToF(celsius) {
  var fahrenheit= 30 * 5/9 + 32;
  // Only change code below this line


  // Only change code above this line
  fahrenheit= c(9/5) + 32;
}

// Change the inputs below to test your code
convertToF(30);
silver537
@silver537
Aug 08 2016 03:13
You gotta type the whole word
Norvin Burrus
@ndburrus
Aug 08 2016 03:15
@AFK3000 reference the input variable, here
"function convertToF( celsius ) {"
also, you may consider the rest, and placing the code where indicated. :)
AFK3000
@AFK3000
Aug 08 2016 03:18
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line


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

// Change the inputs below to test your code
convertToF(30);
var fahrenheit = 30 * 5/9 + 32;
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
Joseph
@revisualize
Aug 08 2016 03:20
@AFK3000 What is the formula for making the conversion? (Hint: It is in the instructions.
AFK3000
@AFK3000
Aug 08 2016 03:21
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  var fahrenheit= celsius * 5/9 +32;
  var celsius= fahrenheit * 9/5 -32

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

// Change the inputs below to test your code
convertToF(30);
var fahrenheit = 30 * 5/9 + 32;
Norvin Burrus
@ndburrus
Aug 08 2016 03:22
@x-yz :)
AFK3000
@AFK3000
Aug 08 2016 03:23
what the heck
i believe my formula is correct
AFK3000
@AFK3000
Aug 08 2016 03:30
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  var fahrenheit = celsius * 5/9 +32;
  var celsius= (fahrenheit-32) / 1.8;

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

// Change the inputs below to test your code
convertToF(30);
var fahrenheit = 30 * 5/9 + 32;
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  var fahrenheit = celsius * 5/9 +32;
  var celsius= (fahrenheit-32) / 1.8;

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

// Change the inputs below to test your code
convertToF(30);
function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  fahrenheit = celsius * 5/9 +32;
  celsius= (fahrenheit-32) / 1.8;

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

// Change the inputs below to test your code
convertToF(30);
King Mhar Bayato
@kirahmadlare
Aug 08 2016 03:34

Hello, could you tell me whats wrong with my code:

  // Remove all the values
 var output = [];
  var args = Array.prototype.slice.call(arguments);
  args.splice(0,1);
  for(var i = 0;i<arr.length ; i++)
    {for(var j = 0 ; j<args.length; j++)

    {
          if(arr[i]==args[j]){

            delete arr[i];
          }
       }
    }

output = arr;

seek and destroy challenge

Anonymous
@LAPAIX
Aug 08 2016 03:35
help Iterate Through an Array with a For Loop
CamperBot
@camperbot
Aug 08 2016 03:35

:point_right: challenge iterate through an array with a for loop [wiki]

Challenge Iterate Through an Array with a For Loop

A common task in Javascript is to iterate through the contents of an array. One way to do that is with a for loop. This code will output each element of the array arr to the console:

    var arr = [10,9,8,7,6];
    for (var i=0; i < arr.length; i++) {
       console.log(arr[i]);
    }

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.

:pencil: read more about challenge iterate through an array with a for loop on the FCC Wiki

Joel Santos
@St3ps
Aug 08 2016 03:42
@AFK3000 but it's not
fahrenheit = (celsius * (9/5)) +32;
1p2r3a
@1p2r3a
Aug 08 2016 03:45

function golfScore(par, strokes) {
// Only change code below this line

if(par=0 && strokes=1){
return "Hole-in-one!";

}
else if(){
return "Eagle";
}
else if(){
return "Birdle";
}
else if(){
return "par";
}
else if(){
return "Bogey"
}
else if(){
return "double Bogey"

}
else{
return "Go Home!"
}
return "Change Me";
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

HOW I WANT to pass arguments in if else condition
pankajkankonkar
@pankajkankonkar
Aug 08 2016 03:48
hello
how to solve problem no 280.
what exactly need to be done
thanks
jamesmillerho
@jamesmillerho
Aug 08 2016 03:48
@kirahmadlare your code is correct, but you should return
 return arr.filter(function(a){return a !== null;});
Norvin Burrus
@ndburrus
Aug 08 2016 03:48
@1p2r3a these may be useful: :sparkles:
Artur Sęp
@a-sep
Aug 08 2016 03:53
@pankajkankonkar giv us a name of lection
jamesmillerho
@jamesmillerho
Aug 08 2016 03:53
@pankajkankonkar what's the exercise name
Chris Lacaille
@ChrisL108
Aug 08 2016 04:01
Hey guys having a small issue with RegEx'es.. I need to match parentheses ONLY if there is a matching opening/closing parentheses. Here's what I have so far...
function telephoneCheck(str) {
  return /(?:1{1}\s)?\(?(\d{3})\)?-?\s?(\d{3})-?\s?(\d{4})/g.test(str);
}

// this returns true since my parentheses are optional
telephoneCheck("(555-555-5555");
DJ
@qualitymanifest
Aug 08 2016 04:03
@ChrisL108 so allow two types of area codes: one with a full set of parens or one with no parens
Chris Lacaille
@ChrisL108
Aug 08 2016 04:04
Didn't think of that @qualitymanifest ..thanks! Do you know if this is possible with RegEx tho?
DJ
@qualitymanifest
Aug 08 2016 04:04
@ChrisL108 yes, that is basically what i did for that challenge
@ChrisL108 just put both area codes in a capturing group with an "or pipeline" in between. also you don't need the global flag for this one
Chris Lacaille
@ChrisL108
Aug 08 2016 04:06
@qualitymanifest Yeah I just saw the pipeline way
totally forgot about that lol
@qualitymanifest Thanks!
CamperBot
@camperbot
Aug 08 2016 04:07
chrisl108 sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star2: 1334 | @qualitymanifest |http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Aug 08 2016 04:07
no problem :+1: that's a fun challenge
Jose Ignacio Rodriguez-Labra
@Nachosuperxs
Aug 08 2016 04:10
Will .removeClass from jQuery remove a class of a div that is a parent of the element .removeClass is pointing to? In other words, does .removeClass remove inherited classes?
Scott Burnley
@burnleyscott
Aug 08 2016 04:40
Struggling with the "Stand in Line" section of Javascript. Suppose to write a function nextInLine
Sabrina Ferguson
@itsacoyote
Aug 08 2016 04:41
@burnleyscott what's your current code so far?
Markus Kiili
@Masd925
Aug 08 2016 04:42
@burnleyscott Find out the two array methods needed, and use them on item and arr.
Scott Burnley
@burnleyscott
Aug 08 2016 04:42
So am I suppose to use the console.log for after on the item and the console.log for before on the array?
The display code is what is confusing to me
Sabrina Ferguson
@itsacoyote
Aug 08 2016 04:43
@burnleyscott the console.log is to help you see the outputs so you can see if your code is working correctly.
Markus Kiili
@Masd925
Aug 08 2016 04:43
@burnleyscott No console.logs needed. Just return at the end is enough.
Scott Burnley
@burnleyscott
Aug 08 2016 04:43
Ohh my gosh I was thinking display meant example code....not actually displaying the results
sorry blonde moment
thanks guys
So i will want to be using the push and shift correct?
Markus Kiili
@Masd925
Aug 08 2016 04:46
@burnleyscott Yes.
And I would guess Sabrina is not a guy ;)
Sabrina Ferguson
@itsacoyote
Aug 08 2016 04:48
:P
Brandon Bowers
@Bowers96
Aug 08 2016 04:51
var Car = function() {
  this.wheels = 4;
  this.engines = 1;
  this.seats = 5;
};

// Only change code below this line.

var myCar = new Car();
  myCar.nickName = "random";
Why does it say : The property nickname of myCar should be a string.
?8
Markus Kiili
@Masd925
Aug 08 2016 04:52
@Bowers96 Is it nickname or nickName?
Brandon Bowers
@Bowers96
Aug 08 2016 04:53
Duhhhhhh. Thank you. @Masd925
CamperBot
@camperbot
Aug 08 2016 04:53
bowers96 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2253 | @masd925 |http://www.freecodecamp.com/masd925
Devon
@metalogicoder
Aug 08 2016 04:56
```
  var newArray = [];
  for (var i = 0; i < arr.length + size; i + size) {
    var arrSlice = arr.slice(i, i + size);
    newArray.push(arrSlice);
  }

  return newArray;
Hey guys can you tell me what im doing wrong with this loop here
it keeps giving me an infinite loop
the arr value for that function is ([a, b, c, d], 2)
Markus Kiili
@Masd925
Aug 08 2016 04:57
@PyroMechanic Try (var i=0; i<arr.length; i+=size)
You were not incrementing.
Devon
@metalogicoder
Aug 08 2016 04:58
@Masd925 You're fantastic! Thank you
CamperBot
@camperbot
Aug 08 2016 04:58
pyromechanic sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2254 | @masd925 |http://www.freecodecamp.com/masd925
Devon
@metalogicoder
Aug 08 2016 04:58
so simple >_<
Markus Kiili
@Masd925
Aug 08 2016 04:59
@PyroMechanic There is also an elegant solution with while loop.
NixonRichard
@NixonRichard
Aug 08 2016 05:19
hmm
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:22
Any javascript gurus on?
Need some help solving a problem.
Markus Kiili
@Masd925
Aug 08 2016 05:28
@CyberSurferX No gurus here, but you can post your question.
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:29
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> <script>
    $(".h-icon").click(function (event) {
        event.preventDefault();
        $("i", this).toggleClass("fa-heart fa-heart-o");
        $.ajax({
            url: $(this).attr("href")
        })
        return false;
    });
@Masd925 Here's the issue. I'm using it on several classes, and it's only working on every other class.
@Masd925 Any idea why this might be happening?
bradulz
@bradulz
Aug 08 2016 05:32
@CyberSurferX is it because its both i AND this? so it toggles twice?
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:33
When I take off the <i> element it doesn't work at all.
@bradulz
bradulz
@bradulz
Aug 08 2016 05:34
@CyberSurferX what happens when you just take the this out of the toggle
Manjot Singh
@msingh18
Aug 08 2016 05:34
I am not able to get the GET request working properly in Codepen. My url parameter automatically gets prefixed with the codepen address. Can someone help?
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:35
@bradulz It toggles every elements class.
DJ
@qualitymanifest
Aug 08 2016 05:35
@msingh18 paste your codepen
bradulz
@bradulz
Aug 08 2016 05:35
@CyberSurferX wasnt that your goal? :S
Manjot Singh
@msingh18
Aug 08 2016 05:35
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:36
No i only want to toggle the element's class i'm currently clicking on.
@bradulz
DJ
@qualitymanifest
Aug 08 2016 05:37
@msingh18 put https:// at the beginning of your URL variable
bradulz
@bradulz
Aug 08 2016 05:37
why not just use this then? or put an id on it and target that?
@CyberSurferX
DJ
@qualitymanifest
Aug 08 2016 05:38
This message was deleted
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:39
Because an id can only be used once, but i'll try using this.
@bradulz
Manjot Singh
@msingh18
Aug 08 2016 05:40
@qualitymanifest connection is refused when I try to https://
DJ
@qualitymanifest
Aug 08 2016 05:40
@msingh18 yeah sorry, try http:// that will give you errors too but for another reason. at least then the URL will work on its own
Manjot Singh
@msingh18
Aug 08 2016 05:41
@qualitymanifest how to get rid of all the errors?
NixonRichard
@NixonRichard
Aug 08 2016 05:41
function destroyer(arr) {
  // Remove all the values
  var newArr = [];
  for ( var  i = 0 ; i < arguments.length ; i++) {
    newArr.push(arguments[i]);
  }

  return arr.filter(function(val) {
    return newArr.indexOf(val) == -1;
});

}


destroyer([1, 2, 3, 1, 2, 3], 2, 3);
hi there i wonder how this work ?
seek and destroy challenge
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:42
@bradulz "this" didn't work either.
Markus Kiili
@Masd925
Aug 08 2016 05:44
@NixonRichard Filter keeps those arr elements that return true when passed into the callback function. So it keeps those that return -1 from the indexOf and thus are not found on the array of arguments.
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:45
    $(".h-icon").click(function (e) {
        e.preventDefault();
        $("i", this).toggleClass("fa-heart fa-heart-o");
    });
Can anyone help me solve this? I have been all over the internet, stack overflow, and still no luck.
Abis Mal
@abisthecodermal
Aug 08 2016 05:54
What's wrong with this code?
//Diff Two Arrays

//Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other //words, return the symmetric difference of the two arrays.


function diffArray(arr1, arr2) {

  var a="";
  var b="";
  var arr10="";
  var arr20="";

  if (arr1.length===0)
    return arr2;

  if (arr2.length===0)
    return arr1;

  arr1.sort();
  arr2.sort();

  if (arr1[0]<arr2[0]){
    arr10=arr1[0];
    a=arr1.shift();
    return (arr10+diffArray(arr1,arr2));
  }

  else if(arr1[0]===arr2[0]){
    a=arr1.shift();
    b=arr2.shift();
    return(arr1,arr2);
  }
  else{
    arr20=arr2[0];
    b=arr2.shift();
    return (arr20+diffArray(arr1,arr2));
  }
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
Joshua Whalen
@CyberSurferX
Aug 08 2016 05:55
The sad thing is it works perfectly on jsfiddle.
1p2r3a
@1p2r3a
Aug 08 2016 06:03

function golfScore(par, strokes) {
// Only change code below this line

if(strokes==1){
return "Hole-in-one!";

}
else if(strokes<=par-2){
return "Eagle";
}
else if(strokes===par-1){
return "Birdle";
}
else if(strokes==par){
return "par";
}
else if(strokes==par+1){
return "Bogey";
}
else if(strokes===par+2){
return "double Bogey";

}
else if(strokes>=par+3){
return "Go Home!";
}
else{
return "Change Me";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

can anyone find the error on this
Victor Fischer Scattone
@VFS
Aug 08 2016 06:11
I need some help on "Sum All Numbers in a Range - Intermediate Algo."
I thing the expected solution is to iterate between the arr.min and arr.max, populating a new array. Then, reduce this array to the sum.
Wouldn't it be extremely faster to just solve that with a for?
function sumAll(arr) {
  var sum = 0;

  var els = Math.max.apply(null, arr) - Math.min.apply(null, arr);

  for(var i = 0; i <= els; i++){
    sum += Math.min.apply(null, arr) + i;
  }
  return sum;
}

sumAll([5, 10]);
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:12
@a-sep Smallest Common Multiple
@jamesmillerho Smallest Common Multiple

function smallestCommons(arr) {
var max = Math.max(arr[0],arr1);
var min = Math.min(arr[0],arr1);
var num = min==1 ? 2: min;
var flag=1;
var new_arr=[];

for(var i=min; i<=max; i++){
new_arr.push(i);
}
while(true){
for(i=0; i<new_arr.length; i++){
if(num%new_arr[i]!==0){
flag=0;
break;
}
}
if(flag===0){
num++;
flag=1;
}
else
break;
}
return num;
}
smallestCommons([23,18]);

anything wrong in this code ?

Markus Kiili
@Masd925
Aug 08 2016 06:20
@victorso Using loops and basic operations is somewhat faster than using methods. Usually though clarity of the code is the most important thing and more compact code has value too in real projects.
You could take the apply out of the loop:
function sumAll(arr) {
  var max = Math.max.apply(null,arr);
  var min = Math.min.apply(null,arr);
  var result = 0;
  for (var i=min; i<=max; i++) result += i;
  return result;
}
or use some math:
function sumAll(arr) {
  var max = Math.max.apply(null,arr);
  var min = Math.min.apply(null,arr);
  return (max+min)/2*(max-min+1);
}
Victor Fischer Scattone
@VFS
Aug 08 2016 06:24
Thanks @Masd925 Sure, those would be nice improvements! But my question is what would be the advantages of using the reduce method suggested on the "helpful links" instead of using those basic operations. I'm having trouble seeing how this problem benefits of the reduce method.
CamperBot
@camperbot
Aug 08 2016 06:24
victorso sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2256 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 08 2016 06:25
@victorso There is no benefit at this case. Just teaches how to use reduce.
Victor Fischer Scattone
@VFS
Aug 08 2016 06:26
@Masd925 Nice! Thanks!
CamperBot
@camperbot
Aug 08 2016 06:26
victorso sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: victorso already gave masd925 points
Mark Todd
@Knochenmark
Aug 08 2016 06:27
@victorso you could also just sort the array instead of Math.max or min
Markus Kiili
@Masd925
Aug 08 2016 06:27
@Knochenmark Sorting is so slow that it should be avoided if the sorted array is not really needed later.
Mark Todd
@Knochenmark
Aug 08 2016 06:28
@Masd925 lol you are sorting an array of length 2...
Markus Kiili
@Masd925
Aug 08 2016 06:29
@Knochenmark Here there is little difference but we are learning to make good code...
dalbergiaretusa
@dalbergiaretusa
Aug 08 2016 06:30
hi guys could you help me

im stuck on a challenge where i need to access something from within a function
the base var looks like this

var collection = {
    (...)
};

and the function looks like this

function updateRecords(id, prop, value) {
  if(collection[prop]!=="tracks" && collection[value]!==""){
      collection[value]=collection[prop];
    }
  if(collection[prop]=="tracks" && collection[value]!=="") {
    collection[prop].push(collection[value]);
  }
  if(collection[value]!=="") collection[prop].del();

  return collection;
}
updateRecords(5439, "artist", "ABBA");

and i thought that this should work but JS shouts that collection[prop] is unidentified

Markus Kiili
@Masd925
Aug 08 2016 06:33
@dalbergiaretusa First figure out how to access a particular record with given id.
Manjot Singh
@msingh18
Aug 08 2016 06:33
How do you access JSON object in JavaScript?
Coy Sanders
@coymeetsworld
Aug 08 2016 06:33
you need to use the id parameter to access collector for one @dalbergiaretusa, also you need to check if the property exists within that record collection as well, using the hasOwnProperty method
Joshua Whalen
@CyberSurferX
Aug 08 2016 06:34
@coymeetsworld Could you help me with a JQuery problem i'm having?
Coy Sanders
@coymeetsworld
Aug 08 2016 06:35
sure
dalbergiaretusa
@dalbergiaretusa
Aug 08 2016 06:35
alright
so to access an object I need to go for collection[id][prop] ie?
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:36
hi i need help with smallest common multiples algo..
Coy Sanders
@coymeetsworld
Aug 08 2016 06:36
yeah @dalbergiaretusa
Mark Todd
@Knochenmark
Aug 08 2016 06:37
@dalbergiaretusa to access the property of the object with the specified id
@pankajkankonkar whats your approach?
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:40

@Knochenmark
i have this code

function smallestCommons(arr) {
var max = Math.max(arr[0],arr[1]);
var min = Math.min(arr[0],arr[1]);
var num = min==1 ? 2: min;
var flag=1;
var new_arr=[];
for(var i=min; i<=max; i++){
new_arr.push(i);
}
while(true){
for(i=0; i<new_arr.length; i++){
if(num%new_arr[i]!==0){
flag=0;
break;
}
}
if(flag===0){
num++;
flag=1;
}
else
break;
}
return num;
}
smallestCommons([1,5]);

its working fine for small ranges but not working for greater ranges

says infinite loop
srinivas
@srinivasdasu
Aug 08 2016 06:41
Hi All, I need bus reservation system project in java . It's urgent as i am out of time. Could you please project code.
Mark Todd
@Knochenmark
Aug 08 2016 06:41
@pankajkankonkar that while(true) is quite risky :D
Tymon
@Tymon555
Aug 08 2016 06:41
hello all :)
Manjot Singh
@msingh18
Aug 08 2016 06:42
@srinivasdasu College assignment? Good luck with that
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:42
function mutation(arr) {
    arr.forEach(function(x) {
        return x.toLowerCase();
    });

    return arr;
}

console.log(mutation(["hello", "Hel"]));
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:42
@Knochenmark it says infinite for "for" loop
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:42
hello, can someone tell me why this is not returning the expected result?
which is ['hello', 'hel'];
Mark Todd
@Knochenmark
Aug 08 2016 06:43
@jkchuynh829 what is the exspected result?
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:43
@Knochenmark what will be the better way ?
Markus Kiili
@Masd925
Aug 08 2016 06:44
@jkchuynh829 Returning inside forEach callback does nothing.
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:44
@Knochenmark
smallestCommons([1, 5]) should return a number.
smallestCommons([1, 5]) should return 60.
smallestCommons([5, 1]) should return 60.
smallestCommons([1, 13]) should return 360360.
smallestCommons([23, 18]) should return 6056820.
its not working for last one..
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:44
okay, that helps @Knochenmark
Mark Todd
@Knochenmark
Aug 08 2016 06:45
@pankajkankonkar read up on smallest common on wikipedia, there are a few approaches. iam not even sure what you are trying
@jkchuynh829 arr.map(function(e){
return e.toLowerCase();
}); ?
pankajkankonkar
@pankajkankonkar
Aug 08 2016 06:45
@Knochenmark okay
thanks
CamperBot
@camperbot
Aug 08 2016 06:45
pankajkankonkar sends brownie points to @knochenmark :sparkles: :thumbsup: :sparkles:
:cookie: 393 | @knochenmark |http://www.freecodecamp.com/knochenmark
Mark Todd
@Knochenmark
Aug 08 2016 06:46
arr.map(function(e){
return e.toLowerCase();
});
@jkchuynh829 this does the trick
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:46
im still stuck on smallest commons..
the maths.. the maths
Mark Todd
@Knochenmark
Aug 08 2016 06:47
try the one with greatest common divisor
Darth Skywalker
@adityaparab
Aug 08 2016 06:47
Math is magical :)
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:47
the farthest i got was setting up the helper method to find the gcd with recusion
Mark Todd
@Knochenmark
Aug 08 2016 06:47
i tried the prime factorization and gave up but gcd is pretty trivial when you figured it out
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:48
then my brain melted
Mark Todd
@Knochenmark
Aug 08 2016 06:48
why, all you need to do is create the range and use reduce for the sum :D
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:48
what is the difference in your example @Knochenmark
because i haven't mastered reduce
i created the range, yes
Mark Todd
@Knochenmark
Aug 08 2016 06:49
if you have the range and gcd, just use reduce on your range and return the calculation :D
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:49
im surprised you have the same approach as me, is this a common way to solve that problem
Mark Todd
@Knochenmark
Aug 08 2016 06:49
i think it probably is
srinivas
@srinivasdasu
Aug 08 2016 06:49
@msingh18 could you please help me if you have any idea
I was stuck in between
Mark Todd
@Knochenmark
Aug 08 2016 06:50
i think prime factorization is usually also simple, but i was stuck at trying to omit the factors with highest power. Gave up and went for gcd
Jimmy Huynh
@jkchuynh829
Aug 08 2016 06:50
i see
Mark Todd
@Knochenmark
Aug 08 2016 06:52
return yourRangeArray.reduce(function(a,b){
return; // return the gcd calculation formula here ;)
})
@jkchuynh829
Manjot Singh
@msingh18
Aug 08 2016 06:54
Is JSON object same as any other JavaScript object?
Mark Todd
@Knochenmark
Aug 08 2016 06:55
@msingh18 you can parse it into a javascript object
@msingh18 json object is a bit more strict the way the keys have to be strings
Manjot Singh
@msingh18
Aug 08 2016 06:55
@Knochenmark is that the only difference?
Mark Todd
@Knochenmark
Aug 08 2016 06:56
@msingh18 hm other than that its pretty much the same like object literals
Markus Kiili
@Masd925
Aug 08 2016 06:57
@msingh18 JSON is a string or text format for storing objects. Those FCC challenges deal with JS objects created from JS object literals.
Manjot Singh
@msingh18
Aug 08 2016 06:57
@Knochenmark @Masd925 thank you, I am reading further about it
CamperBot
@camperbot
Aug 08 2016 06:57
msingh18 sends brownie points to @knochenmark and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 394 | @knochenmark |http://www.freecodecamp.com/knochenmark
:star2: 2257 | @masd925 |http://www.freecodecamp.com/masd925
Mark Todd
@Knochenmark
Aug 08 2016 06:58
@msingh18 there are a few more limitations
Manjot Singh
@msingh18
Aug 08 2016 06:58
@Knochenmark such as?
dalbergiaretusa
@dalbergiaretusa
Aug 08 2016 06:59
hey, how to add a property to a JSON without overwriting everything thats been there before?
Mark Todd
@Knochenmark
Aug 08 2016 06:59
@Masd925 its not a String, but you can stringify a JSON object
Sergio Salinas
@sergiosalfer
Aug 08 2016 06:59
hi yall, I've a question about push function
Markus Kiili
@Masd925
Aug 08 2016 07:00
@Knochenmark JSON is a text format for storing objects, and those FCC challenges have very little to do with actual JSON.
Sergio Salinas
@sergiosalfer
Aug 08 2016 07:00
why this function return me the value 3?
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  return arr.push(num);
}

getIndexToIns([40, 60], 50);
Giovanni
@spgiovanni
Aug 08 2016 07:00
<paste your code here>,
'''
CamperBot
@camperbot
Aug 08 2016 07:00
:bulb: to format code use backticks! ``` more info
Alexander Køpke
@alexanderkopke
Aug 08 2016 07:01
@sergiosalfer seems to return the length
peibowl
@peibowl
Aug 08 2016 07:01
hello eveybody
Sergio Salinas
@sergiosalfer
Aug 08 2016 07:01
how can i fix it?
Giovanni
@spgiovanni
Aug 08 2016 07:02
how do I paste my screen shot in the message forum?
peibowl
@peibowl
Aug 08 2016 07:02
When I run this, it shows "undefined" in the console for each element of numArr
```
  var numArr = [];
  numArr.push(num%10);
  num -= num%10;
  numArr.shift(num%100);
  num -= num%100;
  numArr.shift(num%1000);
  num -= num%1000;
  numArr.shift(num);
  console.log(numArr[0], numArr[1], numArr[2], numArr[3]);
Darth Skywalker
@adityaparab
Aug 08 2016 07:02
@sergiosalfer : The push function adds an element to the array and returns the length of the array after the element is pushed. You're returning arr.push(num); so it will return the length of arr after pushing a num into it.
Selvin Walter
@Selvin11
Aug 08 2016 07:02
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
arr.push(num);
return arr;
}
Sergio Salinas
@sergiosalfer
Aug 08 2016 07:03
@adityaparab thanks
CamperBot
@camperbot
Aug 08 2016 07:03
sergiosalfer sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 518 | @adityaparab |http://www.freecodecamp.com/adityaparab
peibowl
@peibowl
Aug 08 2016 07:03
but if I use console.log("numArr: " + numArr[0]); it returns the right number
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:03
@peibowl what is num?
peibowl
@peibowl
Aug 08 2016 07:03
num is a number given to a function like myFunction(1987);
I'm trying to spread each number
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:03
@peibowl can you post your whole function?
peibowl
@peibowl
Aug 08 2016 07:04
1, 9, 8, 7
Markus Kiili
@Masd925
Aug 08 2016 07:04
@Knochenmark I have discussed the incorrect terminology of these JSON challenges on the curriculum development channel, so read from there if you need to continue this discussion.
Giovanni
@spgiovanni
Aug 08 2016 07:05
? ```

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
    case 1:
      answer = "alpha";
      break;

    case 2:
      answer="beta";
      break;

    case 3:
      answer="gamma";
      break;

    case 4:
      answer="delta";




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

// Change this value to test
caseInSwitch(1);
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:06
@spgiovanni Your switch statement is missing
Giovanni
@spgiovanni
Aug 08 2016 07:06
need help I that my syntax is off
@Billy5500 ok I'll try that but it still wasn't working with it
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:07
switch (x) {

  case 1:
    console.log("x is 1");
    break;
  ...}
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:08
@spgiovanni you also need brackets
switch (x) {
  ...
}
Giovanni
@spgiovanni
Aug 08 2016 07:09

function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
   switch(x){

     case 1:
      answer = "alpha";
      break;

    case 2:
      answer="beta";
      break;

    case 3:
      answer="gamma";
      break;

    case 4:
      answer="delta";

   }


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

// Change this value to test
caseInSwitch(1);
dalbergiaretusa
@dalbergiaretusa
Aug 08 2016 07:09
I have a problem with adding objects to an array, could you help me?
Mark Todd
@Knochenmark
Aug 08 2016 07:09
@spgiovanni should be switch(val)
Tilak Raj
@trdhiman
Aug 08 2016 07:09
hi friends , In "Mutation" basic algorithm ,
my function passes all the tests except first one <
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:09
@dalbergiaretusa array.push(value);
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:09
@spgiovanni We showed switch(x) as an example, not within your program
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:10
@dalbergiaretusa in this case, value would be an object
Tilak Raj
@trdhiman
Aug 08 2016 07:10
where i am going wrong ??

function mutation(arr) {
var firstPart = arr[0].toLowerCase() ;
var secondPart = arr1.toLowerCase();
for (var i = 0 ; i < secondPart.length; i++){
if(firstPart.indexOf (secondPart[i]) !== -1 ) {

return true ;
}
else{
return false ;
}
}
}

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

peibowl
@peibowl
Aug 08 2016 07:10
here is the whole code:
`
function convertToRoman(num) {
  var numbers = {
    1: "I", 2: "II", 3: "III", 4: "IV", 5: "V", 6: "VI", 7: "VII", 8: "VIII", 9:"IX",
    10: "X",20: "XX", 30:"XXX", 40:"XL", 50:"L", 60:"LX", 70:"LXX2", 80:"LXXX", 90:"XC",
    100:"C", 200:"CC", 300:"CCC", 400:"CD", 500:"D", 600:"DC", 700:"DCC", 800:"DCCC", 900:"CM",
    1000:"M", 2000: "MM", 3000:"MMMM"
  };
  var numArr = [];
  numArr.push(num%10);
  num -= num%10;
  numArr.shift(num%100);
  num -= num%100;
  numArr.shift(num%1000);
  num -= num%1000;
  numArr.shift(num);
  console.log(numArr[0], numArr[1], numArr[2], numArr[3]);

  return num;
}
Giovanni
@spgiovanni
Aug 08 2016 07:11
@Billy5500 @Knochenmark Thanks that worked I won't so how long I was on this one challenge lol.
CamperBot
@camperbot
Aug 08 2016 07:11
spgiovanni sends brownie points to @billy5500 and @knochenmark :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @billy5500 |http://www.freecodecamp.com/billy5500
:cookie: 395 | @knochenmark |http://www.freecodecamp.com/knochenmark
Manjot Singh
@msingh18
Aug 08 2016 07:11
Anyone who has completed the LocalWeather Challenge here?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:11
Glad to help! Keep it up!
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:11
@spgiovanni good luck
Giovanni
@spgiovanni
Aug 08 2016 07:12
@jarenescueta731 thx again u2
CamperBot
@camperbot
Aug 08 2016 07:12
spgiovanni sends brownie points to @jarenescueta731 :sparkles: :thumbsup: :sparkles:
:cookie: 348 | @jarenescueta731 |http://www.freecodecamp.com/jarenescueta731
Mark Todd
@Knochenmark
Aug 08 2016 07:12
@peibowl whats wrong?
peibowl
@peibowl
Aug 08 2016 07:13
when I show in the console the values stored in numArr, it throws undefined, undefined, undefined, undefined
instead of each number
Mark Todd
@Knochenmark
Aug 08 2016 07:13
@peibowl yeah, you need to check in which range the numbers are, because thousands are undefined if the number is smaller than 1000
peibowl
@peibowl
Aug 08 2016 07:13
I've checked that using the % operator and working with the num variable, I get the right values
@Knochenmark how is that??
Where can I read about that?
Mark Todd
@Knochenmark
Aug 08 2016 07:14
@peibowl iam pretty close to your approach, just check for example if num<10 then you dont need to handle hundreds and thousands only ones
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:15
@peibowl Let's say num is 100,
peibowl
@peibowl
Aug 08 2016 07:15
yeah, but I want to fill the whole numArr to do the translation to roman later
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:15
numArr.push(num%10); //0 therefore you are not pushing anything
Mark Todd
@Knochenmark
Aug 08 2016 07:15
@peibowl or maybe just dont concatinate when the value is undefined?
peibowl
@peibowl
Aug 08 2016 07:16
always from 4 numbers, although the number is 0
Manjot Singh
@msingh18
Aug 08 2016 07:16
@Knochenmark the JSON request is not going through Codepen when I use http:// but if I use https:// the openweather api won't respond. Is this a known bug?
Mark Todd
@Knochenmark
Aug 08 2016 07:16
@peibowl or filter your array of undefined
peibowl
@peibowl
Aug 08 2016 07:16
Ok got it, gonna ive it a rethink
thanks @Knochenmark and @Billy5500
CamperBot
@camperbot
Aug 08 2016 07:17
peibowl sends brownie points to @knochenmark and @billy5500 :sparkles: :thumbsup: :sparkles:
:cookie: 396 | @knochenmark |http://www.freecodecamp.com/knochenmark
:cookie: 306 | @billy5500 |http://www.freecodecamp.com/billy5500
Mark Todd
@Knochenmark
Aug 08 2016 07:17
@msingh18 i think thats some policy thing from codepen to prevent crosssite scripting
Manjot Singh
@msingh18
Aug 08 2016 07:17
@Knochenmark then how does one complete that challenge?
Mark Todd
@Knochenmark
Aug 08 2016 07:17
@msingh18 i dont know, havnt started than one yet :D
Manjot Singh
@msingh18
Aug 08 2016 07:18
I see the example code is working fine
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:18
@peibowl You've created an object with all roman numbers but you are not using it as far as I can see
Mark Todd
@Knochenmark
Aug 08 2016 07:18
@Billy5500 thats his next step
Manjot Singh
@msingh18
Aug 08 2016 07:18
@Knochenmark oh all right, thanks for your help
CamperBot
@camperbot
Aug 08 2016 07:18
msingh18 sends brownie points to @knochenmark :sparkles: :thumbsup: :sparkles:
:warning: msingh18 already gave knochenmark points
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:19
@Knochenmark Yeah but he doesn't even need any of the code he has written so far except that object
Solomon B
@ssbothwell
Aug 08 2016 07:20
i'm on the show local weather exercise. I'm having trouble pulling the data from the openweathermap api into javascript. whats wrongwith this code? nothing is loading in the console.
$(document).ready(function() {
$.getJSON("api.openweathermap.org/data/2.5/weather?lat=34.0647706&lon=-118.2376252&mode=json&APPID=0e9190dabd49647b32b3110e8b65664a", function(json) {
console.log(json);
});
});
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:20
@trdhiman still there? you said all the cases work except the first one?
Coy Sanders
@coymeetsworld
Aug 08 2016 07:20
api call is through http @ssbothwell
you need to add the protocol to your URL
Solomon B
@ssbothwell
Aug 08 2016 07:21
ooh derp
@coymeetsworld thanks
CamperBot
@camperbot
Aug 08 2016 07:21
ssbothwell sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1302 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Aug 08 2016 07:21
no problem
Tilak Raj
@trdhiman
Aug 08 2016 07:22
yes brother
Solomon B
@ssbothwell
Aug 08 2016 07:22
hmm still nothing showing up in console
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:22
@ssbothwell I used crossorigin.me, it's really easy
Solomon B
@ssbothwell
Aug 08 2016 07:24
ermm not sure what thats for to be honest
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:25
@ssbothwell Did you read through it?
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:25
@trdhiman the problem is that you only check if the first letter of secondPart exists in firstPart. when you return true or false, it ends the for loop. so it won't check the rest of the letters.
Solomon B
@ssbothwell
Aug 08 2016 07:25
yeah but i'm using a the openweathermap api which is supposed to be accessible by developers?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:26
@ssbothwell Just append it to the beginning of the json call url
@ssbothwell It's served over http, and codepen is in https, therefore it won't work
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:26
@trdhiman since "h" of hey is also in hello, it says true
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:26
@ssbothwell Unless you do what I suggested
Tilak Raj
@trdhiman
Aug 08 2016 07:26
so what to do ??
Solomon B
@ssbothwell
Aug 08 2016 07:27
ooh ok i'll try it
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:27
@ssbothwell I can give you an example if you want
Solomon B
@ssbothwell
Aug 08 2016 07:27
oh that totally worked
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:27
@trdhiman you need to figure out how to check for all the letters of secondPart, and not end the for loop too early
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:27
@ssbothwell Nice! Good luck!
Solomon B
@ssbothwell
Aug 08 2016 07:28
funny that the FCC exercise didn't mention anything about that
@Billy5500 thanks again!
CamperBot
@camperbot
Aug 08 2016 07:28
ssbothwell sends brownie points to @billy5500 :sparkles: :thumbsup: :sparkles:
:cookie: 307 | @billy5500 |http://www.freecodecamp.com/billy5500
Tilak Raj
@trdhiman
Aug 08 2016 07:28
but i added for loop to check all the elements of second part ...
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:28
@ssbothwell Well, in the real world you're gonna have to dig deep sometimes
Solomon B
@ssbothwell
Aug 08 2016 07:28
true
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:29
@trdhiman but once it checks the first letter of secondPart, it returns true or false. the return ends the for loop prematurely
Gerren Jackson
@gerrenjj
Aug 08 2016 07:29
Hi everyone
Brandon
@Brandons42
Aug 08 2016 07:30
I am on Record Collection of Basic JavaScript and I'm having trouble with the "If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array." part. Anything I do creates an error saying it's not a function or "Cannot read property 'push' of undefined. Can anyone show me how to do this?
Subramanya Chakravarthy
@chakrihacker
Aug 08 2016 07:30
@gerrenjj hi
Gerren Jackson
@gerrenjj
Aug 08 2016 07:31
Can anyone help me with this>>>>>>

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line

Philip Orchard
@orshy
Aug 08 2016 07:31
@Brandons42 make sure you are using bracket notation
Jaren Escueta
@jarenescueta731
Aug 08 2016 07:31
@trdhiman the for loop doesn't go past secondPart[0]
Gerren Jackson
@gerrenjj
Aug 08 2016 07:31
You should assign processArg to processed
Brandon
@Brandons42
Aug 08 2016 07:31
@orshy I am.
Subramanya Chakravarthy
@chakrihacker
Aug 08 2016 07:32
@gerrenjj that's not full code
Gerren Jackson
@gerrenjj
Aug 08 2016 07:32
How do I assign processArg to processed?
Philip Orchard
@orshy
Aug 08 2016 07:32
can you share the code you are referencing?
Markus Kiili
@Masd925
Aug 08 2016 07:32
@Brandons42 You need to make a .hasOwnProperty() check before you push. If the tracks property is absent, you need to create the property.
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:32
@gerrenjj You mean how to call that function?
Gerren Jackson
@gerrenjj
Aug 08 2016 07:32
processed should have a value of 2 is already checked
yes
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:33
processArg(processed);
Gerren Jackson
@gerrenjj
Aug 08 2016 07:34
no
How do I assign processArg to processed
Brandon
@Brandons42
Aug 08 2016 07:34
@Masd925 I did that too.
Gerren Jackson
@gerrenjj
Aug 08 2016 07:34
thats the real question
Muhammad Hasham
@MohammadHasham
Aug 08 2016 07:35
can anyone help me with finding keepers please
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:35
@gerrenjj You mean give processed the value of the function processArg?
Gerren Jackson
@gerrenjj
Aug 08 2016 07:36
@Billy5500 no it says>>>>>> You should assign processArg to processed
Vatsal Pande
@vatsalpande
Aug 08 2016 07:36
Hi.. just finished missing letter exercise .. Can someone suggest a better solution if possible?
```
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:36
@gerrenjj Please give more information and paste your whole code, properly formatted put around your code```
Vatsal Pande
@vatsalpande
Aug 08 2016 07:36
function fearNotLetter(str) {
  var lastValue, currentValue, missingString;
  str.split("").forEach(function(item){
  currentValue = item.charCodeAt(0);
  if(!missingString && lastValue && currentValue -lastValue >1){
    missingString = String.fromCharCode(currentValue -1 );
  }
  lastValue = currentValue;
});
return missingString;
}
Gerren Jackson
@gerrenjj
Aug 08 2016 07:37
How do I snapshot it like that?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:37
wiki code format
CamperBot
@camperbot
Aug 08 2016 07:37

: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

Gerren Jackson
@gerrenjj
Aug 08 2016 07:37
i just copy n paste the code here

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line

Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:37
nooo
wiki code format
CamperBot
@camperbot
Aug 08 2016 07:37

: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

Gerren Jackson
@gerrenjj
Aug 08 2016 07:38
@Billy5500 never did that b4.. How do I switch it
Brandon
@Brandons42
Aug 08 2016 07:39
My code for that little section is ``` else if (prop == "tracks" && value !== "") {
collection[id][prop].push(value);
return collection;
Gerren Jackson
@gerrenjj
Aug 08 2016 07:39
ok i see
Brandon
@Brandons42
Aug 08 2016 07:39
Sorry pressed enter before shift.
My code for that little section is js else if (prop == "tracks" && value !== "") { collection[id][prop].push(value); return collection;My code for that little section is else if (prop == "tracks" && value !== "") {
collection[id][prop].push(value);
return collection;
Oops.
Gerren Jackson
@gerrenjj
Aug 08 2016 07:40
This message was deleted
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:41
@gerrenjj That's for single-line code, read for multi-line
Gerren Jackson
@gerrenjj
Aug 08 2016 07:41
@Billy5500 ok lemme see
Vatsal Pande
@vatsalpande
Aug 08 2016 07:42
function fearNotLetter(str) {
  var lastValue, currentValue, missingString;
  str.split("").forEach(function(item){
  currentValue = item.charCodeAt(0);
  if(!missingString && lastValue && currentValue -lastValue >1){
    missingString = String.fromCharCode(currentValue -1 );
  }
  lastValue = currentValue;
});
return missingString;
}
Can someone please review the missing letters exercise?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:42
@gerrenjj And is that all of your code? The last line says //only change code below this line
Gerren Jackson
@gerrenjj
Aug 08 2016 07:42
Type 3 backticks?
1p2r3a
@1p2r3a
Aug 08 2016 07:42

function golfScore(par, strokes) {
// Only change code below this line

if(strokes==1){
return "Hole-in-one!";

}
else if(strokes<=par-2){
return "Eagle";
}
else if(strokes==par-1){
return "Birdle";
}
else if(strokes==par){
return "par";
}
else if(strokes==par+1){
return "Bogey";
}
else if(strokes==par+2){
return "double Bogey";

}
else if(strokes>=par+3){
return "Go Home!";
}
else{
return "Change Me";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

Gerren Jackson
@gerrenjj
Aug 08 2016 07:43
@Billy5500 yeah thats it
1p2r3a
@1p2r3a
Aug 08 2016 07:43
any one find the error
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:43
@gerrenjj Yeah surround your code with three backticks
Muhammad Hasham
@MohammadHasham
Aug 08 2016 07:43
can anyone help me with finding keepers please?
@gerrenjj @1p2r3a @Billy5500 @vatsalpande @Brandons42
Gerren Jackson
@gerrenjj
Aug 08 2016 07:43
@Billy5500 backtick button?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:44
@gerrenjj Should be under the escape (esc) button on your keyboard
Gerren Jackson
@gerrenjj
Aug 08 2016 07:44
@Billy5500 ok ill try it
Muhammad Hasham
@MohammadHasham
Aug 08 2016 07:45
function findElement(arr, func) {
  var num = [];
  //return arr;
  var top = arr.join('');
  for (var i=0;i<arr.length;i++)
    {
      if (top[i]%2===0)
        {
          num.push(top[i]);
        }
    }
  return num.toString();
}

findElement([1, 3, 5, 8,9,10], 
function(num){ 
return num % 2 === 0; });
why is this not working?
Gerren Jackson
@gerrenjj
Aug 08 2016 07:45
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:45
Nice
That's what I'm talking about
Gerren Jackson
@gerrenjj
Aug 08 2016 07:45
@Billy5500 lol
@Billy5500 processed should have a value of 2
You should assign processArg to processed
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:46
@gerrenjj What exercise is that?
Gerren Jackson
@gerrenjj
Aug 08 2016 07:46
@Billy5500 Assignment with a Returned Value
1p2r3a
@1p2r3a
Aug 08 2016 07:46

function golfScore(par, strokes) {
// Only change code below this line

if(strokes==1){
return "Hole-in-one!";

}
else if(strokes<=par-2){
return "Eagle";
}
else if(strokes==par-1){
return "Birdle";
}
else if(strokes==par){
return "par";
}
else if(strokes==par+1){
return "Bogey";
}
else if(strokes==par+2){
return "double Bogey";

}
else if(strokes>=par+3){
return "Go Home!";
}
else{
return "Change Me";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 4);

find the error in this guys
CamperBot
@camperbot
Aug 08 2016 07:46
find the error in this guys
nothing found
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:47
@gerrenjj Read the instructions again, Call the processArg function with an argument of 7 and assign its return value to the variable processed.
Nupur Roy
@nupur06cherish
Aug 08 2016 07:47
i am stuck in the chunky monkey problem...here is my code

function chunkArrayInGroups(arr, size) {
// Break it up.
var i,temp=[],temp1=[];
while(arr.length > 0)
{
for(i=0;i<size;i++)
{
temp.push(arr[i]);
}
temp1.push(temp);
arr.splice(0,size);
}
arr=temp1;
return arr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);

Gerren Jackson
@gerrenjj
Aug 08 2016 07:48
@Billy5500 ok
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:48
@gerrenjj So you need a variable, it needs to have the name processed
Gerren Jackson
@gerrenjj
Aug 08 2016 07:48
var processed;
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 07:48
@gerrenjj And it's value should be the processArg function with an argument of 7
Brb, that should work, just follow the examples
Gerren Jackson
@gerrenjj
Aug 08 2016 07:49
@Billy5500 ok
Muhammad Hasham
@MohammadHasham
Aug 08 2016 07:52
just a small help needed please
Nupur Roy
@nupur06cherish
Aug 08 2016 07:52

@nupur06cherish
i am stuck in the chunky monkey problem...here is my code
function chunkArrayInGroups(arr, size) {
// Break it up.
var i,temp=[],temp1=[];
while(arr.length > 0)
{
for(i=0;i<size;i++)
{
temp.push(arr[i]);
}
temp1.push(temp);
arr.splice(0,size);
}
arr=temp1;
return arr;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);

Gerren Jackson
@gerrenjj
Aug 08 2016 07:55
This message was deleted
This message was deleted
// Example
var changed = 0;

function change(num) {
  return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
function processArg(7) {
 var processed; 
}
It isn't acting right....ugh
that 7 is giving me a red X
stonefmagiecurata
@stonefmagiecurata
Aug 08 2016 08:01
@gerrenjj you have to call the function processArg() and assign its return value to the processed variable
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:01
var processed = processArg(7); //we're calling the function processArg, giving it an argument of 7 and assigning it to the 'processed' variable
stonefmagiecurata
@stonefmagiecurata
Aug 08 2016 08:01
@gerrenjj just like in the example they gave above
Markus Kiili
@Masd925
Aug 08 2016 08:01
@nupur06cherish You need to initialize temp on the start of while loop and also make a check on i that there are elements left before you push arr[i]. You can also make it on the loop condition.
Gerren Jackson
@gerrenjj
Aug 08 2016 08:02
@stonefmagiecurata @Billy5500 ok
@stonefmagiecurata @Billy5500 Got it!
stonefmagiecurata
@stonefmagiecurata
Aug 08 2016 08:04
@gerrenjj :+1:
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:04
@Masd925 can you help me on "Drop it" challenge?
Gerren Jackson
@gerrenjj
Aug 08 2016 08:05
Thank you >>>>@stonefmagiecurata @Billy5500<<<<< Brownie pointZZZ
CamperBot
@camperbot
Aug 08 2016 08:05
gerrenjj sends brownie points to @stonefmagiecurata and @billy5500 :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @stonefmagiecurata |http://www.freecodecamp.com/stonefmagiecurata
:cookie: 308 | @billy5500 |http://www.freecodecamp.com/billy5500
Markus Kiili
@Masd925
Aug 08 2016 08:05
@MohammadHasham Have to go to dinner now. If you still have the problem later, I can help.
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:05
@gerrenjj Keep it up!
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:05
@Masd925 no prob!
anyone else ? there?
NixonRichard
@NixonRichard
Aug 08 2016 08:06
hmm
Gerren Jackson
@gerrenjj
Aug 08 2016 08:06
@Billy5500 Yezzir
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:06

function dropElements(arr, func) {
  var b=  [];
  for (var i=0;i<arr.length;i++)
    {
      if (func[arr[i]])
        {
          b.push(arr[i]);
        }
    }
  return b;

}
function test(value)
{
  return value >= 3; 
}

dropElements([1, 2, 3],test);
why is it returning an empty array
NixonRichard
@NixonRichard
Aug 08 2016 08:06
cuz u return b
b s an empty array
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:07
but elements are being pushed into that?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:07
@MohammadHasham Are they?
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:07
like b.push(arr[i])
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:07
@MohammadHasham Are you sure they are?
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:07
yes they should actually!
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:07
@MohammadHasham Use console.log to check but since you return an empty array, obviously b didn't change since you initialized it.
NixonRichard
@NixonRichard
Aug 08 2016 08:08
ur code s kind of over complex @MohammadHasham
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:09
@NixonRichard it was there to use the function in the challenge
@Billy5500 but why are the elements not being pushed in b
NixonRichard
@NixonRichard
Aug 08 2016 08:09
 if (func[arr[i]])
what does this part mean ?
fucnt == arr[i] ?
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:10
@NixonRichard it means that if a particular element in test function gets matched
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:10
Yeah, you're accessing a function as it's an array
You provide arguments within parenhteses, not brackets
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:10
@NixonRichard its like if (test(element))
@Billy5500 Where?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:11
On the line @NixonRichard posted
NixonRichard
@NixonRichard
Aug 08 2016 08:12
what s the challenge s name anyway ?
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:12
func(a); //not func[a]
'Drop it', I just did it yesterday
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:12
@NixonRichard drop it
@Billy5500 passing 3/5
2 challenges are still not being passed that worked but changing brackets to parantheisis
any further help please @NixonRichard @Billy5500
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:14
Ok, I'll give you a hint: You need to remove elements from arr until funcreturn true. After that, everything stays the same.
As the instructions point too.
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:16
@NixonRichard sorry! but can you elaborate
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:16
Iterate through the array, add an if statement that checks if func returns true. If it does, slice all arr elements until the one you're currently on. Return arr;
If the whole iteration goes through and func never returns true, return []; (an empty array)
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:17
@NixonRichard okay ill check that
function dropElements(arr, func) {
  var b =  [];
  for (var i=0;i<arr.length;i++)
    {
      if (func===true)
        {
          arr.slice(arr[i]);
        }
      else
        {
          return [];
        }
      if (func(arr[i]))
        {
          b.push(arr[i]);
        }
    }

  return b;

}
function test(value)
{
  return value >= 3; 
}

dropElements([1, 2, 3],test);
@Billy5500 made some changes !
are there any further changes i need to make @Billy5500
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:21
Okay, a few changes:
You don't need b anymore. Delete it.
You only need an if statement in your for loop, remember the code in the code block executes for each element arr
So
if (func(arr[i])){
  arr = arr.slice(i);
  return arr;
}
@MohammadHasham That's all the checking you need in your for loop.
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:24
@Billy5500 Thanks
CamperBot
@camperbot
Aug 08 2016 08:24
mohammadhasham sends brownie points to @billy5500 :sparkles: :thumbsup: :sparkles:
:cookie: 309 | @billy5500 |http://www.freecodecamp.com/billy5500
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:24
but how do i return an empty array
outside for loop
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:24
Yeah, it's pretty simple
Enoch Johnson
@Enocholas
Aug 08 2016 08:24

function myLocalScope() {
var loc = "myVar";

console.log();
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope

// Now remove the console log line to pass the test

can anybody help me with Local Scope and Functions. Not sure what im doing wrong

Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:24
You know that if we return during the execution of a function, the code below never executes, right?
Muhammad Hasham
@MohammadHasham
Aug 08 2016 08:24
@Billy5500 Thanks
CamperBot
@camperbot
Aug 08 2016 08:24
mohammadhasham sends brownie points to @billy5500 :sparkles: :thumbsup: :sparkles:
:warning: mohammadhasham already gave billy5500 points
Bilyan Hadzhi
@bilyanhadzhi
Aug 08 2016 08:25
@MohammadHasham So, all you have to do is add a return []; right at the end of your function.
@MohammadHasham We will get to that line only if the for loop executes for all elements in the array and we never return arr;
@MohammadHasham Hope that helps!
JavarriL
@JavarriL
Aug 08 2016 08:34


function mutation(arr) {
  var c;
  arr[1] = arr[1].toLowerCase();
  arr[1] = arr[1].split('');
  arr[0] = arr[0].toLowerCase();
for(var i = 0; i < arr[1].length; i++) {
  c = arr[0].indexOf(arr[1][i]);

    if (c >= 0) {
    return true;
  } else if (c === -1) {
    return false;
  }
}


  return c;
}

mutation(["hello", "hey"]);
"Mutations". Why is this code not working? The only test that didn't pass was the first one, but when I took off the if statements and saw what c returned, it returned -1, which means that it would return false with the if statements. Can someone shed some light?
If I put the if statements outside of the loop the last two tests fail
Better question: Do you think this is a possible solution? if I create c as an array and push the indexOf onto that array then do the if statements
Islam Ibakaev
@dagman
Aug 08 2016 08:40
hey guys why pomodoro timer doesn't start immidiately?
@JavarriL you get returned true after first match (in your case h) and immidiately quit function losing an opportunity to check other two letters
jamesmillerho
@jamesmillerho
Aug 08 2016 08:45

@JavarriL

if (c >= 0) {
return true;

return will stop the loop..

Islam Ibakaev
@dagman
Aug 08 2016 08:46
@JavarriL i believe you can utillize .every() method to check for all letters
@jamesmillerho not only loop but quit function execution
jamesmillerho
@jamesmillerho
Aug 08 2016 08:47
@JavarriL solution is simple: if it doesn't return false after the whole loop, then return true
yes
Islam Ibakaev
@dagman
Aug 08 2016 08:47
@jamesmillerho it is exactly what .every() does :smile:
jamesmillerho
@jamesmillerho
Aug 08 2016 08:48
lol
NixonRichard
@NixonRichard
Aug 08 2016 08:48
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var newArr =  arr.push(num);

  return newArr;
}

getIndexToIns([40, 60], 50);
JavarriL
@JavarriL
Aug 08 2016 08:48

function mutation(arr) {
  var c = [];
  var d;
  arr[1] = arr[1].toLowerCase();
  arr[1] = arr[1].split('');
  arr[0] = arr[0].toLowerCase();
for(var i = 0; i < arr[1].length; i++) {
  d = arr[0].indexOf(arr[1][i]);
  c.push(d);

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

  if (c[c.length - 1] >= 0) {
    return true;
  } else if (c[c.length - 1] === -1) {
    return false;
  }

  return c[c.length - 1];
}

mutation(["hello", "hey"]);
I figured it out, but there has to be a simpler way. Can anyone show me how this can be simpler?
NixonRichard
@NixonRichard
Aug 08 2016 08:48
anyone know why this return 3 ?
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var newArr =  arr.push(num);

  return newArr;
}

getIndexToIns([40, 60], 50);
JavarriL
@JavarriL
Aug 08 2016 08:49
@jamesmillerho @dagman Thanks
CamperBot
@camperbot
Aug 08 2016 08:49
javarril sends brownie points to @jamesmillerho and @dagman :sparkles: :thumbsup: :sparkles:
:cookie: 369 | @jamesmillerho |http://www.freecodecamp.com/jamesmillerho
:cookie: 625 | @dagman |http://www.freecodecamp.com/dagman
JavarriL
@JavarriL
Aug 08 2016 08:50
@jamesmillerho Oh so flip the if statements to return false first, that makes sense
Islam Ibakaev
@dagman
Aug 08 2016 08:52