These are chat archives for FreeCodeCamp/HelpJavaScript

27th
Jun 2016
FM
@mafelix
Jun 27 2016 00:01
use the tool that's appropriate for the task.
and in the way you know how to use the tool.
I think you'll never fall aways from for loops in javascript
Alando
@Landoghini
Jun 27 2016 00:02
How can I make this return true ?

function isLess(a, b) {
// Fix this code
return a===b;
}

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

uniforlyff
@uniforlyff
Jun 27 2016 00:02
isLess(15, 15)
CX
Alando
@Landoghini
Jun 27 2016 00:03
yes lol but it wants isLess(10,15) to return true
uniforlyff
@uniforlyff
Jun 27 2016 00:03
return a !== b
FM
@mafelix
Jun 27 2016 00:03
so what you're comparing with a === b
is you're saying does a equal b
what unifor said is fucking wrong too
uniforlyff
@uniforlyff
Jun 27 2016 00:04
no
FM
@mafelix
Jun 27 2016 00:04
what you're saying in his code
uniforlyff
@uniforlyff
Jun 27 2016 00:04
10 !== 15
FM
@mafelix
Jun 27 2016 00:04
is a not equal to b
uniforlyff
@uniforlyff
Jun 27 2016 00:04
would be true
FM
@mafelix
Jun 27 2016 00:04
that's not what he wanted
uniforlyff
@uniforlyff
Jun 27 2016 00:04
isLess(10, 15)
FM
@mafelix
Jun 27 2016 00:04
tell me what you're comparing
uniforlyff
@uniforlyff
Jun 27 2016 00:04
omg
FM
@mafelix
Jun 27 2016 00:04
what was his question
Alando
@Landoghini
Jun 27 2016 00:05
isLess(10,15) should return true
isLess(15,10) should return false
You should not use any if or else statements
uniforlyff
@uniforlyff
Jun 27 2016 00:05
function isLess(a, b) {
  // Fix this code
 return a===b;
}

// Change these values to test
isLess(10,15);
FM
@mafelix
Jun 27 2016 00:05
a !== b
uniforlyff
@uniforlyff
Jun 27 2016 00:05
for isLess(10, 15) to be true
FM
@mafelix
Jun 27 2016 00:05
is NOT what the problem is asking
uniforlyff
@uniforlyff
Jun 27 2016 00:05
yes but waht he wanted was
Egoscio
@Egoscio
Jun 27 2016 00:05
return a < b
FM
@mafelix
Jun 27 2016 00:05
^
you're really on my nerves man
Alando
@Landoghini
Jun 27 2016 00:06
I need isLess(10,15) to be true and isLess(15,10) to be false
FM
@mafelix
Jun 27 2016 00:06
you tell some bs that is not good for others learning
uniforlyff
@uniforlyff
Jun 27 2016 00:06
@mafelix omg you piss me off
FM
@mafelix
Jun 27 2016 00:06
good
cuz you're retarded
uniforlyff
@uniforlyff
Jun 27 2016 00:06
you're retarted
FM
@mafelix
Jun 27 2016 00:06
sure thing buddy
Egoscio
@Egoscio
Jun 27 2016 00:06
Why is this community so toxic?
FM
@mafelix
Jun 27 2016 00:07
that's why you tell him to use not equal compare
Egoscio
@Egoscio
Jun 27 2016 00:07
Calm down and code guys.
uniforlyff
@uniforlyff
Jun 27 2016 00:07
there were ways for ti to work
FM
@mafelix
Jun 27 2016 00:07
dude
Alando
@Landoghini
Jun 27 2016 00:07
when i use != it makes isLess(10,15) true but isLess(15,10) is still false
FM
@mafelix
Jun 27 2016 00:07
whats the function supposed to do
uniforlyff
@uniforlyff
Jun 27 2016 00:07
dude basically this malefix
FM
@mafelix
Jun 27 2016 00:07
whats the exercise asking him to do?
Alando
@Landoghini
Jun 27 2016 00:07
Returning Boolean Values from Functions
is the name of the exercise
FM
@mafelix
Jun 27 2016 00:07
and what are you comparing?
find returning boolean values from functions
CamperBot
@camperbot
Jun 27 2016 00:07

find returning boolean values from functions

:zero: challenge returning boolean values from functions

Xander Apponi
@xapponi
Jun 27 2016 00:08
Hey, so, when you run a sort function on strings, it will sort them by alphebetical order. Is there a way to access that "alphebetical index". I'm working on Caesar's Cipher and was wondering if I could use this to help. Thanks :)
FM
@mafelix
Jun 27 2016 00:08
the function is named isLess
Egoscio
@Egoscio
Jun 27 2016 00:08
If your function is named isLess, and you're giving it an equality comparison, then I don't know what you're doing.
FM
@mafelix
Jun 27 2016 00:08
exactly
greg
@wearenotgroot
Jun 27 2016 00:08
@Landoghini read the function name, it should tell you what is supposed to do. --------> isLess
uniforlyff
@uniforlyff
Jun 27 2016 00:08
he's just testing for a match
FM
@mafelix
Jun 27 2016 00:09
this is the first time someone's pissed me off with their balent ignorance on codecamp
uniforlyff
@uniforlyff
Jun 27 2016 00:09
@mafelix you already piss me off since i first saw your damn face
FM
@mafelix
Jun 27 2016 00:09
good my previous statement stands
you're retarded
greg
@wearenotgroot
Jun 27 2016 00:09
come on guys
uniforlyff
@uniforlyff
Jun 27 2016 00:09
same
FM
@mafelix
Jun 27 2016 00:09
and you're telling him things that won't help him
greg
@wearenotgroot
Jun 27 2016 00:09
this is not the place
Alando
@Landoghini
Jun 27 2016 00:09
Thanks lol I was following the instructions and they used a the equal symbol
uniforlyff
@uniforlyff
Jun 27 2016 00:09
@mafelix omg he wanted it to compare
since he was using ===
@Landoghini see
Alando
@Landoghini
Jun 27 2016 00:10
thanks @mafelix and @uniforlyff no more fighting lol
CamperBot
@camperbot
Jun 27 2016 00:10
landoghini sends brownie points to @mafelix and @uniforlyff :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @mafelix |http://www.freecodecamp.com/mafelix
:cookie: 336 | @uniforlyff |http://www.freecodecamp.com/uniforlyff
uniforlyff
@uniforlyff
Jun 27 2016 00:10
@mafelix stupid f
Xander Apponi
@xapponi
Jun 27 2016 00:10
Hey, so, when you run a sort function on strings, it will sort them by alphebetical order. Is there a way to access that "alphebetical index". I'm working on Caesar's Cipher and was wondering if I could use this to help. Thanks :)
FM
@mafelix
Jun 27 2016 00:11
charcode I think is what you're looking for
greg
@wearenotgroot
Jun 27 2016 00:12
@xapponi ------>http://www.asciitable.com/
Xander Apponi
@xapponi
Jun 27 2016 00:13
Thanks @wearenotgroot @mafelix
CamperBot
@camperbot
Jun 27 2016 00:13
xapponi sends brownie points to @wearenotgroot and @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 306 | @mafelix |http://www.freecodecamp.com/mafelix
:star2: 1172 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Egoscio
@Egoscio
Jun 27 2016 00:19
So is this channel dedicated to FCC, or can you ask/answer general JS/Web questions as well?
uniforlyff
@uniforlyff
Jun 27 2016 00:19
can be anything i think
FM
@mafelix
Jun 27 2016 00:20
there are specific rooms
if it's a specific question that has a room then I would say go join that room.
the freecodecamp channel talks about anything and everything
usually the people in the javascript chat are having problems with the exercises that is javascript
don't think too hard. you'll hurt yourself
Egoscio
@Egoscio
Jun 27 2016 00:21
Ah, gotcha. Just checked, and there's a ton of rooms.
FM
@mafelix
Jun 27 2016 00:22
ya glgl
someone needs to implement a block user in gitter
uniforlyff
@uniforlyff
Jun 27 2016 00:23
lol
FM
@mafelix
Jun 27 2016 00:23
this is websocket based?
has to be
can't be too hard
it's already half way there, if you can chat privately with someone then you can just block their socket.id
Europaradise
@europaradise
Jun 27 2016 00:30
This message was deleted
This message was deleted
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 00:36

Hey guys I need a bit of help with my code in 'Pig Latin' the following code is returning:
TypeError: str.join is not a function

Here is my code

`
for (var c = 0; c < consonants.length; c++) {

if (str[0] !== consonants[c]) {

  str = str.push('way');

  str = str.join(' ');

}

}
`

Sorry I pressed enter on accident

uniforlyff
@uniforlyff
Jun 27 2016 00:36
@HTMLNoob paste code :)
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 00:37
Just edited
Egoscio
@Egoscio
Jun 27 2016 00:37
Where did you declare str?
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 00:38
Its declared as a parameter
Its saying that something is wrong with str,join(' ') isnt a function;
Moisés Man
@moigithub
Jun 27 2016 00:38
@HTMLNoob push return something else.. not an array
Egoscio
@Egoscio
Jun 27 2016 00:38
Well that means str isn't an array.
Moisés Man
@moigithub
Jun 27 2016 00:39
acording to the documentation .. push return the LENGTH of the array
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 00:39
?
Moisés Man
@moigithub
Jun 27 2016 00:39
soo u replacing ur str value for a number
str.join<-- error (cuz str is no longer an array )
mdn.io/push <-- read the documentation :)
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 00:40

.push doesnt return the length of an array, it adds to the end of an array

The push() method adds one or more elements to the end of an array and returns the new length of the array. -MDN

oh :) nvm
thx @moigithub
CamperBot
@camperbot
Jun 27 2016 00:41
htmlnoob sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1545 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jun 27 2016 00:41
:P :+1:
DuyChip9901
@DuyChip9901
Jun 27 2016 00:44
help me
CamperBot
@camperbot
Jun 27 2016 00:44

:point_right: adding environment variables [wiki]

Adding Envirioment Variables in Windows

Via GUI

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

Via Command Line

Refer to this answer on Super User.

:pencil: read more about adding environment variables on the FCC Wiki

DuyChip9901
@DuyChip9901
Jun 27 2016 00:44
myVar = myVar should be change
but i write myVar = ++myVar ;
if i change that code it's wrong
Freinet Brutus
@freinet12
Jun 27 2016 00:46
hey guys, I'm working on the wikipedia viewer and I need help with my javascript code. when i search something in the search box, nothing shows up and if something does show up, it only lasts 2 seconds and it disappears. can anyone help me fix this problem?
Egoscio
@Egoscio
Jun 27 2016 00:46
myVar++ is like doing myVar = myVar + 1
DuyChip9901
@DuyChip9901
Jun 27 2016 00:48
if i change myVar + 1 ===> myVar++ it's wrong
uniforlyff
@uniforlyff
Jun 27 2016 00:49
@DuyChip9901 lets see your code :)
Egoscio
@Egoscio
Jun 27 2016 00:49
Yeah, without context it's somewhat difficult to imagine what's going on..
DuyChip9901
@DuyChip9901
Jun 27 2016 00:51

var myVar = 87;

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

uniforlyff
@uniforlyff
Jun 27 2016 00:51
is that all the code?
Brendan Kinahan
@BKinahan
Jun 27 2016 00:51
check the example in the instructions again :D
i++; is the entire line
Egoscio
@Egoscio
Jun 27 2016 00:52
Yeah, ++ does the redeclaration for you
Charles Bakar
@charlesBak
Jun 27 2016 00:53

hi guys can you please what is wrong with

function largestOfFour(arr) {
  // You can do this!
  var array = [];
   var array_1 = [];   
   for(var i = 0; i < arr.length; i++){
      for(var j = 0; j < arr[i].length; j++){
       array.push(arr[i][j]);
      }
     array.sort(function(a, b){
           return b - a;
      });
   array_1.push(array[0]);
   }

 return array_1;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])

stuck on the second test
Challenge : Return Largest Numbers in Arrays

Brendan Kinahan
@BKinahan
Jun 27 2016 00:54
maybe you mean to return array_1
Charles Bakar
@charlesBak
Jun 27 2016 00:55
@BKinahan ya you right
Egoscio
@Egoscio
Jun 27 2016 00:56
Does the challenge force you to go through all those hoops? Lazy me says use Math.max .-.
Charles Bakar
@charlesBak
Jun 27 2016 00:56
@BKinahan i tried it still not passed the second test
it gives me this output
[ 27, 27, 39, 1001 ]
@Egoscio i dont get it with the Math.max
i dont know why the second value is 27
azjgard
@azjgard
Jun 27 2016 01:04
Someone want to tell me what is wrong with this code?
var myStr = 'Here is a backslash: \.\n\t\tHere is a new line with two tabs';
Eleazar Resendez
@eleazarbr
Jun 27 2016 01:04
Excuse my impatience but i'm stuck in this:
var myStr = "Here is a backslash:\ . \n \t \t Here is a new line with two tabs.";
myStr isn't encoded with the proper espace sequences, spacing and it neet to have any space between consecutive escape sequences.
azjgard
@azjgard
Jun 27 2016 01:04
^^^^^
I'm stuck at the same point.
Eleazar Resendez
@eleazarbr
Jun 27 2016 01:05
:worried:
Charles Bakar
@charlesBak
Jun 27 2016 01:05
This message was deleted
azjgard
@azjgard
Jun 27 2016 01:07
Eleazar, I realized I was missing a space as a sentence.
Charles Bakar
@charlesBak
Jun 27 2016 01:07
@eleazarbr @azjgard the backslash is
Her...  : \\.\n\t\tHere...
azjgard
@azjgard
Jun 27 2016 01:08
@eleazarbr You're missing a backslash.
Egoscio
@Egoscio
Jun 27 2016 01:09
@charlesBak Is your function supposed to return a single number?
Charles Bakar
@charlesBak
Jun 27 2016 01:10
@Egoscio no it returns a Array of four elements
explanation is good
Eleazar Resendez
@eleazarbr
Jun 27 2016 01:12
@azjgard @charlesBak Thanks.. let's go ahead
CamperBot
@camperbot
Jun 27 2016 01:12
eleazarbr sends brownie points to @azjgard and @charlesbak :sparkles: :thumbsup: :sparkles:
:cookie: 149 | @azjgard |http://www.freecodecamp.com/azjgard
:cookie: 263 | @charlesbak |http://www.freecodecamp.com/charlesbak
FM
@mafelix
Jun 27 2016 01:13
Math.max is good.
You can also sort the subarrays and pluck on the last element of the sorted subarrays. It should be the biggest element sorted
Egoscio
@Egoscio
Jun 27 2016 01:15
Just curious, why is it return b - a;? Is that greatest to least? I usually do a - b. Never played around with it to see the difference.
FM
@mafelix
Jun 27 2016 01:16
Yea it is.
Egoscio
@Egoscio
Jun 27 2016 01:17
Oh okay. I was just blindly following a - b because a stack overflow post instructed that.
FM
@mafelix
Jun 27 2016 01:17
Maybe he wants to take first ele out instead.
azjgard
@azjgard
Jun 27 2016 01:17
Just curious, what are brownie points for?
uniforlyff
@uniforlyff
Jun 27 2016 01:18
@Egoscio you can also use < and >
FM
@mafelix
Jun 27 2016 01:18
Mdn is ur best bet egi
Ego
Egoscio
@Egoscio
Jun 27 2016 01:18
Yeah, I use MDN a lot. I wonder if I ever looked at it for sort.
Charles Bakar
@charlesBak
Jun 27 2016 01:18
@mafelix @Egoscio i sorted in ascendant order so i can take the first element of each subarray and put them together
FM
@mafelix
Jun 27 2016 01:19
Thats a good plan
So whats going wrong.
Charles Bakar
@charlesBak
Jun 27 2016 01:19
i still have to fiure out how to implement with Math.max
Egoscio
@Egoscio
Jun 27 2016 01:19
Well, does the challenge instruct you to use it?
FM
@mafelix
Jun 27 2016 01:19
Why do you need math max if youve sorted the arrays
Charles Bakar
@charlesBak
Jun 27 2016 01:20
@mafelix what wrong is that for the second test case it give me the output [27,27,39, 1001]
FM
@mafelix
Jun 27 2016 01:20
Take every first element and push it to an empty areay
Charles Bakar
@charlesBak
Jun 27 2016 01:20
so it did not sort the second subarray
FM
@mafelix
Jun 27 2016 01:20
Cant really look at ur code at gym on mobile
Thats strange.
Charles Bakar
@charlesBak
Jun 27 2016 01:21
@mafelix ya i did that
FM
@mafelix
Jun 27 2016 01:21
It sorts every array but the second array in the ssecond test
Diego Mayer
@Chrono79
Jun 27 2016 01:21
@charlesBak you're not reseting the max value
Charles Bakar
@charlesBak
Jun 27 2016 01:22
@mafelix yes that is right
FM
@mafelix
Jun 27 2016 01:22
Hmm
U dont need a max value
Sort ur arrays
Iterate over arr.
For every subarray push subarray0
Charles Bakar
@charlesBak
Jun 27 2016 01:23
@Chrono79 how do i reset it
FM
@mafelix
Jun 27 2016 01:23
To an empty array
Diego Mayer
@Chrono79
Jun 27 2016 01:23
let's see your code
Charles Bakar
@charlesBak
Jun 27 2016 01:24
@Chrono79 @mafelix
function largestOfFour(arr) {
  // You can do this!
  var array = [];
   var array_1 = [];   
   for(var i = 0; i < arr.length; i++){
      for(var j = 0; j < arr[i].length; j++){
       array.push(arr[i][j]);
      }
     array.sort(function(a, b){
           return b - a;
      });
     array_1.push(array[0]);
   }

 return array_1;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Egoscio
@Egoscio
Jun 27 2016 01:25
@charlesBak What does the challenge expect as the output?
FM
@mafelix
Jun 27 2016 01:25
Ok
Diego Mayer
@Chrono79
Jun 27 2016 01:25

@charlesBak

      for(var j = 0; j < arr[i].length; j++){
       array.push(arr[i][j]);
      }

You're steamrolling the array, building a new one with the elements of the each of the subarrays
Just sort the subarrays and do this array_1.push(array[0]);
Delete the steamroll part

FM
@mafelix
Jun 27 2016 01:26
From what I can see.
Charles Bakar
@charlesBak
Jun 27 2016 01:26
@Egoscio [27, 5, 39, 1001]
FM
@mafelix
Jun 27 2016 01:26
Ya what he said ure pushing elements without taking only biggest values
Pseudo code it.
Iterate over arr, iterate over subarrays. Sort subarrays b-a. Take every element of subarray 0 index and push into an answer array. Return answer
Charles Bakar
@charlesBak
Jun 27 2016 01:28
@mafelix this loop fill an array with all the elements of a subarray so i can sort them in the next loop
FM
@mafelix
Jun 27 2016 01:28
You dont need that.
It goes in sequence
Egoscio
@Egoscio
Jun 27 2016 01:29
@charlesBak I did this:
function largest (array) {
  return array.map(function (a) {
    return Math.max.apply({}, a)
  })
}
FM
@mafelix
Jun 27 2016 01:29
1 subarray 2 subarray so on and so forth
Diego Mayer
@Chrono79
Jun 27 2016 01:29
@charlesBak just iterate over arr, sort inner subarrays, and push the greatest value to array_1;
FM
@mafelix
Jun 27 2016 01:30
Ya
Egoscio
@Egoscio
Jun 27 2016 01:30
I inputed the array you provided and it gave me the expected output without doing backflips
FM
@mafelix
Jun 27 2016 01:30
Returb array 1 outside of loop
The way hes doing it is more manually.
Egoscio
@Egoscio
Jun 27 2016 01:30
indeed. is that required?
FM
@mafelix
Jun 27 2016 01:31
Math max I would say is a higher level function
The code inside math max is probably similar to what hes trying to do with for loops
Its not required
Charles Bakar
@charlesBak
Jun 27 2016 01:31
@Chrono79 how should i sort the inner subarray like this?
arr[i][j].sort(function(a, b) {
})
FM
@mafelix
Jun 27 2016 01:32
Some languages dont have higher level functions though
Diego Mayer
@Chrono79
Jun 27 2016 01:32
@charlesBak no, just arr[i].sort
Egoscio
@Egoscio
Jun 27 2016 01:32
Yeah, but in a realistic situation, wouldn't you just use Math.max instead of reinventing the wheel?
Well, maybe I'm missing the point. true.
FM
@mafelix
Jun 27 2016 01:32
Yea but he chose to do it his way
So lets help him finish it his way.
Egoscio
@Egoscio
Jun 27 2016 01:33
Sounds good
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:33
Can anyone help me solve an issue with my pig latin challenege? I can’t seem to get it working and i’ve been at it for a couple hours
Diego Mayer
@Chrono79
Jun 27 2016 01:34
@ConnHurr show your code
@charlesBak arr[i] is a subarray, you can sort it, arr[i][j] is a only a number, you can't sort that
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:35

Here is my code:


function translatePigLatin(str) {

  var vowels = ["a","e","i","o","u"];
  var split = str.split("");
  var count = 0;
  var last = "a";

  if (vowels.indexOf(split[0]) >= 0) {
    str = split.join("").concat("way");
  } else {
    console.log(split);
    for (var i = 0; i < split.length; i++) {
      console.log("split[i]: " + split[i]);
      if (vowels.indexOf(split[i]) >= 0) {
        //console.log(vowels.indexOf(split[i]));
        count++;
        break;

        //console.log(count);
      }
    }
    last = str.substr(0, count);
    console.log("last: " + last);
    split.splice(0, count);
    str = split.join("").concat(last).concat("ay");
  }

  console.log(str);
  return str;
}

translatePigLatin("glove");

I can’t get it to work for “glove” for some reason…

Egoscio
@Egoscio
Jun 27 2016 01:35
If you are posting code that is large use Gist - https://gist.github.com/
Diego Mayer
@Chrono79
Jun 27 2016 01:36
@ConnHurr lol at your output
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:37
haha yeah, but it should be oveglay I believe, but for whatever reason I can’t get it to move the constatnant chunk to the end, only the first one
but I went through my code, and I can’t figure it out :/
Diego Mayer
@Chrono79
Jun 27 2016 01:38
@ConnHurr wouldn't you have to count letters that are not vowels to know how many you have to move to the end?
FM
@mafelix
Jun 27 2016 01:39
/(@
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:40
@Chrono79 What i’m trying to do is look at the letters until it reaches a vowel, at that point it breaks out of the loop. Before that im incrementing count
unless thats not working as I was thinking
FM
@mafelix
Jun 27 2016 01:40
9t9444/54'555/0p0p00000099000p00099080990000009009999/090c00000
Diego Mayer
@Chrono79
Jun 27 2016 01:41

@ConnHurr

    for (var i = 0; i < split.length; i++) {
      console.log("split[i]: " + split[i]);
      if (vowels.indexOf(split[i]) < 0) { // with this if, you count letters that aren't vowels
        //console.log(vowels.indexOf(split[i]));
        count++;
        //console.log(count);
      } else break; // when it's a vowel, exit the loop
    }

Try this

Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:42
Nothing changes when I add that...
Diego Mayer
@Chrono79
Jun 27 2016 01:43
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:44
oh I didn’t see that you changed it to <0
Why would you change it to <0? sorry that confuses me
Diego Mayer
@Chrono79
Jun 27 2016 01:44
look at the comments
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:45
Oh so before I was incrementing ony when it was a vowel?
Diego Mayer
@Chrono79
Jun 27 2016 01:45
yes
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:46
Oh man I can’t believe it was that simple
thank you @Chrono79
CamperBot
@camperbot
Jun 27 2016 01:46
connhurr sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1320 | @chrono79 |http://www.freecodecamp.com/chrono79
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:46
I have one more question; are these challeneges supposed to be giving me this hard of a time? I seem to have to seek help for 90% of them, when I breezed through practically everything beforehand
James S.
@Mrblue27
Jun 27 2016 01:47

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
var processed = 2;
function processArg(num){

}

Diego Mayer
@Chrono79
Jun 27 2016 01:49
@ConnHurr I couldn't say, depends on your previous experience, amongst other things
James S.
@Mrblue27
Jun 27 2016 01:49

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
var processed = 2;
function processArg(num){

} Any idea of how do I assign processArg to processed

Charles Bakar
@charlesBak
Jun 27 2016 01:49

@mafelix @Egoscio @Chrono79 @uniforlyff

function largestOfFour(arr) {
  // You can do this!
    var array = [];
   var array_1 = [];   
   for(var i = 0; i < arr.length; i++){
      for(var j = 0; j < arr[i].length; j++){
       arr[i].sort(function(a, b){
           return b - a;
      });  

     }
     array_1.push(arr[i][0]);
  }
 return array_1;
}

largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

it is working

thanks you guys
Diego Mayer
@Chrono79
Jun 27 2016 01:50
@charlesBak :+1:
Charles Bakar
@charlesBak
Jun 27 2016 01:50
@uniforlyff @Chrono79 @Egoscio @mafelix much thanks you
CamperBot
@camperbot
Jun 27 2016 01:50
charlesbak sends brownie points to @uniforlyff and @chrono79 and @egoscio and @mafelix :sparkles: :thumbsup: :sparkles:
:cookie: 11 | @egoscio |http://www.freecodecamp.com/egoscio
:cookie: 337 | @uniforlyff |http://www.freecodecamp.com/uniforlyff
:star2: 1321 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 307 | @mafelix |http://www.freecodecamp.com/mafelix
Charles Bakar
@charlesBak
Jun 27 2016 01:50
you guys are awesome
Connor Hastey-Palindat
@cpalindat
Jun 27 2016 01:51
@Chrono79 well I mean I took 2 years of computer science in university before I dropped out so I feel like I should be getting these more easily
Diego Mayer
@Chrono79
Jun 27 2016 01:51

@Mrblue27

function processArg(num){
}

that's a function definition, not a function call

@ConnHurr try testing smaller parts then, so you're sure it works and then join them
@Mrblue27 look at the code example above the one you have to use
changed = change(10); that's how you assign the returned value of function change, given the value 10 to the var changed
Moisés Man
@moigithub
Jun 27 2016 02:01
@charlesBak u can remove the 2nd loop.. not doing anything with j
Charles Bakar
@charlesBak
Jun 27 2016 02:02
@moigithub ill try it now
@moigithub thank you now my code look much easier
CamperBot
@camperbot
Jun 27 2016 02:07
charlesbak sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1546 | @moigithub |http://www.freecodecamp.com/moigithub
Nick Neuman
@neecholaus
Jun 27 2016 02:16
hey can someone help me with the stand in line exercise for javascript?
Kris Blanchette
@Aurorikin
Jun 27 2016 02:18
I can't make sense of 162 Access MultiDimensional Arrays With Indexes at all. Can anyone explain that to me point my toward a resource so I can wrap my head around wtf
Diego Mayer
@Chrono79
Jun 27 2016 02:18
@neecholaus review the challenges about aray manipulating methods: pop, push, shift and unshift
Nick Neuman
@neecholaus
Jun 27 2016 02:19
no i know all those. i just figured it out i think i just spelled the return statement wrong or something
Diego Mayer
@Chrono79
Jun 27 2016 02:19
let's see your code then @neecholaus
Nick Neuman
@neecholaus
Jun 27 2016 02:20
blob
Diego Mayer
@Chrono79
Jun 27 2016 02:21
@neecholaus you could return arr.shift();
Nick Neuman
@neecholaus
Jun 27 2016 02:22
no that doesnt work.
@Chrono79
Moisés Man
@moigithub
Jun 27 2016 02:23
shifting twice ?
Diego Mayer
@Chrono79
Jun 27 2016 02:23
@neecholaus it should, you just don't have to call it twice
Charles Bakar
@charlesBak
Jun 27 2016 02:23
@neecholaus your first line is correct you dont need the second line
and just do var remove = arr.shift() and return remove
Kris Blanchette
@Aurorikin
Jun 27 2016 02:23
Is it possible to search the chat for questions that have already been asnwered?
Nick Neuman
@neecholaus
Jun 27 2016 02:25
@Chrono79 @moigithub okay so doing var removed = arr.shift() worked so does that give removed the value of the first element and actually remove it?
Charles Bakar
@charlesBak
Jun 27 2016 02:25
@neecholaus ya
Diego Mayer
@Chrono79
Jun 27 2016 02:26
@neecholaus arr.shift() returns the removed value, that's why I told you to just return that instead of using a var to store the value and then returning it
Nick Neuman
@neecholaus
Jun 27 2016 02:26
@Chrono79 @charlesBak okay sweet thanks guys
CamperBot
@camperbot
Jun 27 2016 02:26
neecholaus sends brownie points to @chrono79 and @charlesbak :sparkles: :thumbsup: :sparkles:
:star2: 1322 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 265 | @charlesbak |http://www.freecodecamp.com/charlesbak
Yi
@ycoding007
Jun 27 2016 02:26
hi, everyone, can you comment on my code for challenge "Check for Palindromes"

```function palindrome(str) {
str = str.toLowerCase().replace(/[^A-Za-z0-9]/g, '');
//http://stackoverflow.com/questions/26857934/regular-expression-val-replace-a-za-z0-9a-za-z0-9-g

//convert str to array, reverse all character in a new array, convert the reversed array to string
var array = str.split('');
var reverseArray = [];
for (var i=array.length-1;i>=0;i--){
reverseArray.push(array[i]);
}
var reverseStr = reverseArray.join('');

// compare original str with new str
if (str === reverseStr){
return true;
}
else {
return false;
}

}

palindrome("0_0 (: /-\ :) 0-0");```

Diego Mayer
@Chrono79
Jun 27 2016 02:27
This message was deleted
Yi
@ycoding007
Jun 27 2016 02:27
i forgot how to attach code block in comment...
Moisés Man
@moigithub
Jun 27 2016 02:28
shift enter after/before backticks
backticks must be on its own line
Yi
@ycoding007
Jun 27 2016 02:28

/
function palindrome(str) {
str = str.toLowerCase().replace(/[^A-Za-z0-9]/g, '');
//http://stackoverflow.com/questions/26857934/regular-expression-val-replace-a-za-z0-9a-za-z0-9-g

//convert str to array, reverse all character in a new array, convert the reversed array to string
var array = str.split('');
var reverseArray = [];
for (var i=array.length-1;i>=0;i--){
reverseArray.push(array[i]);
}
var reverseStr = reverseArray.join('');

// compare original str with new str
if (str === reverseStr){
return true;
}
else {
return false;
}

}
palindrome("0_0 (: /-\ :) 0-0");
/

Moisés Man
@moigithub
Jun 27 2016 02:29
ermm.. backticks
Diego Mayer
@Chrono79
Jun 27 2016 02:29
help format
CamperBot
@camperbot
Jun 27 2016 02:29

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Moisés Man
@moigithub
Jun 27 2016 02:30
ur code looks ok @ycoding007
Yi
@ycoding007
Jun 27 2016 02:30
function palindrome(str) {
  str = str.toLowerCase().replace(/[^A-Za-z0-9]/g, '');
  //http://stackoverflow.com/questions/26857934/regular-expression-val-replace-a-za-z0-9a-za-z0-9-g

  //convert str to array, reverse all character in a new array, convert the reversed array to string
  var array = str.split('');
  var reverseArray = [];
  for (var i=array.length-1;i>=0;i--){
    reverseArray.push(array[i]);
  }
  var reverseStr = reverseArray.join('');

   // compare original str with new str
   if (str === reverseStr){
     return true;
   }
  else {
    return false;
  }

}
palindrome("0_0 (: /-\ :) 0-0");
finally......sorry about that
i cheated on how to remove non alphanumeric characters...
Diego Mayer
@Chrono79
Jun 27 2016 02:31
@ycoding007 did you do that to reverse a string here: https://www.freecodecamp.com/challenges/reverse-a-string ?
Yi
@ycoding007
Jun 27 2016 02:32
@Chrono79 yes, I did this reverse string challenge as well
Diego Mayer
@Chrono79
Jun 27 2016 02:32
I mean, there is a shorter way of doing it
Moisés Man
@moigithub
Jun 27 2016 02:32

@ycoding007 another way to do this

var reverseArray = [];
for (var i=array.length-1;i>=0;i--){
reverseArray.push(array[i]);
}

is using the reverse method

Diego Mayer
@Chrono79
Jun 27 2016 02:33
@moigithub :+1:
and chaining methods it gets shorter @ycoding007
Moisés Man
@moigithub
Jun 27 2016 02:34
@ycoding007 also if (str === reverseStr){
this will be evaluated to a boolean...
so u can just return str===reverseStr;
to make it shorter
Yi
@ycoding007
Jun 27 2016 02:34
@moigithub :P , you know what, I know the 'reverse' method, however, I want to give myself a lttle trouble to see if i am clear about the for loop : P
Moisés Man
@moigithub
Jun 27 2016 02:34
:+1: @ycoding007
Charles Bakar
@charlesBak
Jun 27 2016 02:35
for loop do great things @ycoding007
Yi
@ycoding007
Jun 27 2016 02:37
how hard to write the 'replace' command?
Moisés Man
@moigithub
Jun 27 2016 02:38
var reverseArray = [];
for (var i=0; i<array.length; i++){
   reverseArray.unshift(array[i]);
}
:D
Yi
@ycoding007
Jun 27 2016 02:38
@moigithub SMART!!
Moisés Man
@moigithub
Jun 27 2016 02:38
String.replace a loop + string contatenation
Chipi
@Chipsta
Jun 27 2016 02:44

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

return item; // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
dont know where to start with this very confused

James S.
@Mrblue27
Jun 27 2016 02:44

Any idea of how do I assign processArg to processed
// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line
var processed = 2;
function processArg(num){

}

any one have and idea how I would assign processed to processArg for assignment Assignment with a Returned Value

Yi
@ycoding007
Jun 27 2016 02:44
@moigithub is there any efficient to DIRECTLY compare two strings?
Moisés Man
@moigithub
Jun 27 2016 02:45
"a" === "b" ??
Chipi
@Chipsta
Jun 27 2016 02:46
that doesnt make sense
to me
Yi
@ycoding007
Jun 27 2016 02:46
Chipi
@Chipsta
Jun 27 2016 02:46
modify the line
oh i think i can see it
its kind of confusing with the other inputs above and below it
Moisés Man
@moigithub
Jun 27 2016 02:49
@ycoding007 never seen that before :)
... but im newbie :)
Chipi
@Chipsta
Jun 27 2016 02:50
console.log(nextInLine(testArr, 0));
what can i modify this to
Chipi
@Chipsta
Jun 27 2016 02:52
im not getting any responses is my computer just lagging?
Santiago Gómez
@Sperkajugglite
Jun 27 2016 02:52

function translatePigLatin(str) {
var firstLetter;
while (str[0] !== "a" || str[0] !== "e" || str[0] !== "i" || str[0] !== "o" || str[0] !== "u") {
firstLetter = str[0];
str = str.slice(1, str.length);
str = str + firstLetter;
}

str = str + "ay";
return str;
}

Moisés Man
@moigithub
Jun 27 2016 02:52
@Sperkajugglite at some point from many slices.. ur str will be "" <-- empty
Santiago Gómez
@Sperkajugglite
Jun 27 2016 02:52
but isn't it appending at the end?
Moisés Man
@moigithub
Jun 27 2016 02:52
"".slice(1) will return ""
This message was deleted
Santiago Gómez
@Sperkajugglite
Jun 27 2016 02:53
str = str + firstLetter
have any ideas?
Moisés Man
@moigithub
Jun 27 2016 02:54
soo.. if ur str dont have any vowel....
gtg
Charles Bakar
@charlesBak
Jun 27 2016 02:55

@ycoding007 compare complete string can also be like this

function comp(str, str1){
  for(var i = 0; i < str.length && (str[i] === str1[i]); i++);
      if(str[i] === str1[i])
          return true;
  else
      return false;
}

console.log(comp("Hall", "Hal"));

i mean without using any library

chiztorismo
@chiztorismo
Jun 27 2016 02:57
Hi I am new to JavaScript... I pray I do well. I am glad that there is an active community here. Nice to meet you all.
Santiago Gómez
@Sperkajugglite
Jun 27 2016 02:57
got it!!!
thanks man!!
Yi
@ycoding007
Jun 27 2016 02:57
@charlesBak that's very great!!!, since the return is in the loop, will i get multiple "true" "false" result?
Charles Bakar
@charlesBak
Jun 27 2016 02:58
Welcome @chiztorismo
chiztorismo
@chiztorismo
Jun 27 2016 02:58
thanks @charlesBak
CamperBot
@camperbot
Jun 27 2016 02:58
chiztorismo sends brownie points to @charlesbak :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @charlesbak |http://www.freecodecamp.com/charlesbak
Charles Bakar
@charlesBak
Jun 27 2016 02:59
no it make sure to give only one result @ycoding007
youre welcome @chiztorismo this is a great community
Yi
@ycoding007
Jun 27 2016 03:02
by the way, in addition to freecodecamp, what IDE do you use for writing Javascript code?
at least it can do some debugging for me :)
azjgard
@azjgard
Jun 27 2016 03:03
@ycoding007 I used Sublime for a long time. It's super light weight, but it doesn't do any javascript debugging without plugins.
Charles Bakar
@charlesBak
Jun 27 2016 03:03
@ycoding007 i use sublime text really great
Chipi
@Chipsta
Jun 27 2016 03:03
do you guys ever look up the answer to figure out a challenge or just rely on these chatrooms? im pretty damn close to looking uo the answer for this stand in line challenge
Yi
@ycoding007
Jun 27 2016 03:04
@Chipsta if i get stuck, like how to use syntax, i look up online, and try to write code myself, if all fail, then cheat it :)
Charles Bakar
@charlesBak
Jun 27 2016 03:04
@Chipsta This chatroom will help you solve your problems
azjgard
@azjgard
Jun 27 2016 03:05
@Chipsta What problem are you having?
Kevin Murphy
@kaym0
Jun 27 2016 03:05
Hey, I'm doing "Chunky Monkey" in the algorithms
Diego Mayer
@Chrono79
Jun 27 2016 03:05
@ycoding007 return exits the function
Kevin Murphy
@kaym0
Jun 27 2016 03:05
I've got the answer here, (looked it up online) because I thought it was a bit too hard for what I know. I've been looking at the code but I don't understand it. Before I move on I'd like to be able to understand it
Here's the answer, but
Logan Klein
@Lkleindesigns
Jun 27 2016 03:06
@azjgard What kind of plugins were you using for javascript debugging, or would you recommend something else?
Kevin Murphy
@kaym0
Jun 27 2016 03:06
Could somebody maybe go over that with me to help me understand it?
Diego Mayer
@Chrono79
Jun 27 2016 03:06
@charlesBak that loop won't run more than once
What does that loop exactly?
Chipi
@Chipsta
Jun 27 2016 03:07
im just retarded i am confused as fuck as to why they put nextInLine(arr,item) first of all i dont know how to write a function calling those because i don't know which variables to use.

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

return item; // Change this line
}

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

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

azjgard
@azjgard
Jun 27 2016 03:07
@Lkleindesigns You can install something called "JSHint" via Sublime's package manager, but it took me a few hours to get it working because there's a lot of crap you have to do via console commands and other stuff. I've turned into a big fan of "Cloud 9", which is an IDE that runs right in your browser. It has built in JSHint to catch your Javascript syntax errors. That's the one I currently use at work.
Charles Bakar
@charlesBak
Jun 27 2016 03:07
@azjgard do you have the SublimeLinter and JSHint in Sublime Text for javascript
azjgard
@azjgard
Jun 27 2016 03:08
@charlesBak Yes I do
Diego Mayer
@Chrono79
Jun 27 2016 03:08

@ycoding007 compare complete string can also be like this
```
function comp(str, str1){
for(var i = 0; i < str.length && (str[i] === str1[i]); i++);
if(str[i] === str1[i])
return true;
else
return false;
}

console.log(comp("Hall", "Hal"));
```
i mean without using any library

This isn't right @charlesBak

Chipi
@Chipsta
Jun 27 2016 03:08
what is (arr,item)?
Charles Bakar
@charlesBak
Jun 27 2016 03:09
@Chrono79 i just make sure the strings are the same size and then compare them with them contents to obtain the result
Kevin Murphy
@kaym0
Jun 27 2016 03:09
@Chipsta it's the variables within the function
@Chipsta I believe it's teaching you how to use functions, so pay attention only to whatever you're writing inside the function.
@Chipsta if you gave (2, 3) (2 = arr and 3 = item)
Charles Bakar
@charlesBak
Jun 27 2016 03:10

@Chrono79

console.log(comp("Hall", "Hal"));

return false

this is C programming style i just tried it with js
Chipi
@Chipsta
Jun 27 2016 03:10
so should i start off by defining arr and item
????
Charles Bakar
@charlesBak
Jun 27 2016 03:10
and it seems to work
Kevin Murphy
@kaym0
Jun 27 2016 03:10
@Chipsta what is your question?
Kevin Murphy
@kaym0
Jun 27 2016 03:11
@chipasta what is the goal to what you are doing, I'm not sure I understood that
Chipi
@Chipsta
Jun 27 2016 03:11
if they are variables they need to be defined
Diego Mayer
@Chrono79
Jun 27 2016 03:11
@charlesBak wouldn't it be better just return str1 === str2?
azjgard
@azjgard
Jun 27 2016 03:11
@Chipsta Those variables are defined when the function is called
Kevin Murphy
@kaym0
Jun 27 2016 03:11
@Chipsta they get defined via the input
Chipi
@Chipsta
Jun 27 2016 03:12
pretty damn confusing
Charles Bakar
@charlesBak
Jun 27 2016 03:12
@azjgard i have it to but it is weird sometimes, become slow
Chipi
@Chipsta
Jun 27 2016 03:12
ill check the ink
Kevin Murphy
@kaym0
Jun 27 2016 03:12
@Chipsta The challenge will provide inputs, your goal is to manipulate the data within the function in order to provide whatever result is asked
@Chipsta can you link me and I'll see if I can help you understand?
azjgard
@azjgard
Jun 27 2016 03:13

so for example, if you have a function like this:

function addTwoNumbers (num1, num2) {

return num1 + num2;

}

this function will add and display the value of any two numbers that are given to it. These values are defined later on in the code, when the function is called, like this:

(let's use 2 and 3 as an example)

addTwoNumbers(2, 3);

The point of functions is to make the same code work for multiple pieces of information. So you could call the function that I previously wrote for any two numbers to add them together, for example:

addTwoNumbers(8, 20);
addTwoNumbers(200, 500);

and it goes on and on.

Charles Bakar
@charlesBak
Jun 27 2016 03:14
@Chrono79 ya that would work in javascript
azjgard
@azjgard
Jun 27 2016 03:14
@charlesBak check out Cloud9.. http://c9.io
Kevin Murphy
@kaym0
Jun 27 2016 03:15
Lol
Chipi
@Chipsta
Jun 27 2016 03:15
could i put anything inside of the ()?
Kevin Murphy
@kaym0
Jun 27 2016 03:16
Can you give me the link so I can better understand what you're asking?
Chipi
@Chipsta
Jun 27 2016 03:16
instead of num1 and 2? is it used like a placeholder?
Kevin Murphy
@kaym0
Jun 27 2016 03:16
All I have is a fraction of the code you're using and I don't know what you're trying to do
Chipi
@Chipsta
Jun 27 2016 03:17

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

return item; // Change this line
}

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

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

Kevin Murphy
@kaym0
Jun 27 2016 03:17
yes, but the actual link to the challenge so I can read what it ants you to do
azjgard
@azjgard
Jun 27 2016 03:17
@Chipsta yes, it's used like a placeholder. that's exactly it
Chipi
@Chipsta
Jun 27 2016 03:18

nextInLine([], 1) should return 1
nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5
After nextInLine(testArr, 10), testArr[4] should be 10

function nextInLine(arr, item) {

// Your code here

return item; // Change this line

}

// Test Setup

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

// Display Code

console.log("Before: " + JSON.stringify(testArr));

console.log(nextInLine(testArr, 0)); // Modify this line to test

console.log("After: " + JSON.stringify(testArr));

azjgard
@azjgard
Jun 27 2016 03:18
@Chipsta so in other words, when you're writing the code inside of the function and making references to 'arr' and the other variable, you're just making references to placeholders
Charles Bakar
@charlesBak
Jun 27 2016 03:20
@azjgard thanks man
CamperBot
@camperbot
Jun 27 2016 03:20
charlesbak sends brownie points to @azjgard :sparkles: :thumbsup: :sparkles:
:cookie: 197 | @azjgard |http://www.freecodecamp.com/azjgard
Kevin Murphy
@kaym0
Jun 27 2016 03:21

{ arr.push(item);
return arr.shift(); // Change this line } @Chipsta

, so when you use "arr.push(item); it is refering to the "arr" and "item" in at the start of the function, which is relevent to input, which would be what "testArr" is

Anybody able to help me to understand this

function chunkArrayInGroups(arr, size)
{
var temp = [];
var result = [];
// Break it up
for (var b in arr)
{
if (b % size !== size-1)
{temp.push(arr[b]);}
else
{
temp.push(arr[b]);
result.push(temp);
temp = [];
}

}

if (temp.length !==0)
{result.push(temp);}
return result;
}

I looked up the answer because I was having difficulty, and usually if I do that I can understand and learn from it, and then I rewrite the code in my own way
But I just don't understand this
Kevin Murphy
@kaym0
Jun 27 2016 03:26
when you use for (var b in arr) does it create another array? or
Chipi
@Chipsta
Jun 27 2016 03:26
i just dont understand how the variable at the bottom that contains an array of 5 numbers can manipulate the two cariables inside the function.
Doug
@Spazcool
Jun 27 2016 03:27

Hey, not sure how to make this happen. Working on a webpage that is about the solar system, it includes a rotating model of the solar system. At the moment I have the planets make a little jingle and fade away and back in when the mouse hovers over them. However, I'd like them to do those actions based on their coordinates on the screen.

So far I've got:$(document).ready(function() { var x = $("#mercury").offset; function poop(){ if(x.top >= 1200.00 && x.left >=1000.00){ $("#mercury").fadeOut("slow");

Kevin Murphy
@kaym0
Jun 27 2016 03:27
The variable athte bottom is the hypothetical input, @Chipsta
azjgard
@azjgard
Jun 27 2016 03:27

@kaym0

for (var b in arr) is just another way of saying for (var b = 0; b < arr.length: b++) {}

Kevin Murphy
@kaym0
Jun 27 2016 03:27
@Chipsta realistically it doesn't effect your code at all, it's just the input, which you can change too. It's there so you can change it and see how it effects the results
azjgard
@azjgard
Jun 27 2016 03:28
it's a 'for-each- loop versus just a 'for' loop, but functionally, they are the same thing
Kevin Murphy
@kaym0
Jun 27 2016 03:28
@thanks azjgard
thanks @azjgard
CamperBot
@camperbot
Jun 27 2016 03:28
:cookie: 199 | @azjgard |http://www.freecodecamp.com/azjgard
kaym0 sends brownie points to @azjgard :sparkles: :thumbsup: :sparkles:
Chipi
@Chipsta
Jun 27 2016 03:29
whats up with all the console.log stuff at thee bottom?
Kevin Murphy
@kaym0
Jun 27 2016 03:30
@Chipsta Again, it's nothing you need to worry about because it's just there to make the function you're using work.
@Chipsta you will learn about that later
@Chipsta They usually don't include it, and I undersand how it can be confusing.

Essentially all you need to worry about is the

function (a, b) {
return x;
}

Oh, hey.
Also I was wondering how it gets placed into two seperate arrays using that coding
It's completely blowing over my head lol
Chipi
@Chipsta
Jun 27 2016 03:35
so for nextInLine([2], 1) should return 2
i would want to use the .shift()
Chipi
@Chipsta
Jun 27 2016 03:36
?
Kevin Murphy
@kaym0
Jun 27 2016 03:36
@Chipsta Please check this
It's a full explaination of the challenge, it's best not to use these, but if you're really stumped it's a great way to help understand
@Chipasta Did you get it?
Chipi
@Chipsta
Jun 27 2016 03:40
kinda but not really
i know i need to use .push
Kevin Murphy
@kaym0
Jun 27 2016 03:40
@Chipsta the answer is on the page.. lol
Chipi
@Chipsta
Jun 27 2016 03:41
i understad that but im trying not to look at it
ranranking
@ranranking
Jun 27 2016 03:41
excuse me, what is the opposite of if(val)? is it if(val == false)? But that won't work when val = null and etc.
Kevin Murphy
@kaym0
Jun 27 2016 03:41
You push the item onto the arr @Chipsta
arr.push(item);
then you create another variable for what's removed
var removed = arr.shift(); // this is what is removed when you push
then you return the removed variables with
return removed;
Since 2, 1 would be two variables, when you PUSH item (1) onto arr (2), it removes the (2) and puts (1) there. @Chipsta
Then you're just saving whatever is removed to another variable, which we have called "removed" but you can call it whatever you like. @Chipsta
Chipi
@Chipsta
Jun 27 2016 03:45
var testArr = [1,"B"];
this is what i narrowed it down to so i can understand it easier
Kevin Murphy
@kaym0
Jun 27 2016 03:46
Okay, so
Using that same code
Chipi
@Chipsta
Jun 27 2016 03:46
to be able to use .push )_and /shift()
Kevin Murphy
@kaym0
Jun 27 2016 03:46
Arrays are seperated by ]['s
so if you had 1, [ b ]
azjgard
@azjgard
Jun 27 2016 03:47

@ranranking the opposite of 'if(val)' would literally be 'if(val == false)' or, for laziness, 'if(!val)', like you said. If you want to check other values you don't want val to be, do it with OR operators like this:

if ( (val == false) || (val == null) || (val == undefined) ) {
// do stuff
}

Kevin Murphy
@kaym0
Jun 27 2016 03:48

now
arr = b
removed = 1

where before
item = b
arr = 1
removed = nothing

The site explains it pretty vividly, I would suggest watching a video if you can't understand it after reading the answer!
Chipi
@Chipsta
Jun 27 2016 03:49
ok thanks
azjgard
@azjgard
Jun 27 2016 03:49

@ranranking What exactly are you trying to do? I'd think the easiest way would be:

if (val == true) {
//do stuff
}
else { // <------the else part will catch everything
//do other stuff
}

Chipi
@Chipsta
Jun 27 2016 03:49
@kaym0 thanks
CamperBot
@camperbot
Jun 27 2016 03:49
chipsta sends brownie points to @kaym0 :sparkles: :thumbsup: :sparkles:
:cookie: 250 | @kaym0 |http://www.freecodecamp.com/kaym0
Kevin Murphy
@kaym0
Jun 27 2016 03:50
Also @Chipsta the "examples run" section of that page can be really useful for understanding. It usually goes line by line explaining it!
Vanessa
@dadousuren
Jun 27 2016 03:51
hello~
Kevin Murphy
@kaym0
Jun 27 2016 03:51
hello
Chipi
@Chipsta
Jun 27 2016 03:52
what kinda video would you recommend @kaym0
Nathaniel Nasarow
@Torgian
Jun 27 2016 03:53
hey guys
having problems with API stuff :/
I keep getting this error
 The page at 'https://codepen.io/torgian/pen/JKEZOz' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=?jsonp?'. This request has been blocked; the content must be served over HTTPS.
azjgard
@azjgard
Jun 27 2016 03:55
@Torgian What does your code look like? You're making some sort of cross-domain request that's not allowed
@Torgian Are you using an iframe or something?
Nathaniel Nasarow
@Torgian
Jun 27 2016 03:56
No, here let me show you my codepen
strange thing was, it was working yesterday, and I was about to do more design stuff when it stopped working
ranranking
@ranranking
Jun 27 2016 03:57

@azjgard my situation is:

if(val) {
//do nothing
} else {
//do someting
}

So the structure is not totally correct. I don't want any do nothing parts in my code

Nathaniel Nasarow
@Torgian
Jun 27 2016 03:59
@azjgard Yesterday the API was working just fine, today it's not. I have run across the same error with a few other APIs so not sure what's wrong.
azjgard
@azjgard
Jun 27 2016 04:01

@Torgian That's really weird.. I'll look at it and see if I know enough to help.

@ranranking What are the possible ways that val could be defined according to your code before that statement? Is there any way that it would ever be something other than a boolean?

Nathaniel Nasarow
@Torgian
Jun 27 2016 04:02
@azjgard thanks mate. I might have to change the way I make the API request. I've mostly followed the example given by FCC, but I think I might have to restructure it as a full ajax request... more reading for me! XD
CamperBot
@camperbot
Jun 27 2016 04:02
torgian sends brownie points to @azjgard :sparkles: :thumbsup: :sparkles:
:cookie: 202 | @azjgard |http://www.freecodecamp.com/azjgard
azjgard
@azjgard
Jun 27 2016 04:02
@Torgian Were the errors you received in the other APIs in reference to 'http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=?jsonp?' as well?
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:03
The errors were similar, related to their own pages.
all pointing to the security thing
Now I also have the code on my computer
running it from there, I just run into the usual
XMLHttpRequest cannot load http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=. The 'Access-Control-Allow-Origin' header has a value 'http://null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
but that's because of the lack of jsonp support on their end
Richard
@codecampergg
Jun 27 2016 04:06

Hi everyone! I'm trying to factorialize a number given in the parameter but I have no idea how to do it, any help? please


function factorialize(num) {
  for(i = 0; i == num; i++) {
    num = i * i;
  }
  return num;
}


factorialize(5);

This is my code, please help me

ranranking
@ranranking
Jun 27 2016 04:06
@azjgard no val can be anything. I use if(val) to check if val is falsy or not. I will only do something when val is falsy variable, such as NaN, null, '', etc.
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:06
I really want use this one: http://quotes.stormconsultancy.co.uk/api but no jsonp support, and I don't know how to access it otherwise.
@codecampergg Have you read about how factorializing works mathematically?
Richard
@codecampergg
Jun 27 2016 04:08
yeah, I know the basics but it's kind of confusing when I try to put it in the code
@Torgian
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:09
you're real close
think about i and what it is doing in your code
your for loop is also incorrect
first work through on how you want to iterate through your numbers. Then, consider what i will do in that for loop.
Xander Apponi
@xapponi
Jun 27 2016 04:11
Hey everyone, I am on "Caesars Cipher". My problem is that some of the characters are changing to the wrong letter because it continues to loop through and change them. Any thoughts on how this could be better approached. I have to shift the characters 13 letters down.

function rot13(str) { // LBH QVQ VG!
  var array = str.split(""); 
  for (i = 0; i < array.length; i++) {
    if (array[i] === "A") {
      array.splice(i, 1, "N");
    }
    if (array[i] === "B") {
      array.splice(i, 1, "O");
    }
    if (array[i] === "C") {
      array.splice(i, 1, "P");
    }
    if (array[i] === "D") {
      array.splice(i, 1, "Q");
    }
    if (array[i] === "E") {
      array.splice(i, 1, "R");
    }
    if (array[i] === "F") {
      array.splice(i, 1, "S");
    }
    if (array[i] === "G") {
      array.splice(i, 1, "T");
    }
    if (array[i] === "H") {
      array.splice(i, 1, "U");
    }
    if (array[i] === "I") {
      array.splice(i, 1, "V");
    }
    if (array[i] === "J") {
      array.splice(i, 1, "W");
    }
    if (array[i] === "K") {
      array.splice(i, 1, "X");
    }
    if (array[i] === "L") {
      array.splice(i, 1, "Y");
    }
    if (array[i] === "M") {
      array.splice(i, 1, "Z");
    }
    if (array[i] === "N") {
      array.splice(i, 1, "A");
    }
    if (array[i] === "O") {
      array.splice(i, 1, "B");
    }
    if (array[i] === "P") {
      array.splice(i, 1, "C");
    }
    if (array[i] === "Q") {
      array.splice(i, 1, "D");
    }
    if (array[i] === "R") {
      array.splice(i, 1, "E");
    }
    if (array[i] === "S") {
      array.splice(i, 1, "F");
    }
    if (array[i] === "T") {
      array.splice(i, 1, "G");
    }
    if (array[i] === "U") {
      array.splice(i, 1, "H");
    }
    if (array[i] === "V") {
      array.splice(i, 1, "I");
    }
    if (array[i] === "W") {
      array.splice(i, 1, "J");
    }
    if (array[i] === "X") {
      array.splice(i, 1, "K");
    }
    if (array[i] === "Y") {
      array.splice(i, 1, "L");
    }
    if (array[i] === "Z") {
      array.splice(i, 1, "M");
    }



  }
  var finalArr = array.join("");
  return finalArr;


}

// Change the inputs below to test
rot13("SERR YBIR?");
azjgard
@azjgard
Jun 27 2016 04:12

@Torgian Maybe something changed on the API site's end of things? If you said that it was functioning the last time you were working on it and it randomly broke overnight, then that's the only thing I can think of.

And that seems to be corroborated by Mozilla: https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content/How_to_fix_website_with_mixed_content. Mozilla says that the best way to avoid the problem you're getting is to load everything over HTTPS. According to the error message you're getting, Codepen is being loaded over HTTPS (the 'right way') but the quotesdesign website isn't (the 'wrong way'), which is what is generating the error.

I think I definitely need to take some networking classes haha. You probably already knew everything I just spit out, but that's all I've got for now

Nathaniel Nasarow
@Torgian
Jun 27 2016 04:12
Holy if statements Batman!
Xander Apponi
@xapponi
Jun 27 2016 04:12
I know, Thats why I feel like theres a better way .
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:13
@xapponi remember what you have learned over the past several lessons. There's no need for this many if statements in your code.
@azjgard Yeah, I figured it had something to do with that. Gods, this is a really annoying one. I had everything working perfectly yesterday and wanted to just go over the design of the page today, but now i need to figure out how to do the API
Xander Apponi
@xapponi
Jun 27 2016 04:14
I tried to use the ASCII characters and an array, but I had trouble when it came to making Z jump back to the beginning of A
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:14
you can use if statements for that
there's also a way to use a regex
There are a few ways you can do this one, the regex being the cleanest version, but probably the hardest to come across
My code uses several concepts we have learned over the past few chapters (slice, indexOf, the CharCode functions)
and my original code had two if statements
Richard
@codecampergg
Jun 27 2016 04:16
Thanks man! I'm gonna think about it and figure it out how to solve it @Torgian
CamperBot
@camperbot
Jun 27 2016 04:16
codecampergg sends brownie points to @torgian :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @torgian |http://www.freecodecamp.com/torgian
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:16
revisit the CharCodes and go over the past few lessons again to get an idea
draw it out on paper if you want, that helps me sometimes
Xander Apponi
@xapponi
Jun 27 2016 04:17
Thanks @Torgian
CamperBot
@camperbot
Jun 27 2016 04:17
xapponi sends brownie points to @torgian :sparkles: :thumbsup: :sparkles:
:cookie: 276 | @torgian |http://www.freecodecamp.com/torgian
Chipi
@Chipsta
Jun 27 2016 04:17
have you guys used any other sites for learning developing ? any suggestions ?
Thomas hadley
@Thadley17
Jun 27 2016 04:18

Hey guys, some guidance would be very helpful.

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

      if(firstName == contacts[i].firstName){

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

       // return "No such contact";

      }

  }

I'm stuck on the lesson "Profile Lookup". I've tried multiple times to be able to pass this and the part that is messing me up is how to return "No such contact". With it commented out, everything passes but undefined contacts, If I uncomment the last return function, i believe everything is ignored and only that return function works. What am I missing? It's driving me bonkers lol

Chipi
@Chipsta
Jun 27 2016 04:18
im just having a hard time grasping these concepts in javascript and am thinking about using another source to maybe help my understanding
Karolis
@Luomint
Jun 27 2016 04:19
This message was deleted
@Chipsta I usually google and try to find different explanations for the same problem
azjgard
@azjgard
Jun 27 2016 04:20
@Chipsta I'd supplement your learning here with YouTube videos and google searches on specific topics that you have a hard time understanding. I don't think there is really one go-to place. An example that I always learn a lot from is https://developer.mozilla.org/en-US/Learn/JavaScript, the offically javascript reference from Mozilla.
Karolis
@Luomint
Jun 27 2016 04:21
Your brain is creating new neural networks, it takes time but it will get easier and easier
Chipi
@Chipsta
Jun 27 2016 04:22
yeah i feel pretty dumb
im trying to read eloquent javascript but it takes me several days to get passed one page
i also work full-time
Xander Apponi
@xapponi
Jun 27 2016 04:23
Just wondering, how long do you think it would take to complete all certifications from freeCodeCamp?
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:23
They say that it takes about a year
But it really depends on each person
azjgard
@azjgard
Jun 27 2016 04:24
I'm sure it depends on how much time you put into it on a daily basis as well
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:24
of course.
Xander Apponi
@xapponi
Jun 27 2016 04:25
For me, I got through HTML and CSS stuff in a weekend, but have been on basic javascript for months now.
Karolis
@Luomint
Jun 27 2016 04:25
@Chipsta most programmers say they felt stupid a lot of the time when they were learning and even when they are professionals
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:26
lolz @xapponi wait till you get to the algorithm challenges like me :smile: Many times you will get frustrated XD
Nahid
@nahid-uddin
Jun 27 2016 04:27
Me and you both lol @xapponi
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:28

Speaking of which :)
I'm having a hard time on 'Pig Latin'

`
str = str.split('');//Splits the word

for (var index = 0; index < str.length; index++) {

if (consonants.indexOf(str[index].toLowerCase()) != -1) {

str.push(str[index]);
}
else {

  str.push('a', 'y');
  break;

}

}
`

I cant find a way to take out the beginning consonants

Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:29
i did a while loop
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:29
well I found a quote API that isn't annoying me now
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:29
to see if there were consonants at str[0]
if not
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:29
so everything works again D
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:29
append "way"
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:30
oh thank you!!!! .append XD thats what I need.
thanks @Sperkajugglite
CamperBot
@camperbot
Jun 27 2016 04:30
htmlnoob sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:30
if there are
not append
Richard
@codecampergg
Jun 27 2016 04:30

Am I close?


function factorialize(num) {
  for(i = 0; i < num + 1; i++) {

}

var n = (num * i) * (num + i);

  return n;
}


factorialize(5);

@Torgian

Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:30
just concat
with +
Richard, use recursion
its easier
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:31
yea, srry theres just so many built-in functions and properties to remember many times you forget them.
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:31
@codecampergg read up on for loops, and check how they work. You will need to use the .length property
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:31
HTMLNoob when you finish
lets do the next one
im stuck
Xander Apponi
@xapponi
Jun 27 2016 04:32
https://www.youtube.com/watch?v=ozmE8G6YKww, This is in java not javascript, but it really helped me understand recursion. Hope it helps.
Nathaniel Nasarow
@Torgian
Jun 27 2016 04:32
Your 'var n ' is also using the incorrect formula, but it's closer
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:32
i remembered the factorial recursion in python and applied it to js
@HTMLNoob could you do it?
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:33
Yea I got one problem down but I another appeared.
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:33
@HTMLNoob tell me
Joni petriashvili
@Jonhnwhantcoding
Jun 27 2016 04:33
guys how to do this task
Write variable names in Javascript in camelCase. In camelCase, multi-word variable names have the first word in lowercase and the first letter of each subsequent word is capitalized.
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:34
I was able to get the consonants to the end of the array but I couldnt delete the first ones
Do I use splice somehow?
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:34
@HTMLNoob what i did was :
if there aren't consonants
add "way"
if there are: save the firstChar in a variable
save the rest in another variable (using substr or spli)
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:35
Yes, but how do I delete or remove the firstChar from the array?
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:35
dont
just create another one like: rest + firstChar
Richard
@codecampergg
Jun 27 2016 04:36
Thanks to everyone! @Torgian @xapponi @Sperkajugglite
CamperBot
@camperbot
Jun 27 2016 04:36
codecampergg sends brownie points to @torgian and @xapponi and @sperkajugglite :sparkles: :thumbsup: :sparkles:
:cookie: 276 | @sperkajugglite |http://www.freecodecamp.com/sperkajugglite
:warning: codecampergg already gave torgian points
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:36
and put that in a loop until it takes all the consonants from the begining
CamperBot
@camperbot
Jun 27 2016 04:36
:cookie: 258 | @xapponi |http://www.freecodecamp.com/xapponi
Syed Taha
@Spawn12
Jun 27 2016 04:37
Screenshot (71).png
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:39
how do you put your code in the chat?
Tyler Del Rosario
@TylerDelRosario
Jun 27 2016 04:39
you use `
also dont use ' you have to use ` if you look theres a difference
Its right beside number 1 on your keyboard
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:40

`
Speaking of which :)
I'm having a hard time on 'Pig Latin'

`
str = str.split('');//Splits the word

for (var index = 0; index < str.length; index++) {

if (consonants.indexOf(str[index].toLowerCase()) != -1) {

str.push(str[index]);
}
else {

  str.push('a', 'y');
  break;

}

}
`

I cant find a way to take out the beginning consonants

oh
thanks man
thanks @HTMLNoob
CamperBot
@camperbot
Jun 27 2016 04:42
sperkajugglite sends brownie points to @htmlnoob :sparkles: :thumbsup: :sparkles:
:cookie: 283 | @htmlnoob |http://www.freecodecamp.com/htmlnoob
Santiago Gómez
@Sperkajugglite
Jun 27 2016 04:42
could you do it?
BenKlemme
@BenKlemme
Jun 27 2016 05:05
hey guys I'm stuck on the "where do I belong" challenge in javascript. Some of the tests work but not all and I'm not sure why.
function getIndexToIns(arr, num) {
arr.sort();
var j = 0,
k = 1;
for (var i = 0; i < arr.length; i++) {
j++;
k++;
if (num > arr[i] && num < arr[j]) {
arr.splice(j, 0, num);
return j;
} else if (num <= arr[i]) {
arr.splice(i, 0, num);
return i;
} else if (num >= arr[j]) {
arr.splice(k, 0, num);
return k;
}
}
}
oops forgot the formatting..
`function getIndexToIns(arr, num) {
arr.sort();
var j = 0,
k = 1;
for (var i = 0; i < arr.length; i++) {
j++;
k++;
if (num > arr[i] && num < arr[j]) {
arr.splice(j, 0, num);
return j;
} else if (num <= arr[i]) {
arr.splice(i, 0, num);
return i;
} else if (num >= arr[j]) {
arr.splice(k, 0, num);
return k;
}
}
}
lol alright its not working. sorry
function getIndexToIns(arr, num) {
  arr.sort();
  var j = 0,
      k = 1;
  for (var i = 0; i < arr.length; i++) {
    j++;
    k++;
    if (num > arr[i] && num < arr[j]) {
      arr.splice(j, 0, num);
      return j;
    } else if (num <= arr[i]) {
      arr.splice(i, 0, num);
      return i;
    } else if (num >= arr[j]) {
      arr.splice(k, 0, num);
      return k;
    }
  }
}
there we go
damole8u
@damole8u
Jun 27 2016 05:08
Having issues with the Nesting Loops section
not sure what I'm doing wrong
mayuri nayak
@mayuri14
Jun 27 2016 05:10
Build a CodePen.io app that is functionally similar to this: https://codepen.io/FreeCodeCamp/full/NNvBQW/.
How to do this
damole8u
@damole8u
Jun 27 2016 05:11

here's my code:function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length; i++) {
for (var j=0; j < multiplyAll[i].length; j++) {
console.log(arr[i][j]);
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

@damole8u how are you handling the product variable? reference instructions: Modify function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr :) product result is 1, with that code...
mayuri nayak
@mayuri14
Jun 27 2016 05:15
Build a CodePen.io app that is functionally similar to this: https://codepen.io/FreeCodeCamp/full/NNvBQW/. Where should I write this code?
Syed Taha
@Spawn12
Jun 27 2016 05:17
on any text editor and save it by .html @mayuri14
mayuri nayak
@mayuri14
Jun 27 2016 05:19
Then where to upload it
Justin Ober
@0b3r
Jun 27 2016 05:20
Your other option is to create a codepen.io account and then "Create a New Pen"
then you can code the html css and js right in there and save it
then when its complete you just submit the codepen url
mayuri nayak
@mayuri14
Jun 27 2016 05:22
Ok thank you
Justin Ober
@0b3r
Jun 27 2016 05:22
No problem
96street
@96street
Jun 27 2016 05:37
are .ajax() and getJSON() GET/POST methods?
Justin Ober
@0b3r
Jun 27 2016 05:40
.ajax can be any request type by changing the "method" parameter
getJson looks to be just a "GET" method
silver537
@silver537
Jun 27 2016 05:41
Help brownie
CamperBot
@camperbot
Jun 27 2016 05:41

:point_right: brownie points [wiki]

Brownie Points

The number beside your picture on Free Code Camp tells you how many Brownie Points you have.

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

  1. Complete challenges - you get one point per challenge you complete
  2. Help other campers in chat - each time you help another camper and they thank you (by typing "thanks @yourname"), you will get a point

Brownie Points help you look like the kind of person who codes a lot, shares relevant links, and helps people.

They also add to your Streak.

:pencil: read more about brownie points on the FCC Wiki

silver537
@silver537
Jun 27 2016 05:42
@mayuri14 :point_up:
Krishna Sai Gullapalli
@Krish2704
Jun 27 2016 05:43
@silver537 thank you!
CamperBot
@camperbot
Jun 27 2016 05:43
krish2704 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 372 | @silver537 |http://www.freecodecamp.com/silver537
96street
@96street
Jun 27 2016 05:43
@0b3r gotcha
kirbyedy
@kirbyedy
Jun 27 2016 05:43
@silver537 hey infinity :)
hello world
CamperBot
@camperbot
Jun 27 2016 05:43

welcome to FreeCodeCamp @kirbyedy!

Justin Ober
@0b3r
Jun 27 2016 05:43
@silver537 thanks
CamperBot
@camperbot
Jun 27 2016 05:43
0b3r sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 373 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Jun 27 2016 05:43
Ugh fucking picture.... -_-
Krishna Sai Gullapalli
@Krish2704
Jun 27 2016 05:43
@kirbyedy you're not welcome. get out! :p
kirbyedy
@kirbyedy
Jun 27 2016 05:43
:(
:crying_cat_face:
Eric Bezanson
@ericbezanson
Jun 27 2016 05:48
can someone help me with whats wrong with Return Largest Numbers In Arrays. my logic is: interate through outer array via for loop, find largest number inside inner array by setting var check to 0 and replacing check with any number larger than it until it reaches the end of the array and also setting var largest as = to check, once the for loop is completed for the inner array then var longest is pushed to var arr2 which starts as an empty array. heres the code:
function largestOfFour(arr) {
  var arr2 = [];
  var largest;
    for (i=0; i < arr.length; i++){
      for (j=0; j < arr[i].length; j++){
        var check = 0;
        if (j > check) {
          largest = check;
        }
      }
      arr2.push(largest);
    }
  return arr2;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Markus Kiili
@Masd925
Jun 27 2016 05:49
@ericbezanson You should initialize the variable for every subarray (you have it in wrong place).
Eric Bezanson
@ericbezanson
Jun 27 2016 05:49
right now its returning [0,0,0,0]
@Masd925 you mean in this case arr2 ?
Markus Kiili
@Masd925
Jun 27 2016 05:50
@ericbezanson I mean var check=0;
You initialize it for every subarray element.
Eric Bezanson
@ericbezanson
Jun 27 2016 05:51
hmm but i need it to be 0 at the beginning of each main array loop
so should it be between the two for loops?
Markus Kiili
@Masd925
Jun 27 2016 05:52
Yes.
Each i value means a new subarray so initialization should be before j loop statement.
Eric Bezanson
@ericbezanson
Jun 27 2016 05:52
like this:
function largestOfFour(arr) {
  var arr2 = [];
  var largest;
    for (i=0; i < arr.length; i++){
      var check = 0;
      for (j=0; j < arr[i].length; j++){
        if (j > check) {
          largest = check;
        }
      }
      arr2.push(largest);
    }
  return arr2;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Markus Kiili
@Masd925
Jun 27 2016 05:53
Now you have one extra variable there.
Just result array and the largest number found so far.
So remove largest.
Eric Bezanson
@ericbezanson
Jun 27 2016 05:55
but how would I push the largest number into an array without that
Markus Kiili
@Masd925
Jun 27 2016 05:55
You have check.
Eric Bezanson
@ericbezanson
Jun 27 2016 05:56
so if j > check set check = j ?
Markus Kiili
@Masd925
Jun 27 2016 05:56
You should compare arr[i][j] and check.
silver537
@silver537
Jun 27 2016 05:56
@ericbezanson you can use the sort slice and push methods. Sorts the highest number to the front or end. Slice that number off. And push into a new array.
Z.G.Hao
@akidox
Jun 27 2016 05:57
{
    type: “flowers”,
    list: [
        “rose”,
        “tulip”,
        “dandelion”
     ]
}
how dose it make sense,should the type or list be in quotes?
silver537
@silver537
Jun 27 2016 05:57
Or you can map the whole thing to get rid of any for loops.
Markus Kiili
@Masd925
Jun 27 2016 05:57
@silver537 If you wan't to use methods, then Math.max.apply(null,arr) is much better than sorting.
silver537
@silver537
Jun 27 2016 05:58
Doesnt that require a loop?
Never used mathmax
Markus Kiili
@Masd925
Jun 27 2016 05:58
@akidox JS object literal syntax has that freedom to use or not use quotes there. JSON is a text format for storing objects and it has stricter syntax that needs those quotes.
@silver537 The method call that I posted returns the largest number in the array arr.
@silver537 With .apply() you can give any method arguments as an array.
Eric Bezanson
@ericbezanson
Jun 27 2016 06:00
im getting [3,3,3,3] returned now which i dont even know how thats possible lol
function largestOfFour(arr) {
  var arr2 = [];
    for (i=0; i < arr.length; i++){
      var check = 0;
      for (j=0; j < arr[i].length; j++){
        if (j > check) {
          console.log(check);
          check = j;
        }
      }
      arr2.push(check);
    }
  return arr2;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
96street
@96street
Jun 27 2016 06:00
if a page/code has .php does that mean they are writing in PHP language?
Markus Kiili
@Masd925
Jun 27 2016 06:01
@ericbezanson You should compare arr[i][j] and check. That way you access the subarray.
Z.G.Hao
@akidox
Jun 27 2016 06:01
@Masd925 But the object is within an array,isn’t that JSON?
Markus Kiili
@Masd925
Jun 27 2016 06:03
@akidox FCC JSON challenges actually have very little to do with JSON, which is a text or string format for storing objects. Challenges deal with JS object literals written using stricter JSON syntax.
Eric Bezanson
@ericbezanson
Jun 27 2016 06:03
thanks @Masd925 that worked! I think i know why it wasnt working ... within the context of that for loop j was really represnting the number 1 - whatever the length of the sub array was not the actuall element in the array right?
CamperBot
@camperbot
Jun 27 2016 06:03
ericbezanson sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1977 | @masd925 |http://www.freecodecamp.com/masd925
damole8u
@damole8u
Jun 27 2016 06:03
@ndburrus I thought for the modify function multiplyAll that putting product in the () would work
but I get an error
or length is undefined
Markus Kiili
@Masd925
Jun 27 2016 06:05
@akidox
var json = '{"name":"John"}'; // This is JSON
var obj = JSON.parse(json);   // Turn JSON string into JS object { name: 'John' }

obj = {"name":"John"};  // Literal that looks like JSON
obj = {name:"John"};    // Literal that does not look like JSON
silver537
@silver537
Jun 27 2016 06:06
@damole8u put them in cjrly brackets
Curly
Markus Kiili
@Masd925
Jun 27 2016 06:08
@akidox So, those challenges deal with JS object literals that contain text that could be used as part of a JSON string. Very confusing.
damole8u
@damole8u
Jun 27 2016 06:08
@silver537 which one?
Z.G.Hao
@akidox
Jun 27 2016 06:09
So JSON syntax is with single quotes,and the others are not JSON? @Masd925
silver537
@silver537
Jun 27 2016 06:09
Post
Your code
damole8u
@damole8u
Jun 27 2016 06:10

function multiplyAll(product) {
product = 1;
// Only change code below this line
for (var i=0; i < multiplyAll.length; i++) {
for (var j=0; j < multiplyAll[i].length; j++) {
console.log(arr[i][j]);
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

silver537
@silver537
Jun 27 2016 06:11
Your "product" is already equal to the calues in "multiplyAll"
Then you change product to 1.
Is you want "1" you must use something else other than product.
Then youre testing j to be less than multiplyAll. Which the computer has no clue what that is.
Markus Kiili
@Masd925
Jun 27 2016 06:13
@akidox JSON is a syntax that allows storing objects in text or string. It resembles JS literal syntax but has stricter rules (~subset of JS literal syntax). You can turn JSON string into JS objects and vice versa. You can write JS literals using stricter JSON rules, but real JSON is text/string.
Z.G.Hao
@akidox
Jun 27 2016 06:17
Need a little more time to figure out.thanks @Masd925 ,your explanation is helpful.
@Masd925 thanks
CamperBot
@camperbot
Jun 27 2016 06:19
:star2: 1978 | @masd925 |http://www.freecodecamp.com/masd925
akidox sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:19
Someone kind enough to help me? I've been stuck trying to solve the escape string challenge. Is there a way to add a screen shot here to show my current situation?
CruftMaster
@CruftMaster
Jun 27 2016 06:19
hey guys
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:20
Someone kind enough to help me? I've been stuck trying to solve the escape string challenge. Escape strings.jpg
Z.G.Hao
@akidox
Jun 27 2016 06:21
what’s the problem? @ @rangelz1 ?
Markus Kiili
@Masd925
Jun 27 2016 06:21
@rangelz1 Copy/paste code here formatted is better than screenshot.
explain format
CamperBot
@camperbot
Jun 27 2016 06:21

: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

CruftMaster
@CruftMaster
Jun 27 2016 06:21
im on the palindrome algorithm, im just wondering. does any one know if there is a function that removes all non-alpha characters and spaces?
silver537
@silver537
Jun 27 2016 06:22
@rangelz1 delete the space between \n and Here
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:22
@akidox Thanks for responding.
CamperBot
@camperbot
Jun 27 2016 06:22
rangelz1 sends brownie points to @akidox :sparkles: :thumbsup: :sparkles:
:cookie: 273 | @akidox |http://www.freecodecamp.com/akidox
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:23
@silver537 Thanks, I'll give it a try
CamperBot
@camperbot
Jun 27 2016 06:23
rangelz1 sends brownie points to @silver537 :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jun 27 2016 06:23
@CruftMaster Use str.replace() and a suitable regexp object.
CamperBot
@camperbot
Jun 27 2016 06:23
:cookie: 374 | @silver537 |http://www.freecodecamp.com/silver537
silver537
@silver537
Jun 27 2016 06:23
@rangelz1 my bad i meant \t and Here
CruftMaster
@CruftMaster
Jun 27 2016 06:24
@Masd925 ok, i will try that
silver537
@silver537
Jun 27 2016 06:27
@rangelz1 didnit work?
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:28
@silver537 didn't work, same problem.
Shraddha Parab
@Shraddha99
Jun 27 2016 06:28
@sumitk121 Ya . Tell me the problem in lookup profile.
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:29
@silver537 at this point, I have no spaces between consecutive escapes. Can' figure out what to do.
Z.G.Hao
@akidox
Jun 27 2016 06:29
Couldn't help you,though @rangelz1
silver537
@silver537
Jun 27 2016 06:29
Post your code again. Your code is correct by logic but fcc wants a specific answer.
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:30
Escape strings.jpg
@akidox I'm trying to find the solution for this:
kirbyedy
@kirbyedy
Jun 27 2016 06:32
@rangelz1 mind the spaces
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:34
@kirbyedy I took off all the spaces and reposed. My code looks like this now and is not working: var myStr = "Here is a backslash:\.\n\t\tHere is a new line with two tabs.";
Shraddha Parab
@Shraddha99
Jun 27 2016 06:34
@rangelz1 tell me the name of the challenge
silver537
@silver537
Jun 27 2016 06:34
@rangelz1 you still have a space between \t and Here. Delete it.
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:35
@silver537 Escape Sequences in Strings
kirbyedy
@kirbyedy
Jun 27 2016 06:35
@rangelz1 after : you need the space
silver537
@silver537
Jun 27 2016 06:35
Now add the space for backlash.
Yeee
Get away picture. Im helping him
kirbyedy
@kirbyedy
Jun 27 2016 06:37
picture is also helping if you look into it
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:37
@silver537 @kirbyedy space right after : ?
kirbyedy
@kirbyedy
Jun 27 2016 06:38
yes
Carlos R. Rangel
@rangelz1
Jun 27 2016 06:38
@kirbyedy @silver537 @akidox It went through. Thanks for the help. (y)
CamperBot
@camperbot
Jun 27 2016 06:38
rangelz1 sends brownie points to @kirbyedy and @silver537 and @akidox :sparkles: :thumbsup: :sparkles:
:warning: rangelz1 already gave akidox points
:warning: rangelz1 already gave silver537 points
:star2: 1158 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
silver537
@silver537
Jun 27 2016 06:43
Yay!!!
Avinash Kuduvalli
@manicmarvin
Jun 27 2016 06:55

Does anyone know what the instructions in 'Make Oject Properties Private' mean? They read:

Modify the Bike constructor to have a private property called gear and two public methods called getGear and setGear to get and set that value.

Which makes very little sense to me, and the instructions in no way seem to help solve all the validator/checks, which are:

The method getGear of myBike should be accessible outside the object.
The method setGear of myBike should be accessible outside the object.
myBike.gear should remain undefined.
myBike.getGear() should return 4 after calling >myBike.setGear(4).
myBike.getGear() should return 3 after calling >myBike.setGear(3).
myBike.getGear() should return 1 after calling >myBike.setGear(1).

silver537
@silver537
Jun 27 2016 06:58
Means you have to declare a variable inside an object to make the variable private. And methods, which are functions inside an object, are the only way you can access that variable.
You dan also create a provate method by declaring it via constructor. But only public mrthods inside an object can access private variables or methods.
Markus Kiili
@Masd925
Jun 27 2016 07:02
@silver537 By definition, methods are properties whose values happen to be functions, so I would not call private functions inside a constructor methods at all.
Justin Chi
@vai0
Jun 27 2016 07:04
Hello, I am stuck on the "Counting Cards" Javascript challenge
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:04
is there a way to combine regular expressions conditions?
var newStr=str.replace(/\d/gi,"");
newStr=newStr.replace(/\s/gi,"");
newStr=newStr.replace(/\W/gi,"");
Justin Chi
@vai0
Jun 27 2016 07:04
Does the function cc expect the argument to only be one value?
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:05
will it work with /\d\s\W/gi?
Justin Chi
@vai0
Jun 27 2016 07:05
I'm having a hard time understanding how they can get values outside of "-1 Hold", "0 Hold", "1 Bet"
when only one argument is fed into the function
rather than the sequence they're mentioning
James Riall
@JamesRiall
Jun 27 2016 07:06
@sherdildeveloper use the | operator
so you can say \d OR \s OR \W
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:06
it should be and ?
Markus Kiili
@Masd925
Jun 27 2016 07:06
@vai0 count is a global variable that changes from function call to another. The passed card should only change count (no returns yet), and then the return value should be figured out from count (not card).
Justin Chi
@vai0
Jun 27 2016 07:07
ah, gotcha
@Masd925 thanks!
CamperBot
@camperbot
Jun 27 2016 07:07
vai0 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1979 | @masd925 |http://www.freecodecamp.com/masd925
Jimmy Huynh
@jkchuynh829
Jun 27 2016 07:07
hello, do you know how to run debugger with repl.io or otherwise? have only figured it out with plnkr
James Riall
@JamesRiall
Jun 27 2016 07:07
@sherdildeveloper var newStr=str.replace(/\d|\s|\W/gi,"");
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:08
@JamesRiall Thanks any idea why its not filtering _?
CamperBot
@camperbot
Jun 27 2016 07:08
sherdildeveloper sends brownie points to @jamesriall :sparkles: :thumbsup: :sparkles:
:cookie: 302 | @jamesriall |http://www.freecodecamp.com/jamesriall
James Riall
@JamesRiall
Jun 27 2016 07:10
@sherdildeveloper it's working for me
@sherdildeveloper
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:10
@JamesRiall 2_A3*3#A2 its returning _AA
James Riall
@JamesRiall
Jun 27 2016 07:11
@sherdildeveloper what do you want it to return?
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:11
only AA
James Riall
@JamesRiall
Jun 27 2016 07:13
@sherdildeveloper do you have to use replace? you could use match for that and just search for word characters
anilkmrck
@anilkmrck
Jun 27 2016 07:13
hi
Bennn123
@Bennn123
Jun 27 2016 07:14
hello world
CamperBot
@camperbot
Jun 27 2016 07:14

welcome to FreeCodeCamp @Bennn123!

anilkmrck
@anilkmrck
Jun 27 2016 07:14
How to solve GolFcode?
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:15
@JamesRiall don't know how to use match, but will have a look
Bennn123
@Bennn123
Jun 27 2016 07:15
if (strokes===1) return "Hole-in-one!";
else if (strokes <= par-2) return "Eagle";
else if (strokes <= par-1) return "Birdie";
else if (strokes <= par) return "Par";
else if (strokes <= par+1) return "Bogey";
else if (strokes <= par+2) return "Double Bogey";
else return "Go Home!";
lt's golfCode
James Riall
@JamesRiall
Jun 27 2016 07:16
@sherdildeveloper or if you need to filter out everything else use this - var newStr=str.replace(/\W|\d/gi,"");
Markus Kiili
@Masd925
Jun 27 2016 07:16
@Bennn123 Giving the solution is not very good way to help. Better way is to give advice.
Bennn123
@Bennn123
Jun 27 2016 07:16
ok
Himmatlal Parmar
@hp785
Jun 27 2016 07:17
Hey guys can you help me out m got stuck with he Convert Celsius to Fahrenheit part in java script
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:17
@JamesRiall it still isn't filtering _
Bennn123
@Bennn123
Jun 27 2016 07:18
who use node.js?
SBeard
@etacalpha
Jun 27 2016 07:18
@hp785 post your code please
kyadondo Timothy
@chadwalt
Jun 27 2016 07:19
Hello how can I use javascript to get the client's default printer
Himmatlal Parmar
@hp785
Jun 27 2016 07:19

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:19
@hp785 why are you returning 30.
you have to modify the value of fahrenheit variable so that your function converts celsius to fahrenheit itself
svexas
@svexas
Jun 27 2016 07:21
could someone explain what ```
for (var i = 0; i < array.length; i++) {
(function(i) { // protects i in an immediately called function
$.getJSON('/api.php?action=query&list=querypage&qppage=' + array[i] + '&format=json', function (data) {
$('#' + array[i]).text(data.query.querypage.results.length);
});
})(i);
}
what (i) after function stands for?
plus please help with formating :D
Pravin
@pravin07p
Jun 27 2016 07:21
how do i update "tracks" in a record collection after updating it with artist column
Himmatlal Parmar
@hp785
Jun 27 2016 07:22
ok thanxx buddy
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:22
@svexas it is calling the function .Search for IIFE(Immediately invoked function expression)
@hp785 np :+1:
Markus Kiili
@Masd925
Jun 27 2016 07:22
@pravin07p If prop is "tracks" make a .hasOwnProperty() or .propertyIsEnumerable() check whether the tracks array exists.
James Riall
@JamesRiall
Jun 27 2016 07:22
@sherdildeveloper sorry, i forgot that underscore is considered a word character. you have two options - you can either exclude the underscore specifically by matching to it individually (using another or operator), or you can go another route and make the replace for all non-letter characters with something like [^A-Z] (^ here signifies everything but what follows)
Himmatlal Parmar
@hp785
Jun 27 2016 07:22
ok buddy will search for it if gets any plm will let u know :)
SBeard
@etacalpha
Jun 27 2016 07:23
@hp785 follow the math Celsius *9/5 + 30 will give you Fahrenheit
svexas
@svexas
Jun 27 2016 07:23
@UtkarshShukla7 thanks, gonna read about it
CamperBot
@camperbot
Jun 27 2016 07:23
svexas sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 734 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:23
@hp785 no you don't have to it was for @svexas
kyadondo Timothy
@chadwalt
Jun 27 2016 07:23
@svexas when iterating through the array using the for loop the function will pick each array value and pass it though that function
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:23
@svexas :+1:
Himmatlal Parmar
@hp785
Jun 27 2016 07:23
@etacalpha ok
sherdildeveloper
@sherdildeveloper
Jun 27 2016 07:23
@JamesRiall thanks
CamperBot
@camperbot
Jun 27 2016 07:23
sherdildeveloper sends brownie points to @jamesriall :sparkles: :thumbsup: :sparkles:
:warning: sherdildeveloper already gave jamesriall points
Himmatlal Parmar
@hp785
Jun 27 2016 07:23
ok @UtkarshShukla7
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:24
:smile:
Pravin
@pravin07p
Jun 27 2016 07:24
so do i have to use it another else if loop after the if condition?? @Masd925
svexas
@svexas
Jun 27 2016 07:24
@chadwalt I understand what function does, but asked what the (i) at the end of the function stands for
Markus Kiili
@Masd925
Jun 27 2016 07:24
@pravin07p Use nested if.
Jason Keenan
@raavin
Jun 27 2016 07:27
@svexas it's just passing the i from the for loop into the function as a parameter, like in any other function. i is the traditional variable in for loops. I think it stands for iterator
Avinash Kuduvalli
@manicmarvin
Jun 27 2016 07:27
@Masd925 @silver537 Thanks!
CamperBot
@camperbot
Jun 27 2016 07:27
manicmarvin sends brownie points to @masd925 and @silver537 :sparkles: :thumbsup: :sparkles:
:cookie: 376 | @silver537 |http://www.freecodecamp.com/silver537
:star2: 1980 | @masd925 |http://www.freecodecamp.com/masd925
Jason Keenan
@raavin
Jun 27 2016 07:27
@svexas actually I just made that up ;)
@svexas so as 'i' increases with each iteration, array[i] moves to the next element in the array
Avinash Kuduvalli
@manicmarvin
Jun 27 2016 07:30
@svexas @raavin actually, for more on the convention of naming the looping variable , like i, j, k... see stackoverflow
kyadondo Timothy
@chadwalt
Jun 27 2016 07:31

@svexas we first declare a variable called “myName” before declaring our function. When declaring our immediate function, we take one argument: “thisName”. At the end of the immediate function declaration, the open/close parentheses pass the variable “myName” to our immediate function. So, not only does this set of open/close parentheses execute the function, it also allows you to pass an argument to that function.
var myName = 'bart Simpson';

(function(thisName){
console.log( 'hello, my name is: ' + thisName );
}(myName))

var myName = 'bart Simpson';

(function(thisName){
console.log( 'hello, my name is: ' + thisName );
}(myName))

Pravin
@pravin07p
Jun 27 2016 07:31
@Masd925 still stuck
Markus Kiili
@Masd925
Jun 27 2016 07:31
@pravin07p Post the code here formatted.
svexas
@svexas
Jun 27 2016 07:32
@raavin I think I worded it badly, but could you explain me the second from the last line of code i? because for me it looks like i could write a function without i at the end and it would work perfectly
Jason Keenan
@raavin
Jun 27 2016 07:32
@manicmarvin Mmmm, interesting
svexas
@svexas
Jun 27 2016 07:32
})(i); (line I need explaining at)
Jason Keenan
@raavin
Jun 27 2016 07:33
@svexas Ahhhh, can you post it formatted properly???
svexas
@svexas
Jun 27 2016 07:33
could you help me format? I tried and failed before :D
kyadondo Timothy
@chadwalt
Jun 27 2016 07:33
@svexas the i is the variable passed to the immediate function check this out http://blog.kevinchisholm.com/javascript/javascript-immediate-functions-basics/
Pravin
@pravin07p
Jun 27 2016 07:33
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
    collection[id][prop].push(value);
  } else if (value !== ""){
    collection[id][prop] = value;
  }  else {
    delete collection[id][prop];
  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
@Masd925 check dis
svexas
@svexas
Jun 27 2016 07:34
@chadwalt that was what i was looking for, thank you very much
CamperBot
@camperbot
Jun 27 2016 07:34
svexas sends brownie points to @chadwalt :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for chadwalt
Markus Kiili
@Masd925
Jun 27 2016 07:34
@svexas Inside the parens earlier, a function expression creates a function (object). (i) invokes it. Without invocation, the function would be created but not run.
Jason Keenan
@raavin
Jun 27 2016 07:35
@svexas click the speech bubbles to the right of the text entry to get in compose mode, then do your backticks, then back to chat mode to post
Markus Kiili
@Masd925
Jun 27 2016 07:35
@pravin07p You have to check that the tracks property exists (the array), before you can push. So make a .hasOwnProperty() check there were you are pushing now.
Sundeep
@pidugusundeep
Jun 27 2016 07:36
hey can anyone help me i want to change the div class name once the select element value is changed, so i added a onchange event to trigger a function document.getElementById("booksdiv").classname = "input-field col s3 push-s3"; and then this isnt working
svexas
@svexas
Jun 27 2016 07:36
@Masd925 thank you too for explaining
CamperBot
@camperbot
Jun 27 2016 07:36
svexas sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1981 | @masd925 |http://www.freecodecamp.com/masd925
shweta rajput
@ShwetaRajput
Jun 27 2016 07:37
can someone help me with stand in line in javascript?
svexas
@svexas
Jun 27 2016 07:37
This message was deleted
var code = "formatted";
Alex T.
@lx-t
Jun 27 2016 07:38
@pidugusundeep It's className, not classname
Markus Kiili
@Masd925
Jun 27 2016 07:38
@svexas JS has 1st class functions, meaning that you can create functions and pass them around and store them on variables (without invoking them).
svexas
@svexas
Jun 27 2016 07:38
@raavin thanks, didn't know that formating help was near the textbox
CamperBot
@camperbot
Jun 27 2016 07:38
svexas sends brownie points to @raavin :sparkles: :thumbsup: :sparkles:
:cookie: 417 | @raavin |http://www.freecodecamp.com/raavin
Sundeep
@pidugusundeep
Jun 27 2016 07:38
@lx-t Whah thanks bruh !
CamperBot
@camperbot
Jun 27 2016 07:38
pidugusundeep sends brownie points to @lx-t :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @lx-t |http://www.freecodecamp.com/lx-t
shweta rajput
@ShwetaRajput
Jun 27 2016 07:39
can someone help me with stand in line function in javascript
svexas
@svexas
Jun 27 2016 07:39
@Masd925 it may sound stupid, but are there any other function classes?
Pravin
@pravin07p
Jun 27 2016 07:39
i Should use push after .hasOwnProperty as well right @Masd925
Sundeep
@pidugusundeep
Jun 27 2016 07:39
@lx-t and then how do i disable a select element with js ?
Markus Kiili
@Masd925
Jun 27 2016 07:40
@pravin07p If the property exists, you can just push value. If not, you can assign [value].
Pravin
@pravin07p
Jun 27 2016 07:41
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
    collection[id][prop].hasOwnProperty(value);
  } else if (value !== ""){
    collection[id][prop] = value;
  }  else {
    delete collection[id][prop];
  }
@Masd925
Markus Kiili
@Masd925
Jun 27 2016 07:41
@svexas Don't really get what you are asking. Using a function expression or function declaration, makes a function object that has Function.prototype as a prototype.
@pravin07p if (collection[id].hasOwnProperty(prop))
kyadondo Timothy
@chadwalt
Jun 27 2016 07:43
how can I get the default printer name on a client machine
sharkmanch
@sharkmanch
Jun 27 2016 07:46
SOS
I dont really understand this part especially when it says // Test Setup
Range Error: Maximum stack size exceeded
sharkmanch
@sharkmanch
Jun 27 2016 07:52

function nextInLine(arr, item) {

  nextInLine([2], 1);// Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
sos here
kirbyedy
@kirbyedy
Jun 27 2016 07:53
nextInLine(2, 1); this line is not good
you have to use push() and shift() methods
matt li
@mattliye
Jun 27 2016 07:54
'''
CamperBot
@camperbot
Jun 27 2016 07:54
:bulb: to format code use backticks! ``` more info
matt li
@mattliye
Jun 27 2016 07:54
```
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:55
@sharkmanch that is calling recursively the function nextInLine without ever returning from it .The function call stack over each other till they get beyond a particular memory threshold.
matt li
@mattliye
Jun 27 2016 07:55
var count = 0;

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

    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;      

  }

  if (count>0){

    return count + "Bet";

  } else {

    return count + "Hold";

  }

  return "Change Me";
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Please help guys, it isn't working this code
Counting Cards
Markus Kiili
@Masd925
Jun 27 2016 07:56
@pravin07p You have the if that checks if prop is tracks and value non-empty. Inside the if block, make a nested if (collection[id].hasOwnProperty(prop))
Pravin
@pravin07p
Jun 27 2016 07:56

var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  if (prop === "tracks" && value !== "") {
     (collection[id].hasOwnProperty(prop)); 
  } if(prop === "tracks" && value !== "") {
    collection[id][prop].push(value);} 
    else if (value !== ""){
    collection[id][prop] = value;
  } else {
    delete collection[id][prop];
  }


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Bennn123
@Bennn123
Jun 27 2016 07:57
how can l understand ""(empty string)
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:57
@mattliye you have to modify value of count in switch statement and return outside switch after checking if count is < or > 0(or whatever value provided)
Actually let me look again
Bennn123
@Bennn123
Jun 27 2016 07:58
case "John":
answer = ""(empty string);
break; I write here it'wrong
matt li
@mattliye
Jun 27 2016 07:59
I got this, I missed a space in the return statement.
UtkarshShukla7
@UtkarshShukla7
Jun 27 2016 07:59
@mattliye return "Change me " is unreachable
@mattliye count + " Hold"
matt li
@mattliye
Jun 27 2016 07:59
thanks.