These are chat archives for FreeCodeCamp/HelpJavaScript

13th
Apr 2016
Vik
@vvang044
Apr 13 2016 00:00 UTC
string.charCodeAt( ) and string.fromCharcode is confusing
im lost reading mdn
marvin veasy
@juniorveasy
Apr 13 2016 00:01 UTC
i got nothing @ndburrus man
Coy Sanders
@coymeetsworld
Apr 13 2016 00:01 UTC
helps to look at the examples @vvang044
Moisés Man
@moigithub
Apr 13 2016 00:01 UTC
sometimes w3school is easier to read @vvang044
Coy Sanders
@coymeetsworld
Apr 13 2016 00:01 UTC
'ABC'.charCodeAt(0); // returns 65
Moisés Man
@moigithub
Apr 13 2016 00:01 UTC
MDN is too much technical
Coy Sanders
@coymeetsworld
Apr 13 2016 00:01 UTC
it returns 65 because thats the ASCII code for the letter 'A'
Vik
@vvang044
Apr 13 2016 00:02 UTC
yeah that part of 65 i have no clue
Coy Sanders
@coymeetsworld
Apr 13 2016 00:03 UTC
each character has a numerical code to represent it
Moisés Man
@moigithub
Apr 13 2016 00:03 UTC
String.fromCharCode(65)<-- return "A"
(notice the Uppercase S from string.. and camelCase on fromCharCode)
Coy Sanders
@coymeetsworld
Apr 13 2016 00:03 UTC
look at the chart i just provided, 65 is A, 66 B, 67 C...etc
the way to convert that code back to a character to put in a String, you use fromCharCode
Norvin Burrus
@ndburrus
Apr 13 2016 00:04 UTC
@juniorveasy alright - let's start here:
js
   if (strokes == 1) {
    return "Hole-in-one!";
  }
Vik
@vvang044
Apr 13 2016 00:04 UTC
ok.....let me read the link you have provided
Norvin Burrus
@ndburrus
Apr 13 2016 00:05 UTC
@juniorveasy can u see the code?
githubusr1
@githubusr1
Apr 13 2016 00:08 UTC
HI, GOOD MORNING
VioletLove
@violetlove26
Apr 13 2016 00:09 UTC

// Only change code below this line

var remainder; 11 % 3 = 2;

What do I have wrong here?

Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:11 UTC
I am converting the switch statement to a look up table, and I am having trouble getting it to work. can someone tell me what I am doing wrong?

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

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

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

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

Norvin Burrus
@ndburrus
Apr 13 2016 00:14 UTC
@Limelightbuzz which challenge is that?
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:14 UTC
hi people
can somebody help me in javascript ?
where do i belong exercise
Norvin Burrus
@ndburrus
Apr 13 2016 00:14 UTC
@Limelightbuzz .. be consistent with ur use of parens
henrywashere
@henrywashere
Apr 13 2016 00:15 UTC

soooo....would this code be correct @coymeetsworld ??

var sentence = "The" + ' ' + myAdjective + ' ' + myNoun + ' ' + myVerb + ' ' + myAdverb;

Norvin Burrus
@ndburrus
Apr 13 2016 00:15 UTC
@Limelightbuzz u used parens with alpha & bravo, but discontued with the others
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:15 UTC
using objects for Lookups, @ndburrus
Norvin Burrus
@ndburrus
Apr 13 2016 00:15 UTC
@Limelightbuzz discontinued*
Coy Sanders
@coymeetsworld
Apr 13 2016 00:15 UTC
close @henrywashere
look at what it outputs, the words will be squashed together
you want to add spaces between them
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:16 UTC
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var myArr = arr.slice(0,arr.length);
  var args = Array.prototype.slice.call(arguments);
  var orderedArray =[];
    myArr.sort(function(a,b){
      return a-b;
    });

    return arr.indexOf(num); 

}
//Menor que el ultimo y mayor que el primero
getIndexToIns([10, 20, 30, 40, 50], 30);
Coy Sanders
@coymeetsworld
Apr 13 2016 00:16 UTC
+ '' + does nothing
also may want to add more Strings like "The" in your sentence
Norvin Burrus
@ndburrus
Apr 13 2016 00:16 UTC
@Limelightbuzz see the issue?
Coy Sanders
@coymeetsworld
Apr 13 2016 00:16 UTC
to make it sound more like English
henrywashere
@henrywashere
Apr 13 2016 00:16 UTC
gotcha
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:16 UTC
@ndburrus i tried it both ways
Norvin Burrus
@ndburrus
Apr 13 2016 00:17 UTC
@Limelightbuzz ok, but in the code u posted, i'm suggesting that u be consistent with parenthesis usage... :)
@Limelightbuzz please address charlie, delta, echo, & foxtrot....
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:19 UTC
okay, @ndburrus . here is the code updated
Norvin Burrus
@ndburrus
Apr 13 2016 00:19 UTC
@Limelightbuzz alright.... please add some parenthesis to those elements
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:19 UTC

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

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

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

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

Norvin Burrus
@ndburrus
Apr 13 2016 00:20 UTC
@Limelightbuzz ok! is it working?
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:20 UTC
no. I've tried it without parenthesis, also
Norvin Burrus
@ndburrus
Apr 13 2016 00:21 UTC
@Limelightbuzz please place a comma after Frank
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:22 UTC
I'll try it later, I'm heading to a JS meetup @ Galvanize.
Thank you, again!
henrywashere
@henrywashere
Apr 13 2016 00:22 UTC
huh, thats weird...i added space between the quotation marks but it wont go through
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:22 UTC
hello somebody can help me in js?
Norvin Burrus
@ndburrus
Apr 13 2016 00:22 UTC
@Limelightbuzz - i think you changed the result line - s/b: result = lookup[val];
@Limelightbuzz oh, i c. u didn't assign a value to result
Limelightbuzz
@Limelightbuzz
Apr 13 2016 00:23 UTC
i didn't. might be a bug. I'll follw up, when i get there
Norvin Burrus
@ndburrus
Apr 13 2016 00:24 UTC
@Limelightbuzz i just gave u the answer... add that statement above return reslt, and u should be fine.
@Limelightbuzz resuilt*
@Limelightbuzz result*
@Limelightbuzz the val ("charlie") inputwill be evaluated in the key/value storage, and assigned the value for "charlie" - which is "Chicago"
@Limelightbuzz is it getting clearer?
@carlospulido which challenge r u working on?
brb
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:28 UTC
Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.

For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).

Likewise, getIndexToIns([20,3,5], 19) should return 2 because once the array has been sorted it will look like [3,5,20] and 19 is less than 20 (index 2) and greater than 5 (index 1).
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  var myArr = arr.slice(0,arr.length);
  var args = Array.prototype.slice.call(arguments);
  var orderedArray =[];
    myArr.sort(function(a,b){
      return a-b;
    });

    return arr.indexOf(num); 

}
//Menor que el ultimo y mayor que el primero
getIndexToIns([10, 20, 30, 40, 50], 30);
Norvin Burrus
@ndburrus
Apr 13 2016 00:31 UTC
@carlospulido im not there yet carlos - sorry.... which challenge is that anyway?
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:32 UTC
@ndburrus Where do I belong
Norvin Burrus
@ndburrus
Apr 13 2016 00:33 UTC
@carlospulido i cant help with that one, sorry. which exercise is it - i cant see the entire text (1st screen/portion)
@carlospulido oh, hey. it scrolls...
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:33 UTC
@ndburrus

Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.

For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).

Likewise, getIndexToIns([20,3,5], 19) should return 2 because once the array has been sorted it will look like [3,5,20] and 19 is less than 20 (index 2) and greater than 5 (index 1).

Norvin Burrus
@ndburrus
Apr 13 2016 00:35 UTC
@carlospulido sorry carlos - i havent done that one yet. i found the challenge though. "javascript lingop: finding and indexing data in arrays"
lingo*
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:36 UTC
ok @ndburrus dont worry ;)
:)
Tyler Moeller
@TylerMoeller
Apr 13 2016 00:37 UTC
@carlospulido I don't see you adding num to the array before sorting and getting the index
henrywashere
@henrywashere
Apr 13 2016 00:41 UTC
thanks @coymeetsworld
CamperBot
@camperbot
Apr 13 2016 00:41 UTC
henrywashere sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 535 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
henrywashere
@henrywashere
Apr 13 2016 00:41 UTC
finally finished this damn exercise
Moisés Man
@moigithub
Apr 13 2016 00:41 UTC
@carlospulido this is NOT needed var args = Array.prototype.slice.call(arguments);
because getIndexToIns([10, 20, 30, 40, 50], 30); u only pass 2 arguments/parameters
and those 2 parameters are NAMed on the funcitn header function getIndexToIns(arr, num) {
(also u not using args anywhere)
John Drevniok
@johndrevniok
Apr 13 2016 00:42 UTC
is for each llop still usable in javascript?
Moisés Man
@moigithub
Apr 13 2016 00:43 UTC
@carlospulido u also NOT using ur orderedArray variable
John Drevniok
@johndrevniok
Apr 13 2016 00:45 UTC
@TylerMoeller Thanks. I guess the the specific for each is deprecated (with the space between) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in
CamperBot
@camperbot
Apr 13 2016 00:45 UTC
johndrevniok sends brownie points to @tylermoeller :sparkles: :thumbsup: :sparkles:
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:45 UTC
yes i delete it variable now
CamperBot
@camperbot
Apr 13 2016 00:45 UTC
:star: 492 | @tylermoeller | http://www.freecodecamp.com/tylermoeller
Tyler Moeller
@TylerMoeller
Apr 13 2016 00:46 UTC
@johndrevniok You taught me something new, thanks :) Never learned that one.
CamperBot
@camperbot
Apr 13 2016 00:46 UTC
tylermoeller sends brownie points to @johndrevniok :sparkles: :thumbsup: :sparkles:
:star: 126 | @johndrevniok | http://www.freecodecamp.com/johndrevniok
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:48 UTC
@moigithub and now?
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.slice(0,arr.length);
  num = Array.prototype.slice.call(arguments);
  arr.push(num);
    arr.sort(function(a,b){
      return a-b;

    });

    return arr.indexOf(num); 

}
//Menor que el ultimo y mayor que el primero
getIndexToIns([10, 20, 30, 40, 50], 10);
Tyler Moeller
@TylerMoeller
Apr 13 2016 00:48 UTC
@carlospulido You are very close - just add num to the array with an arr.push, then arr.sort like you're already doing with myArr, and then return arr.indexOf(num).
Moisés Man
@moigithub
Apr 13 2016 00:48 UTC
u forgot push num..
ahh i see it
remove this num = Array.prototype.slice.call(arguments);
and this arr.slice(0,arr.length);
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:51 UTC
thsnks @moigithub Thank had in the previous fiscal year Mixed Ideas
CamperBot
@camperbot
Apr 13 2016 00:51 UTC
carlospulido sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star: 892 | @moigithub | http://www.freecodecamp.com/moigithub
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:51 UTC
jajaj google traductor fail
jajaja
i mixin it with challenge seek and destroy in my brain :)
now run !!
;)
bitgrower
@bitgrower
Apr 13 2016 00:53 UTC
interesting gitter change ... I like it ... but it will take me a few minutes to get used to not typing the first name I see ...
Moisés Man
@moigithub
Apr 13 2016 00:56 UTC
@carlospulido https://gitter.im/FreeCodeCamp/Espanol
tambien puedes preguntar por ahi :)
no translator needed :P
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:57 UTC
gracias moises
he entrado muchas veces pero casi nunca hay gente :)
Moisés Man
@moigithub
Apr 13 2016 00:57 UTC
de nada :)... ahora a meme a la tutu :)
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:57 UTC
? meme ??
tutu?
Moisés Man
@moigithub
Apr 13 2016 00:57 UTC
dormir
Carlos Pulido
@carlosfrontend
Apr 13 2016 00:58 UTC
ahhh
aqui se dice a dormir o a sobar
ir a la cama === irse al sobre
jejej
para los niños pequeños se dice mimir es parecido
Si mañana más y mejor gracias por tu ayuda me voy a meme a la tutu :)
good bye all people !
bitgrower
@bitgrower
Apr 13 2016 01:12 UTC
hasta la vista, @carlospulido ... you may have me pulling out my spanish books ... :)
Tien Anh Nguyen
@tienanh2007
Apr 13 2016 01:36 UTC
help validate US Telephone Numbers
CamperBot
@camperbot
Apr 13 2016 01:36 UTC

:point_right: algorithm validate us telephone numbers [wiki]

Problem Explanation:

  • The task is not that hard to understand, implementing it is the hardest part. You have a to validate an US phone number. This means there is a certain amount of numbers required, while you don't need to put the country code, you will still need the area code and use one of the few formats allowed.
:pencil: read more about algorithm validate us telephone numbers on the FCC Wiki
Louis
@samfisher6
Apr 13 2016 01:45 UTC
Screen Shot 2016-04-12 at 6.43.39 PM.png
can some one give a pointer i don't want the answer
i reversed the strings but It's not marking it as correct
Screen Shot 2016-04-12 at 6.43.45 PM.png
bitgrower
@bitgrower
Apr 13 2016 01:47 UTC
you need to put your code within the function, and then use the parameter passed to the function @samfisher6
CodeFay
@CodeFay
Apr 13 2016 01:48 UTC
@samfisher6 you got the basic idea, but the question is asking each string to be reversed, not an array of strings. Just like @bitgrower described
bitgrower
@bitgrower
Apr 13 2016 01:50 UTC
yep -- no need to create your own array of strings ... the challenge will send you, in the parameter passed, the string (just one word for the first 3) that needs to be reversed ...
Louis
@samfisher6
Apr 13 2016 01:54 UTC
sorry I'm not sure i understand
Norvin Burrus
@ndburrus
Apr 13 2016 01:55 UTC
anyone have questions on javascript challenges? i'm not finished with the js section, but can assist with those i've completed....
Jared Pranke
@EtherWolf
Apr 13 2016 01:56 UTC
This message was deleted
CodeFay
@CodeFay
Apr 13 2016 02:00 UTC
@samfisher6 Have you encountered the "Profile Lookup" under Basic Javascript? (It's before the algorithms, so I'm hoping you may have)... that kind of shows an example of how they are calling the function vs hardcoding the array of what they're resting
@samfisher6 Another way to think about it is... for the reverseString function, you want to write a function that you can call, no matter what your input is. Vs hardcoding your query into the function
so... if you wanted to add two numbers , the code would say something like "return a + b;", but the function would be addNumbers(a,b)
Louis
@samfisher6
Apr 13 2016 02:02 UTC
ah ok thanks
CodeFay
@CodeFay
Apr 13 2016 02:02 UTC
:) no worries! happy to help
Jas
@JB2016
Apr 13 2016 02:05 UTC
help Split Strings
CamperBot
@camperbot
Apr 13 2016 02:05 UTC

:point_right: challenge split strings with split [wiki]

You can use the .split() method to split a string into an array.

split uses the argument you give to to split the string.

array = string.split(' ');
:pencil: read more about challenge split strings with split on the FCC Wiki

Jas
@JB2016
Apr 13 2016 02:05 UTC
help Split Strings with split
CamperBot
@camperbot
Apr 13 2016 02:05 UTC

:point_right: challenge split strings with split [wiki]

You can use the .split() method to split a string into an array.

split uses the argument you give to to split the string.

array = string.split(' ');
:pencil: read more about challenge split strings with split on the FCC Wiki

reedhammond
@reedhammond
Apr 13 2016 02:05 UTC
Hello. Could someone please help me with this challenge:
Use the \d selector to select the number of numbers in the string, allowing for the possibility of one or more digit.

// Setup
var testString = "There are 3 cats but 4 dogs.";

// Only change code below this line.

var expression = /\3+4/g; // Change this line

// Only change code above this line

// This code counts the matches of expression in testString
var digitCount = testString.match(expression).length;

Yomi
@Joll59
Apr 13 2016 02:06 UTC
@CodeFay I am actaully on"Profile Lookup" in basic javascript
reedhammond
@reedhammond
Apr 13 2016 02:06 UTC
I can not figure out what I am doing wrong
Yomi
@Joll59
Apr 13 2016 02:06 UTC
can i burrow a second set of eyes
Jas
@JB2016
Apr 13 2016 02:06 UTC
@reedhammond \d+
reedhammond
@reedhammond
Apr 13 2016 02:07 UTC
/\d+3+4/g;
LIke that?
Jas
@JB2016
Apr 13 2016 02:07 UTC
@reedhammond na just \d no 3+4
Coy Sanders
@coymeetsworld
Apr 13 2016 02:07 UTC
remove +3+4
\d matches a digit
Jas
@JB2016
Apr 13 2016 02:07 UTC
@reedhammond where counting any digits
Tiffany White
@twhite96
Apr 13 2016 02:07 UTC
@ndburrus I am at Return Early Pattern for Functions
reedhammond
@reedhammond
Apr 13 2016 02:07 UTC
Thanks so much!
Tiffany White
@twhite96
Apr 13 2016 02:08 UTC
And I am a bit stuck
Yomi
@Joll59
Apr 13 2016 02:08 UTC
for (var a = 0; a < contacts.length; a++)
    {
      if (firstName == contacts[a].firstName && contacts[a].hasOwnProperty(prop))
        {
          return contacts[a][prop];} 
     else if (firstName != contacts[a].firstName) 
            {
              return "No such contact";}
           else if (prop != contacts[a].prop)
                { 
                  return "No such property";}
    }
please take a look anyone and tell me where i am screwing this thing up. This is for Profile LookUp
Norvin Burrus
@ndburrus
Apr 13 2016 02:08 UTC
@twhite96 Hi Tiffany, ok let's take a look
Jas
@JB2016
Apr 13 2016 02:09 UTC
@reedhammond can you put @JB2016 then thanks :)))
CamperBot
@camperbot
Apr 13 2016 02:09 UTC
jb2016 sends brownie points to @reedhammond :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for reedhammond
Tiffany White
@twhite96
Apr 13 2016 02:09 UTC
@ndburrus I know I don't need to initialize these variables
I don't want to define them
Jas
@JB2016
Apr 13 2016 02:09 UTC
@Joll59 try just a simple if (contacts[a][prop])
Tiffany White
@twhite96
Apr 13 2016 02:10 UTC
But they are asking if a or b is less that 0
Norvin Burrus
@ndburrus
Apr 13 2016 02:10 UTC
@twhite96 ok, so far, so good...
Tiffany White
@twhite96
Apr 13 2016 02:10 UTC
And I am confused as to what to put in the console.log statement
Jas
@JB2016
Apr 13 2016 02:10 UTC
@Joll59 you shouldn't need .hasOwnProp
Alex
@MisterM22
Apr 13 2016 02:10 UTC
hint
CamperBot
@camperbot
Apr 13 2016 02:10 UTC
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Tiffany White
@twhite96
Apr 13 2016 02:11 UTC
@ndburrus I have set each variable less than 0 but I know that isn't the right thing to do
Norvin Burrus
@ndburrus
Apr 13 2016 02:11 UTC
@twhite96 ok, we're only going to focus on the code between the comments to be changed?
Tiffany White
@twhite96
Apr 13 2016 02:11 UTC
@ndburrus yes
Norvin Burrus
@ndburrus
Apr 13 2016 02:12 UTC
@twhite96 ok, so, based on what the challenge is asking for - a/b conditions, which function do u suppose u'd like to use?
Tiffany White
@twhite96
Apr 13 2016 02:13 UTC
@ndburrus so I should add my own function in here?
Norvin Burrus
@ndburrus
Apr 13 2016 02:13 UTC
@twhite96 just a moment - u said u are considering setting values for a/b. wait - is that really what ur after - or are u seeking a comparison result?
Louis
@samfisher6
Apr 13 2016 02:14 UTC
Screen Shot 2016-04-12 at 7.13.26 PM.png
thanks everyone that took me a while
Tiffany White
@twhite96
Apr 13 2016 02:14 UTC

@ndburrus here are the instructions: Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Hint
Remember that undefined is a keyword, not a string.

Norvin Burrus
@ndburrus
Apr 13 2016 02:14 UTC
let's think about the objective. u want to see what? can u post ur code?
Tiffany White
@twhite96
Apr 13 2016 02:15 UTC
Here is the code:
// Setup
function abTest(a, b) {
  // Only change code below this line 
  console.log(-a < 0 || -b < 0 );
  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Norvin Burrus
@ndburrus
Apr 13 2016 02:15 UTC
@twhite96 ok, lets take a look...
Tiffany White
@twhite96
Apr 13 2016 02:16 UTC
// Setup

function abTest(a, b) {
  // Only change code below this line 
  console.log(-a < 0 || -b < 0 );
  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Norvin Burrus
@ndburrus
Apr 13 2016 02:16 UTC
@twhite96 hmmm... that looks like one way to proceed. question: why are a & b negative?
Tiffany White
@twhite96
Apr 13 2016 02:17 UTC
I just tested it a few minutes ago. They aren't supposed to be @ndburrus
Norvin Burrus
@ndburrus
Apr 13 2016 02:17 UTC
@twhite96 ok, so lets get rid of that/those
Tiffany White
@twhite96
Apr 13 2016 02:17 UTC
@ndburrus using this without the -a/b doesn't pass all the tests
@ndburrus abTest(-2,2) doesn't pass neither does abTest(2,-2)
The rest do
Norvin Burrus
@ndburrus
Apr 13 2016 02:19 UTC
@twhite96 i approached this one differently using if, else if statements. but, the challenge specifically states (or requests) that a & b be evaluated against/compared to 0.
Tiffany White
@twhite96
Apr 13 2016 02:19 UTC
Okay
Norvin Burrus
@ndburrus
Apr 13 2016 02:20 UTC
@twhite96 let's focus on interpretting the challenge and not the results. the results will follow a proper understanding of the challenge, won't it?
Tiffany White
@twhite96
Apr 13 2016 02:20 UTC
@ndburrus I suppose
Norvin Burrus
@ndburrus
Apr 13 2016 02:20 UTC
@twhite96 so, what types of values should a & b be? (hint: positive or negative)
@twhite96 based on the challenge text
@twhite96 instructions (1st & 2nd lines)
Tiffany White
@twhite96
Apr 13 2016 02:21 UTC
So it should be negative @ndburrus
Norvin Burrus
@ndburrus
Apr 13 2016 02:22 UTC
@twhite96 are a & b positive or negative in the challenge?
Tiffany White
@twhite96
Apr 13 2016 02:22 UTC
They are both positive-- abTest(2,2)
Norvin Burrus
@ndburrus
Apr 13 2016 02:22 UTC
@twhite96 don't guess. just look at the red a & b. did they put a negative sign on those?
Tiffany White
@twhite96
Apr 13 2016 02:23 UTC
They are positive.
Norvin Burrus
@ndburrus
Apr 13 2016 02:23 UTC
@twhite96 ok, bingo. using ur method - do those values work?
Tiffany White
@twhite96
Apr 13 2016 02:23 UTC
No
Norvin Burrus
@ndburrus
Apr 13 2016 02:23 UTC
@twhite96 hmmm...moment
Yomi
@Joll59
Apr 13 2016 02:23 UTC
@JB2016 i made the changes and still not working..... this is what it looks like now.
```
ffs
 for (var a = 0; a < contacts.length; a++)
    {if (contacts[a].firstName == firstName)
      {if (contacts[a][prop])
        {return contacts[a][prop];} 
         else {return "No such property";}}
            else {return "No such contact";}
    }
lol
Tiffany White
@twhite96
Apr 13 2016 02:24 UTC
Your return statements shouldn't be inside those brackets @Joll59
Norvin Burrus
@ndburrus
Apr 13 2016 02:24 UTC
@twhite96 ok, it looks like u aren't requesting that anything be done if the condition/s is /are met.
Tiffany White
@twhite96
Apr 13 2016 02:25 UTC
Ahhhh @ndburrus
Norvin Burrus
@ndburrus
Apr 13 2016 02:25 UTC
@twhite96 what would u like to be done if the conditions are met?
Tiffany White
@twhite96
Apr 13 2016 02:25 UTC
I need the function to exit with an undefined
Norvin Burrus
@ndburrus
Apr 13 2016 02:25 UTC
@twhite96 the comp did the evaluation, just like u asked it to. then it did nothing - because u didn't request any action, no?
Yomi
@Joll59
Apr 13 2016 02:26 UTC
@twhite96 what do you mean?
Tiffany White
@twhite96
Apr 13 2016 02:26 UTC
Yeah but I don't understand how to get the function to quit with undefined unless I add another return statement to return undefined @ndburrus
Norvin Burrus
@ndburrus
Apr 13 2016 02:26 UTC
@twhite96 i (and the comp) - see no request/function that produces undefined
@twhite96 hmmmm... that sounds like an idea worth trying....
Tiffany White
@twhite96
Apr 13 2016 02:27 UTC
@Joll59 Usually return statements aren't inside brackets. For instance your code should look like this:
tekac
@tekac
Apr 13 2016 02:27 UTC
^
Norvin Burrus
@ndburrus
Apr 13 2016 02:28 UTC
@twhite96 i dont see any code - or example
Jas
@JB2016
Apr 13 2016 02:29 UTC
Hey, does anyone know why for Factorialize a Number: factorialize(0) should return 1.
Norvin Burrus
@ndburrus
Apr 13 2016 02:29 UTC
@twhite96 i haven't using ur methodolgy, but i think ur right that u need the return statement to get a "undefined" result
tekac
@tekac
Apr 13 2016 02:30 UTC
doesn't just return; work as undefined? am I worng?
wrong*
cannelflow
@cannelflow
Apr 13 2016 02:30 UTC
@twhite96 if(a is less then 0 or b is less then 0) return undefined @twhite96
Norvin Burrus
@ndburrus
Apr 13 2016 02:31 UTC
@twhite96 btw, i used return statements inside curly braces/brackets in if/esle if statements
Tiffany White
@twhite96
Apr 13 2016 02:31 UTC
 for (var a = 0; a < contacts.length; a++ {
   if  (contacts[a].firstName == firstName) {
if (contacts[a][prop]) {
        return contacts[a][prop];
}  else {
        return "No such property";
} else {
         return "No such contact";}
    } 
}
tekac
@tekac
Apr 13 2016 02:31 UTC
shouldn't it be a if then else if and then else?
I'm new.. but just my 2cents
Gerard Jorgensen
@gerardjorgensen
Apr 13 2016 02:32 UTC
Hey I'm having trouble with the order the code runs on codepen. Test2 should print first but I guess code pend goes through that later??? Here is my codepen link http://codepen.io/GerardJ/pen/RaQPQm?editors=1010
tekac
@tekac
Apr 13 2016 02:32 UTC
holy moly @cannelflow
Yomi
@Joll59
Apr 13 2016 02:33 UTC
@twhite96 did you delete some of the brackets or just move them around so they arent on same line?
Norvin Burrus
@ndburrus
Apr 13 2016 02:33 UTC
js
<// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a < 0) {
    return undefined;
  }
  else if (b < 0) {
    return undefined;
  }


  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);>
Jas
@JB2016
Apr 13 2016 02:33 UTC
@cannelflow Thank you
CamperBot
@camperbot
Apr 13 2016 02:33 UTC
jb2016 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 1059 | @cannelflow | http://www.freecodecamp.com/cannelflow
Norvin Burrus
@ndburrus
Apr 13 2016 02:33 UTC
@twhite96 take a look
Tiffany White
@twhite96
Apr 13 2016 02:33 UTC
@Joll59 Apparently you can have return statements inside brackets. Your code is really hard to read though
Norvin Burrus
@ndburrus
Apr 13 2016 02:34 UTC
@twhite96 can u try it in ur code?
cannelflow
@cannelflow
Apr 13 2016 02:35 UTC
@ndburrus i think this won't pass abTest(2,-2)
Tiffany White
@twhite96
Apr 13 2016 02:35 UTC
@ndburrus yeah I did
It works
Jas
@JB2016
Apr 13 2016 02:35 UTC
@Joll59 you're so close
Norvin Burrus
@ndburrus
Apr 13 2016 02:35 UTC
@twhite96 Shazzam!!!
Jas
@JB2016
Apr 13 2016 02:35 UTC
 for (var a = 0; a < contacts.length; a++)
    {if (contacts[a].firstName == firstName)
      {if (contacts[a][prop]){return contacts[a][prop];} 
         else {return "No such property";}}
            else {return "No such contact";}
    }
ignore that accidentally hit enter
Norvin Burrus
@ndburrus
Apr 13 2016 02:36 UTC
@twhite96 ...so u got it?
Tiffany White
@twhite96
Apr 13 2016 02:36 UTC
@JB2016 why is the code all on one line like that? It makes it hard to read
Yomi
@Joll59
Apr 13 2016 02:36 UTC
@JB2016 i knew i was close, it bothers me that i didnt figure out already
@twhite96 for you
Tiffany White
@twhite96
Apr 13 2016 02:36 UTC
@ndburrus yep. I wasn’t sure about the if else if thing. I guess I should have known
Jas
@JB2016
Apr 13 2016 02:37 UTC
 for (var a = 0; a < contacts.length; a++)
    {if (contacts[a].firstName == firstName)
      {if (contacts[a][prop]){
            return contacts[a][prop];
       } else {
          return "No such property";}
       }     
} 
return "No such contact";
Norvin Burrus
@ndburrus
Apr 13 2016 02:37 UTC
@twhite96 head up, u learned something!
Tiffany White
@twhite96
Apr 13 2016 02:37 UTC
@Joll59 I had never seen return statements inside of brackets. Newb. Ha. 😁
Jas
@JB2016
Apr 13 2016 02:38 UTC
@twhite96 wasn't my code - just copied and pasted and accidentally hit enter
Tiffany White
@twhite96
Apr 13 2016 02:38 UTC
@ndburrus this frustrates me that I didn’t think of that already
@JB2016 no worries
Norvin Burrus
@ndburrus
Apr 13 2016 02:38 UTC
@twhite96 the example shows a return statement inside curly braces/brackets.... :)
Yomi
@Joll59
Apr 13 2016 02:38 UTC
@JB2016 i am trying to figure out what you did differently
Jas
@JB2016
Apr 13 2016 02:39 UTC
return "No such contact" outside of for loop
Tiffany White
@twhite96
Apr 13 2016 02:39 UTC
@ndburrus why would you do that, though?
Norvin Burrus
@ndburrus
Apr 13 2016 02:39 UTC
@twhite96 no frustration allowed - ur in ur happy place.... :)
@twhite96 ...do what?
Tiffany White
@twhite96
Apr 13 2016 02:39 UTC
@ndburrus haha. It was such a simple thing
@ndburrus put a return statement in brackets
Jas
@JB2016
Apr 13 2016 02:39 UTC
@Joll59 basically if not found return "No such contact"
Yomi
@Joll59
Apr 13 2016 02:40 UTC
i see, i was thinking was too literal when i created the code. Thank you
Norvin Burrus
@ndburrus
Apr 13 2016 02:40 UTC
@twhite96 well, the brackets identify whatever it is u would like to have done if the conditions are met, don't they?
Yomi
@Joll59
Apr 13 2016 02:41 UTC
@JB2016, that still doesnt clear the test
lol
Norvin Burrus
@ndburrus
Apr 13 2016 02:41 UTC
brb
Yomi
@Joll59
Apr 13 2016 02:41 UTC
I swear this thing i trying to haunt me
Tiffany White
@twhite96
Apr 13 2016 02:41 UTC
@ndburrus I suppose.
Jas
@JB2016
Apr 13 2016 02:41 UTC
@Joll59 don't worry I did the same thing, was so annoyed that if (contacts[a][prop]) simply returned true or false and if false return "No such prop" but it helps that you know that boolean expression now :)
@Joll59 I think I missed a }
@Joll59 ```
 for (var a = 0; a < contacts.length; a++)
    {if (contacts[a].firstName == firstName)
      {if (contacts[a][prop]){
            return contacts[a][prop];
       } else {
          return "No such property";}
       }     
} 
return "No such contact";
Yomi
@Joll59
Apr 13 2016 02:44 UTC
@JB2016 i didn't
Ken Haduch
@khaduch
Apr 13 2016 02:44 UTC
@gerardjorgensen - you are seeing the effects of the lag that usually takes place in an AJAX request. The call to navigator.geolocation.getCurrentPosition has a callback function that is activated when that function returns. I don't think that they really emphasize then when they introduce you to that function. But what happens is that it posts a request to (wherever it goes) and some time later it returns that values and calls your anonymous function. But in the meantime, the straight-line code in your ready function has executed so it prints "test1" first. Finally, when the getCurrentPosition returns the value, your callback is invoked.
Jas
@JB2016
Apr 13 2016 02:44 UTC
@Joll59 ```
 for (var a = 0; a < contacts.length; a++){
      if (contacts[a].firstName == firstName){
          if (contacts[a][prop]){
            return contacts[a][prop];
          } else {
              return "No such property";}
          }
      }     
} 
return "No such contact";
Ken Haduch
@khaduch
Apr 13 2016 02:45 UTC

@gerardjorgensen - so you have to wait for that event to complete before you have the latitude and longitude to be able to use it in the call to the weather API.

I hope that is a clear explanation?

Norvin Burrus
@ndburrus
Apr 13 2016 02:45 UTC
@twhite96 ok, that didn't sound like u are convinced... take another look at the Example:
Jas
@JB2016
Apr 13 2016 02:45 UTC
@Joll59 post your code?
Yomi
@Joll59
Apr 13 2016 02:45 UTC
@JB2016 lol, i still hadnt moved the return statement to outside the for loop
no need, i got it
@JB2016 thank you sir
CamperBot
@camperbot
Apr 13 2016 02:46 UTC
joll59 sends brownie points to @jb2016 :sparkles: :thumbsup: :sparkles:
Jas
@JB2016
Apr 13 2016 02:46 UTC
@Joll59 classic
Yomi
@Joll59
Apr 13 2016 02:46 UTC
or maam
CamperBot
@camperbot
Apr 13 2016 02:46 UTC
:star: 255 | @jb2016 | http://www.freecodecamp.com/jb2016
Tiffany White
@twhite96
Apr 13 2016 02:46 UTC
@ndburrus no I get it. Just not sure why I can’t do that now
I guess I’m just not there yet
Yomi
@Joll59
Apr 13 2016 02:46 UTC
@twhite96 thank you for the tips
Norvin Burrus
@ndburrus
Apr 13 2016 02:46 UTC
js
<function myFun() {
  console.log("Hello");
  return "World";
  console.log("byebye")
}
myFun();>
CamperBot
@camperbot
Apr 13 2016 02:46 UTC
:star: 237 | @twhite96 | http://www.freecodecamp.com/twhite96
joll59 sends brownie points to @twhite96 :sparkles: :thumbsup: :sparkles:
Tiffany White
@twhite96
Apr 13 2016 02:46 UTC
I don’t understand when I should use it and when I shouldn’t @ndburrus
You’re welcome @Joll59
Norvin Burrus
@ndburrus
Apr 13 2016 02:47 UTC
@twhite96 do what now? ... {see the return inside of brackets, in the example?}
Tiffany White
@twhite96
Apr 13 2016 02:47 UTC
@ndburrus yeah
Norvin Burrus
@ndburrus
Apr 13 2016 02:49 UTC
@twhite96 Definition and Usage
The return statement stops the execution of a function and returns a value from that function.
@twhite96 there are some examples of return statements at http://www.w3schools.com/jsref/jsref_return.asp
brb
Ken Haduch
@khaduch
Apr 13 2016 02:55 UTC
@twhite96 - if you don't mind my chiming in - you use it when you need to! Sometimes the function is supposed to check the arguments to make sure that they are not undefined, or that they are valid numbers. If they are not the type of value as required, usually you return and undefined or null or something like that, perhaps an error message. (I think that there are some challenges or algorithms that use that type of requirement.) In the case of this "contacts" processing, you could make a more complicated type of control mechanism to make it that you would only have one return statement, but it is much more direct to return from the function when you know that you have the correct condition - either the property that was being requested, the "no such property" status, or lastly the "no such contact" status. As I said, you could write it to have only one return statement, but you would have to add additional logic to the code to make it work.
Tiffany White
@twhite96
Apr 13 2016 02:56 UTC
Ahhh Okay @khaduch thanks
CamperBot
@camperbot
Apr 13 2016 02:56 UTC
twhite96 sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 926 | @khaduch | http://www.freecodecamp.com/khaduch
Sumit Roy
@sroy8091
Apr 13 2016 03:02 UTC

//Setup
var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i][firstName]===firstName){
for(var j=0; j<contacts[i].length; j++){
if(contacts[i][j]==prop){
return contacts[i][prop];
}
else{
return "No such property";
}
}
}
else{
return "No such contact";
}
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

whats wrong in this code/
goodm0urning
@goodm0urning
Apr 13 2016 03:04 UTC
Anyone here familiar with JSON?
Jas
@JB2016
Apr 13 2016 03:04 UTC
@sroy help code
Norvin Burrus
@ndburrus
Apr 13 2016 03:05 UTC
@sroy8091 what challenge is that?
Sumit Roy
@sroy8091
Apr 13 2016 03:05 UTC
profile lookup
Jas
@JB2016
Apr 13 2016 03:05 UTC
@sroy8091 if you scroll up the solution is there
@sroy8091 someone just asked the same question
goodm0urning
@goodm0urning
Apr 13 2016 03:06 UTC
I'm trying to do the Record Collection challenge, and only need to figure out how to add something to the end of the "tracks" array
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "ABBA");
Jas
@JB2016
Apr 13 2016 03:06 UTC
@sroy8091 your really close, remove}}
tekac
@tekac
Apr 13 2016 03:07 UTC
@goodm0urning use brackets for the id and props
collection[id][prop]push(value);
Yomi
@Joll59
Apr 13 2016 03:08 UTC
@sroy8091 I also think you may have too many for statements....I could be wrong since I am super noob.
Sumit Roy
@sroy8091
Apr 13 2016 03:08 UTC
i'm not understanding what r u saying? @JB2016
goodm0urning
@goodm0urning
Apr 13 2016 03:08 UTC
AH! Snap! Thanks @tekac
CamperBot
@camperbot
Apr 13 2016 03:08 UTC
goodm0urning sends brownie points to @tekac :sparkles: :thumbsup: :sparkles:
:star: 231 | @tekac | http://www.freecodecamp.com/tekac
Yomi
@Joll59
Apr 13 2016 03:09 UTC
@sroy8091 if you scroll up you'll see my code and @JB2016 solution. You are very freaking close.
Ken Haduch
@khaduch
Apr 13 2016 03:09 UTC

@sroy8091 - a few things that you need to adjust...

  • contacts is an array of objects, so your first for loop to look through that array is right on the money
  • this is not correct: if(contacts[i][firstName]===firstName){. You can just access the object property for firstName with contacts[i].firstName, although I think that if you did this: contacts[i]["firstName"] it would be equivalent. The previous method is more clean-looking.
  • since the elements of the array are objects, you cannot (and do not) use a for loop to process the properties. They mention the .hasOwnProperty() method. You can use that directly to look for the property that they request.
  • with the code formatted as it is, and those errors, I cannot tell if you have the other common problem, which is that many who struggle with this challenge have the return "No such contact"; within the for loop that is processing the contacts array. That can be problematic if you are required to search beyond the first contact - you need to see all of the contacts in the array before you can determine that you cannot find the one that exists.

I hope that helps?

Jas
@JB2016
Apr 13 2016 03:10 UTC
@sroy8091 and you have two for statements
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length; i++){
if(contacts[i][firstName]===firstName){
for(var j=0; j<contacts[i].length; j++){  \\ and remove this
if(contacts[i][j]==prop){
return contacts[i][prop];
}
else{
return "No such property";
}
}
}
else{
return "No such contact";
}  \\ remove these
}
// Only change code above this line
}
@goodm0urning use push :)
Has anyone done palidromes yet?
Sumit Roy
@sroy8091
Apr 13 2016 03:14 UTC
gotcha. thanks @JB2016 @khaduch @Joll59
CamperBot
@camperbot
Apr 13 2016 03:14 UTC
sroy8091 sends brownie points to @jb2016 and @khaduch and @joll59 :sparkles: :thumbsup: :sparkles:
:star: 237 | @joll59 | http://www.freecodecamp.com/joll59
:star: 257 | @jb2016 | http://www.freecodecamp.com/jb2016
:star: 927 | @khaduch | http://www.freecodecamp.com/khaduch
MBJ
@mbjusa
Apr 13 2016 03:29 UTC
hello world
CamperBot
@camperbot
Apr 13 2016 03:29 UTC

welcome to FreeCodeCamp @mbjusa!

ulucay
@ulucay
Apr 13 2016 03:32 UTC
guys
I wanna ask you something
Gerard Jorgensen
@gerardjorgensen
Apr 13 2016 03:34 UTC
@khaduch Oh ok that makes sense I'll try to find ways to somehow wait till it returns something. Thank you!
CamperBot
@camperbot
Apr 13 2016 03:34 UTC
gerardjorgensen sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 928 | @khaduch | http://www.freecodecamp.com/khaduch
Robert Friedman
@robfr77
Apr 13 2016 03:37 UTC
Can anyone suggest why this is not passing Finders Keepers?
function findElement(arr, func) {
  var result = "";
  arr = arr.filter(func);

  arr = arr.splice(0,1);
  result += arr;
  if (result.length > 0) {
  return result;
  }
  else {
    return undefined;
  }
}

findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; });
Coy Sanders
@coymeetsworld
Apr 13 2016 03:40 UTC
just return arr[0]; @robfr77
you don't need to splice the array or check for the length
Robert Friedman
@robfr77
Apr 13 2016 03:42 UTC
derp
Coy Sanders
@coymeetsworld
Apr 13 2016 03:42 UTC
:)
Robert Friedman
@robfr77
Apr 13 2016 03:43 UTC
@coymeetsworld :D
Guillermo Agudelo
@guillermo7227
Apr 13 2016 03:49 UTC
Hellow fellow campers. Could someone please help me pass this challenge https://www.freecodecamp.com/challenges/smallest-common-multiple . Here is the code I'm using http://pastebin.com/AwPU4X2p . It does well when range of numbers is ten or less, for instance, f(1,5), but when the range is greater than then, f(1,13), it enter into a kind of infinite loop and I'm not sure why. Could you please take a look at it?
*ten not then
Sean
@ofperfection
Apr 13 2016 03:52 UTC
function fearNotLetter(str) {
  console.clear();
 var newStr = str.slice();
  //create reference to test against
  var checker = newStr.split("");
  console.log("this is the check split array " + checker);

  var last = checker.length-1;
  var checkerLast = checker[last];
  console.log("this is how long it thinks the checker is minus one " + last);

  var answer = [];

   var alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];

  var start = alphabet.indexOf(checker[0]);
  console.log("this is the start variable " + start);
  var end = alphabet.indexOf(checkerLast);
  console.log("this is the end variable " + end);

  var verify = alphabet.slice(start,end+1);
 //if the variable is z, allow for a full slice
  if(end>24 || end<0){
    verify = alphabet.slice(start);
  }

   console.log("this is the verify variable " + verify);

  var same = verify.join("");
  console.log("this is the same variable " + same);

  if(str==same){
    return undefined;
  }
  //start checking for differences between verify and checker


 // A = [1, 2, 3, 4];
//B = [1, 3, 4, 7];

var diff = checker.filter(function(x) { return verify.indexOf(x) < 0 ;});
    console.log(diff);


  return diff;
}

fearNotLetter("bcd");
can anyone help me use the filter function?
I've googled it
and tried multiple iterations
but the console.log isn't returning anything
and I want to learn the .filter method instead of using nested for loops
hrokr
@hrokr
Apr 13 2016 03:56 UTC
@goodm0urning @tekac -- I'm on the same exercise and have an (almost working) solution of a different sort:
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

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

  return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Coryphaeus
@cvdeby
Apr 13 2016 03:58 UTC
@SeanSaibot If inside the filter you got false this value won't extecute. It's so simple. Filters is not so complecated)
var arr = ['a', 'b', 'c'];
return arr.filter(function (value) {
    if (value === 'a') {
      return false;
    } else {
      return true;
    }
});
// return ['b', 'c']
Sean
@ofperfection
Apr 13 2016 04:00 UTC
how would you test for any value in an array?
hrokr
@hrokr
Apr 13 2016 04:02 UTC
hrokr @hrokr Apr 12 23:56
@goodm0urning @tekac --but it won't let me push a value onto an array. It instead replaces the array with the value. Any thoughts?
Sean
@ofperfection
Apr 13 2016 04:02 UTC
got a code example?
Coryphaeus
@cvdeby
Apr 13 2016 04:07 UTC
@SeanSaibot I didn't understand you. Inside the filter you have current value. If this current iteration return true, you'll see this value inside the new array, if false - vice versa. Filters couldn't make something more. Above example is enough.
@SeanSaibot Instead of 'alphabet' variable try to use RegEx(regular expressions). Maybe it'll be a little difficult for beginner, but they are so useful and work faster.
Vyani
@vyani
Apr 13 2016 04:19 UTC
Hi guys, anyone familiar with For Loops?
I've the the solution for Odd Numbers in Github, but still don't get it

var myArray = [];

for(var i = 1; i < 10; i += 2){
myArray.push(i);
}

// Only change code above this line.

if(typeof(myArray) !== "undefined"){(function(){return myArray;})();}

Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:20 UTC
@hrokr try prop !== tracks in your first nested if statement
hrokr
@hrokr
Apr 13 2016 04:22 UTC
I had tried that one but tried it again -- no love. :-(
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:23 UTC
works for me @hrokr when I changed it
hrokr
@hrokr
Apr 13 2016 04:23 UTC
@Jlipschitz --- such that it would look like this if (collection[id][prop] !== tracks)?
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:24 UTC
no it would look like if( prop !== "tracks") @hrokr
Frank XC
@tenkdayz
Apr 13 2016 04:25 UTC
@vyani how does the function look
Vyani
@vyani
Apr 13 2016 04:26 UTC
This message was deleted
Sean
@ofperfection
Apr 13 2016 04:26 UTC
yeah @cvdeby I saw regex was recommended but tbh I don't have any idea how to work with regex whereas I have a small idea of how to work with arrays.
Vyani
@vyani
Apr 13 2016 04:26 UTC
@tenkdayz

// Setup
var myArray = [];

// Only change code below this line.

var myArray = [];

for(var i = 1; i < 10; i += 2){
myArray.push(i);
}

// Only change code above this line.

if(typeof(myArray) !== "undefined"){(function(){return myArray;})();}
Frank XC
@tenkdayz
Apr 13 2016 04:27 UTC
@vyani there are 2 myArray? ..
delete the one above the for loop.. that might work
Vyani
@vyani
Apr 13 2016 04:28 UTC
This message was deleted
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:28 UTC

@hrokr it's just a matter of comparison. when comparing the object property, it looks like it's not the same as comparing to a string like "tracks" unless the code was in JSON format like below

var collection = {
    2548: {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    5439: {
      "album": "ABBA Gold"
    }
};

were you able to get it to work?

Vyani
@vyani
Apr 13 2016 04:30 UTC
@tenkdayz thanks, will do that. but what about the code at the very bottom line? can you help to explain? I see that code in github without sufficient explanation for me :(
CamperBot
@camperbot
Apr 13 2016 04:30 UTC
vyani sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 369 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
hrokr
@hrokr
Apr 13 2016 04:31 UTC
@Jlipschitz -- that didn't work either.
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:32 UTC
can you post your change?
Frank XC
@tenkdayz
Apr 13 2016 04:33 UTC

@vyani

if(typeof(myArray) !== "undefined"){(function(){return myArray;})();}

that part it's just to make sure myArray is defined.. if so return it.

hrokr
@hrokr
Apr 13 2016 04:34 UTC
@Jlipschitz -- sure but I've done about four changes so give a sec and I'll do the one I think you were mentioning.
@Jlipschitz -- OK, I think you were saying this:
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};

// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

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

  return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:37 UTC
@hrokr you have a typo in your first else statement
Eldar Tinjić
@EldarT90
Apr 13 2016 04:38 UTC
is it possible to append something to property ?
hrokr
@hrokr
Apr 13 2016 04:38 UTC
@Jlipschitz --- Yep. that's it. You are the man. Thanks!
CamperBot
@camperbot
Apr 13 2016 04:38 UTC
hrokr sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 102 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:38 UTC
@hrokr glad I could help!
hrokr
@hrokr
Apr 13 2016 04:40 UTC
@Jlipschitz -- I bet not as much as I am. That thing was giving me fits for four days. I was reading MDN (also with not much love) just after I had posted.
Eldar Tinjić
@EldarT90
Apr 13 2016 04:41 UTC
need help with appending the string to a property
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:41 UTC
MDN always gives me jitters when I see prototype and how it's originally created
Eldar Tinjić
@EldarT90
Apr 13 2016 04:41 UTC
and i dont know if its even possible
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:43 UTC
@EldarT90 if you have a property "string": "hello" you want to append something to "string"? i probably can't assist tbh but curious
Eldar Tinjić
@EldarT90
Apr 13 2016 04:43 UTC
@Jlipschitz yeah something like that i have element a and property is href , so i want to add link to it href with variable (wikipedia challenge)
Nick Rameau
@R4meau
Apr 13 2016 04:44 UTC
@EldarT90
$(element).attr("href", "http://newlink.com");
Eldar Tinjić
@EldarT90
Apr 13 2016 04:45 UTC
@R4meau hmm tnx let me try that
CamperBot
@camperbot
Apr 13 2016 04:45 UTC
eldart90 sends brownie points to @r4meau :sparkles: :thumbsup: :sparkles:
:star: 314 | @r4meau | http://www.freecodecamp.com/r4meau
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:45 UTC
ahh that I could of helped with! but @R4meau beat me to it
Nick Rameau
@R4meau
Apr 13 2016 04:45 UTC
@Jlipschitz ;)
Eldar Tinjić
@EldarT90
Apr 13 2016 04:48 UTC
@R4meau yeah it works really good
vivekraj
@vivekraj-kr
Apr 13 2016 04:48 UTC
Hi
Nick Rameau
@R4meau
Apr 13 2016 04:48 UTC
@EldarT90 You're welcome.
@vivekraj-kr Hello there.
vivekraj
@vivekraj-kr
Apr 13 2016 04:49 UTC
Hello im new here
started learn oop in js
Nick Rameau
@R4meau
Apr 13 2016 04:49 UTC
@vivekraj-kr Welcome to FCC.
vivekraj
@vivekraj-kr
Apr 13 2016 04:49 UTC
ok thank you
Im stuck on " constructor" section in freecodecamp exercises.
could you pls help me out.
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:51 UTC
@vivekraj-kr ask away and we'll try to help
vivekraj
@vivekraj-kr
Apr 13 2016 04:51 UTC

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

//Try it out here
var myCar = new Car(3,1,2);

this is the code snippet
and i need to invoke that new object
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:54 UTC
@vivekraj-kr create your new car and change afterwards. you won't be able to change like Car(3,1,2) because your constructor doesn't take in arguments
vivekraj
@vivekraj-kr
Apr 13 2016 04:54 UTC
ohh ok thank.
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:54 UTC
var Car = function() {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = new Car();

// myobj.property = something
// myobj.property2 = somethingElse
vivekraj
@vivekraj-kr
Apr 13 2016 04:54 UTC
Ill try it and let you know.
Thank you it works.
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:56 UTC
awesome! @vivekraj-kr
vivekraj
@vivekraj-kr
Apr 13 2016 04:56 UTC
That was a blunder mistake ryt?
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 04:59 UTC
happens to us all! you would of been right though by calling `myCar(1, 2, 3) if the constructor was originally setup like:
var Car = function(arg1, arg2, arg3) {
  this.wheels = arg1;
  this.seats = arg2;
  this.engines = arg3;
};
Frank XC
@tenkdayz
Apr 13 2016 05:00 UTC

@Jlipschitz would this work also?

var Car = function() {
  this.wheels = arguments[0];
  this.seats =  arguments[1];
  this.engines =  arguments[2];
};

guess so right?

Alexander Berezkin
@Leidone
Apr 13 2016 05:01 UTC
You should be getting the length of lastName by using .length like this: lastName.length.

// Example
var firstNameLength = 0;
var firstName = "Ada";

firstNameLength = firstName.length;

// Setup
var lastNameLength = 8;
var lastName = "Lovelace";

// Only change code below this line.

lastNameLength = lastName.length;

Jamie Lipschitz
@Jlipschitz
Apr 13 2016 05:02 UTC
that would work @tenkdayz . I guess it's a matter of which way is easier to read? interesting
what's your question @Leidone ?
Coryphaeus
@cvdeby
Apr 13 2016 05:09 UTC
help roman
CamperBot
@camperbot
Apr 13 2016 05:09 UTC

:point_right: algorithm roman numeral converter [wiki]

Problem Explanation:

  • You will create a program that converts an integer to a Roman Numeral.
:pencil: read more about algorithm roman numeral converter on the FCC Wiki
Justin
@daemedeor
Apr 13 2016 05:10 UTC
@tenkdayz it would work BUT i would suggest never to do that, it should be obvious to people that you can pass in arguments
Nick Rameau
@R4meau
Apr 13 2016 05:10 UTC
@daemedeor I agree. But since this is just a challenge and not a production code, it's completely fine.
Coryphaeus
@cvdeby
Apr 13 2016 05:11 UTC
It is my solution for Roman nums)
function convertToRoman(num) {
  var romanDigitsPrimary =   ["I", "X", "C", "M"];  // 1, 10, 100, 1000
  var romanDigitsSecondary = ["V", "L", "D", "ↁ"];  // 5, 50, 500
  var arr = (""+num).split("").reverse();
  function getRoman(digit, primary, secondary, third) {
    primary = "" + primary;
    secondary = "" + secondary;
    third = "" + third;
    switch(digit) {
      case 1: return third + primary;
      case 2: return third + primary.repeat(2);
      case 3: return third + primary.repeat(3);
      case 4: return primary + secondary;
      case 5: return secondary;
    }
  }
  var result = "";
  for(var i = 0; i < arr.length; i++) {
    if(arr[i] > 0 && arr[i] < 6) {
      result = getRoman(parseInt(arr[i]), romanDigitsPrimary[i], romanDigitsSecondary[i], "") + result;// 1-5
    } else if (arr[i] >= 6 && arr[i] < 10) {
      result = getRoman(parseInt(arr[i]) - 5, romanDigitsPrimary[i], romanDigitsPrimary[i+1], romanDigitsSecondary[i]) + result; // 6-9
    }
  }
  return result;
}
convertToRoman(127); // 36
Justin
@daemedeor
Apr 13 2016 05:11 UTC
@R4meau except building good habits is just as important as otherwise
@cvdeby congrats :)
Coryphaeus
@cvdeby
Apr 13 2016 05:12 UTC
@daemedeor Thanks)
CamperBot
@camperbot
Apr 13 2016 05:12 UTC
cvdeby sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 327 | @daemedeor | http://www.freecodecamp.com/daemedeor
Nick Rameau
@R4meau
Apr 13 2016 05:12 UTC
@daemedeor Indeed.
Justin
@daemedeor
Apr 13 2016 05:13 UTC
as a thought experiment its nice to play around, see what works and what doesn't but as far as promoting as "what's different" and "they are functionally the same" and are "good habits" that is as far as you get
Nick Rameau
@R4meau
Apr 13 2016 05:15 UTC
@cvdeby I would suggest to declare getRoman outside of convertToRoman. Good habit.
Justin
@daemedeor
Apr 13 2016 05:16 UTC
ya what r4meau says
jorgon1022
@jorgon1022
Apr 13 2016 05:18 UTC
hi
any of you guys available to help a fellow camper?
Frank XC
@tenkdayz
Apr 13 2016 05:19 UTC
@daemedeor but for editing purposes it's better imo.. what if you want to add this.color ?
Justin
@daemedeor
Apr 13 2016 05:19 UTC
@tenkdayz no.... its not, not to do arguments[0]
Alexander Berezkin
@Leidone
Apr 13 2016 05:19 UTC
@Jlipschitz You should be getting the length of lastName by using .length like this: lastName.length.
Nick Rameau
@R4meau
Apr 13 2016 05:20 UTC
@jorgon1022 Go ahead and ask your question mate.
jorgon1022
@jorgon1022
Apr 13 2016 05:22 UTC
So I am doing a challenge. The challenge is Escape Sequences with Strings. But I am not sure that I am understanding the question correctly
Greg Duncan
@GregatGit
Apr 13 2016 05:22 UTC
@jorgon1022 just put your question up - everyone will be all over it
jorgon1022
@jorgon1022
Apr 13 2016 05:22 UTC
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
//Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Coryphaeus
@cvdeby
Apr 13 2016 05:23 UTC
@jorgon1022 Instead of word 'tab' put "\t" and so for each one word.
jorgon1022
@jorgon1022
Apr 13 2016 05:25 UTC
@cvdeby Thank you . You gave me the answer. I appreciate it.
CamperBot
@camperbot
Apr 13 2016 05:25 UTC
jorgon1022 sends brownie points to @cvdeby :sparkles: :thumbsup: :sparkles:
:star: 311 | @cvdeby | http://www.freecodecamp.com/cvdeby
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 05:26 UTC
@Leidone was "lovelace" originally set to 8, could be that it should be 0? looks good to me. don't see why it wouldn't take it
Justin
@daemedeor
Apr 13 2016 05:28 UTC
@Jlipschitz also don't put arg1, arg2, arg3 as parameters, you should strive to be as self documenting as possible and make variables that are semantic ^.^
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 05:28 UTC
just looked and it should be var lastNameLength = 0
duly noted! I was just showing him lol @daemedeor
Justin
@daemedeor
Apr 13 2016 05:30 UTC
@Jlipschitz fair enough i've used my fair share of bad variables names when making examples XD except i havent usd one as bad as ids (not here in an exercise book)
Alexander Berezkin
@Leidone
Apr 13 2016 05:35 UTC
@Jlipschitz thanks
CamperBot
@camperbot
Apr 13 2016 05:35 UTC
leidone sends brownie points to @jlipschitz :sparkles: :thumbsup: :sparkles:
:star: 105 | @jlipschitz | http://www.freecodecamp.com/jlipschitz
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 05:36 UTC
i think you've definitely right though that i should apply the same standards, even if it's something simple it's still good habit building. don't see any negative to that! good thing i stopped declaring variables a,b,c, one, two, three, etc lol
@daemedeor
Justin
@daemedeor
Apr 13 2016 05:38 UTC
@Jlipschitz usually i only use single variable letters in 2 situations: maths(and not always all the time either) and loops, anything outside of those you should never ever use single letters
Jamie Lipschitz
@Jlipschitz
Apr 13 2016 05:40 UTC
yeah learned that the hard way when trying to back track lol
Ashutosh Parmar Jain
@AshutoshParmar
Apr 13 2016 06:09 UTC
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:17 UTC
Hi guys I need help on Chunky Monkey challenge, is someone available?
Frank XC
@tenkdayz
Apr 13 2016 06:20 UTC
@StoneDisk go ahead
Ivan
@elementWebDev
Apr 13 2016 06:20 UTC
Return Early Pattern for Functions? have tried several different things... not sure what to do
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Frank XC
@tenkdayz
Apr 13 2016 06:21 UTC
@oghosting what does it have to return?
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:22 UTC
My code is producing empty element arrays:
Ivan
@elementWebDev
Apr 13 2016 06:22 UTC
if a or b are less than 0 the function will immediately exit with a value of undefined
Frank XC
@tenkdayz
Apr 13 2016 06:23 UTC
@oghosting else what?
kirbyedy
@kirbyedy
Apr 13 2016 06:23 UTC
else undefined
Kristoforus Rua
@kru
Apr 13 2016 06:23 UTC
can you post your code here @StoneDisk
Ivan
@elementWebDev
Apr 13 2016 06:24 UTC
undefined
k..
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:25 UTC
Sorry but how do I post my code in Gitter?
kirbyedy
@kirbyedy
Apr 13 2016 06:25 UTC
help format
CamperBot
@camperbot
Apr 13 2016 06:25 UTC

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Frank XC
@tenkdayz
Apr 13 2016 06:25 UTC
if a||b === undefind return undefined else return undefined?
Kristoforus Rua
@kru
Apr 13 2016 06:25 UTC
nah thats will do it
kirbyedy
@kirbyedy
Apr 13 2016 06:26 UTC
@tenkdayz no he has to test against the 0
Kristoforus Rua
@kru
Apr 13 2016 06:26 UTC
let c = test;
Kevin Myrick
@aphextwin234
Apr 13 2016 06:26 UTC
@StoneDisk there is a shortcut follow the @camperbot
kirbyedy
@kirbyedy
Apr 13 2016 06:27 UTC
@oghosting if a or b is less than zero, return
Kevin Myrick
@aphextwin234
Apr 13 2016 06:27 UTC
then people can view this array,
Ivan
@elementWebDev
Apr 13 2016 06:32 UTC
// Setup
function abTest(a, b) {
  // Only change code below this line
  if (a||b < 0) {
    return undefined;
  }


  // Only change code above this line

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

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

When a return statement is reached, the execution of the current function stops and control returns to the calling location.

Example

function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
The above outputs "Hello" to the console, returns "World", but "byebye" is never output, because the function exits at the return statement.

Instructions
Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.

Markus Kiili
@Masd925
Apr 13 2016 06:35 UTC
@oghosting I actually like this solutions the most, leaving returning undefined for the engine:
function abTest(a, b) {
  // Only change code below this line

  if (a>0 && b>0)

  // Only change code above this line

  return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:36 UTC
here is my code:
var group = [];
  var extra = arr.length % size;
  var round = Math.floor((arr.length / size) + extra);
  var pos = 0;

  for (var x = 1; x <= round; x++) {
    for (var y = 0; y < size; y++) {
      if (x === round) {
        group.push(arr.slice(pos));
      }
      group.push(arr.slice(pos, pos + size));
      pos += size;
    }
  }
Jas
@JB2016
Apr 13 2016 06:38 UTC
help Check for Palindromes
CamperBot
@camperbot
Apr 13 2016 06:38 UTC

:point_right: algorithm check for palindromes [wiki]

Explanation:

Our goal for solving this problem is tidying up the string passed in, and checking whether it is in fact a palindrome.

  • If you are unsure of what a palindrome is, it is a word or phrase that when reversed spells the same thing forwards or backwards. A simple example is mom, when you reverse the letters, it spells the same thing! Another example of a palindrome is race car. When we take out anything that is not a character it becomes racecar which is the same spelled forwards or backwards!

Once we have determined whether it is a palindrome or not we want to return either true or false based on our findings.

:pencil: read more about algorithm check for palindromes on the FCC Wiki

Ivan
@elementWebDev
Apr 13 2016 06:38 UTC
wow... thank you @Masd925
CamperBot
@camperbot
Apr 13 2016 06:38 UTC
oghosting sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1356 | @masd925 | http://www.freecodecamp.com/masd925
Ivan
@elementWebDev
Apr 13 2016 06:39 UTC
lol
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:41 UTC
I tried removing excess empty array elements using pop() but test still failed.
Kevin Myrick
@aphextwin234
Apr 13 2016 06:44 UTC
are you trying to put those variables into your array? @StoneDisk
I don't know this challenge, I'm not very far. @StoneDisk
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:49 UTC
@aphextwin234, round variable is supposed to calculate the exact array size and pos variable is used to set the element position for group array.
mohitjarvissharma
@mohit-jarvis-sharma
Apr 13 2016 06:50 UTC
in celcius to farenheit conversion
my code seems right but the result is null always
fahrenheit = (celcius*9)/5 + 32;
Blauelf
@Blauelf
Apr 13 2016 06:51 UTC
@Masd925 Shouldn't it be if (a>=0 && b>=0) then, as 0 can be considered non-negative (at least the square root for 0 is the same whether it is -0 or +0)
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 06:53 UTC
@krua, that is the code that makes excess empty array elements.
Markus Kiili
@Masd925
Apr 13 2016 06:53 UTC
@Blauelf Yes, you are correct.
Blauelf
@Blauelf
Apr 13 2016 06:57 UTC
@StoneDisk I don't think that you need nested loops if you use slice. And your variable round is not that good, why not simply use pos as the iterator variable and do for (var pos = 0; pos < arr.length; pos += size) {? If slice has not enough elements, its result will be shorter, so you don't even have to care about that special case of extra elements, they'll be included in the last batch.
Francis Yvan Jubera
@StoneDisk
Apr 13 2016 07:04 UTC
@Blauelf It worked, thanks a lot :smile:
CamperBot
@camperbot
Apr 13 2016 07:04 UTC
stonedisk sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1606 | @blauelf | http://www.freecodecamp.com/blauelf
mohitjarvissharma
@mohit-jarvis-sharma
Apr 13 2016 07:06 UTC
here is my code

var myStr; // Change this line

myStr = "I am a \"double quoted\" string inside \"double quotes\" " ;

it gives an output of
myStr = "I am a \"double quoted\" string inside \"double quotes\" " ;
why is it giving myStr = also :;/
Dominic Barretto
@Dominicbarretto
Apr 13 2016 07:08 UTC
Hey Guys I am doing the "counting cards" challenge
following is my switch statment
switch(card)
{
case 2:
case 3:
case 4:
case 5:
case 6: count++;sString=count +" Bet"; break;
case 7:
case 8:
case 9: sString = count + " Hold"; break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A': count--; sString= count + " Hold"; break;
}
i am not getting proper result for the following values
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"

Here is my function which has the switch statement in it
function cc(card) {
// Only change code below this line

var sString="";

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

}

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

Blauelf
@Blauelf
Apr 13 2016 07:11 UTC
@Dominicbarretto Separate the card->count part from the count->return value part. Don't set the return value in your switch statement.
The count->return value part does not care about the card, it depends only on count.
Dominic Barretto
@Dominicbarretto
Apr 13 2016 07:12 UTC
sorry i didnt get u
@Blauelf
Blauelf
@Blauelf
Apr 13 2016 07:13 UTC
Pseudo-code
1. Examine card, change count accordingly
2. Examine count, return the right answer
Those should be separate parts in your code, both in the same function, but separate.
The return value depends on count only, so it should not be assembled in a path that depends on card.
Dominic Barretto
@Dominicbarretto
Apr 13 2016 07:20 UTC
but why dose it work for the other condtions ie
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
Blauelf
@Blauelf
Apr 13 2016 07:22 UTC
Just because a code sometimes returns the right result does not mean it's correct. If I am in Hamburg or London and I predict "at least some rain in the day", I'm right in most cases, yet that prediction is not that useful.
Dominic Barretto
@Dominicbarretto
Apr 13 2016 07:29 UTC
@Blauelf i did it ur way n it worked!
but my question is why didnt it worked my way?
@Blauelf n e ways thanks!
CamperBot
@camperbot
Apr 13 2016 07:30 UTC
dominicbarretto sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1607 | @blauelf | http://www.freecodecamp.com/blauelf
mostlind
@mostlind
Apr 13 2016 07:37 UTC
Why should factorialize(0) return 1?
Markus Kiili
@Masd925
Apr 13 2016 07:40 UTC
@mostlind Factorial of 0 is defined that way.
mostlind
@mostlind
Apr 13 2016 07:42 UTC
@Masd925 weird.. so I just have to put an if to check if the argument is 0?
Markus Kiili
@Masd925
Apr 13 2016 07:42 UTC
@mostlind Yes.
mostlind
@mostlind
Apr 13 2016 07:42 UTC
thanks @Masd925
CamperBot
@camperbot
Apr 13 2016 07:42 UTC
mostlind sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1357 | @masd925 | http://www.freecodecamp.com/masd925
Blauelf
@Blauelf
Apr 13 2016 07:44 UTC
@Dominicbarretto Consider the sequences 2, "A" 7, 8 "A", 2, all of them result in no change in count (after the second card that is), yet your code would have returned the very same number of count sometimes with Bet, sometimes with Hold. According to the task description, the decision Bet/Hold should be a function of count only.
@mostlind There is one way to put 0 elements in an order, same for 1, but two for two, six ways for three elements, ...
It makes a lot sense if you consider that n!=n(n1)!n!=n*(n-1)!, which means that 1!=10!1!=1*0! or 0!=10!=1
And you don't have to treat 0 as a special case in all ways, you'll have to if you do it recursively, but you don't if you use a simple loop.
vetoCode
@vetoCode
Apr 13 2016 07:48 UTC
can someone help me?
why fires the if and the else at the same time?!
http://codepen.io/vetoCode/pen/GZQEgp?editors=0010
why nothing is showed in first box
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:01 UTC
@mostlind, setting it as 0 would ensure that the law of exponent works consistently and the when finding permutation as @Blauelf answered earlier, you only have one way to organise 0 element(s)
Hi @EldarT90!
Justin
@daemedeor
Apr 13 2016 08:02 UTC
@EldarT90 you need to actually call twitch()
and then you need to add jquery
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:02 UTC
Sorry for digression @EldarT90, are you done with the Wikipedia viewer?
Eldar Tinjić
@EldarT90
Apr 13 2016 08:02 UTC
@brainyfarm @daemedeor hey guys ^^
@brainyfarm yes, you wanna check how it looks like ?
Justin
@daemedeor
Apr 13 2016 08:03 UTC
hi @EldarT90 :D
Eldar Tinjić
@EldarT90
Apr 13 2016 08:03 UTC
@brainyfarm http://codepen.io/EldarT/pen/qZxJZp - its basically 99% done
Justin
@daemedeor
Apr 13 2016 08:04 UTC
@EldarT90 nice i enjoyed your design :)
Eldar Tinjić
@EldarT90
Apr 13 2016 08:04 UTC
@daemedeor thanks mate, however from where should i call function? i want it to be "executed" asap, not on click like in previous exercise
CamperBot
@camperbot
Apr 13 2016 08:04 UTC
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 337 | @daemedeor | http://www.freecodecamp.com/daemedeor
Justin
@daemedeor
Apr 13 2016 08:05 UTC
@EldarT90 just right below twitch is defined so just twitch()
you could also make it self invoking
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:05 UTC
@EldarT90, is your image broken? And you did a good job man!
Eldar Tinjić
@EldarT90
Apr 13 2016 08:05 UTC
@brainyfarm its not broken, you mean the wikipedia logo ?
Justin
@daemedeor
Apr 13 2016 08:06 UTC
the search text is a bit hard to read though
Eldar Tinjić
@EldarT90
Apr 13 2016 08:06 UTC
@daemedeor like this? http://codepen.io/EldarT/pen/VaXLGV i called , but its not working
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:06 UTC
@EldarT90, imgur would not work on codepen.io.
Justin
@daemedeor
Apr 13 2016 08:06 UTC
@EldarT90 yea but then you dont have jquery added
Screen Shot 2016-04-13 at 4.07.14 AM.png
Eldar Tinjić
@EldarT90
Apr 13 2016 08:07 UTC
@daemedeor aaa
@daemedeor sec
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:07 UTC
You can add http://crossorigin.me before the image to make it work or host on Dropbox @EldarT90.
Eldar Tinjić
@EldarT90
Apr 13 2016 08:07 UTC
@brainyfarm :/ but it works for me, so is it just me or ?
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:08 UTC
It does not work for me @EldarT90 :P
Eldar Tinjić
@EldarT90
Apr 13 2016 08:08 UTC
@brainyfarm check again i added that crossorigin thingy ^^
Justin
@daemedeor
Apr 13 2016 08:09 UTC
hmmm for the wiki image, it popped up fine
for me
Eldar Tinjić
@EldarT90
Apr 13 2016 08:09 UTC
@daemedeor i added jquery, still not working =(
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:10 UTC
Ashutosh Parmar Jain
@AshutoshParmar
Apr 13 2016 08:10 UTC
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:11 UTC
It only worked with crossorigin.me for me @daemedeor :P
Justin
@daemedeor
Apr 13 2016 08:11 UTC
shrug
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:11 UTC
Could you share your code @AshutoshParmar?
Eldar Tinjić
@EldarT90
Apr 13 2016 08:12 UTC
@brainyfarm check again ^^
Justin
@daemedeor
Apr 13 2016 08:12 UTC
@EldarT90 there's no stream property on your object
Eldar Tinjić
@EldarT90
Apr 13 2016 08:12 UTC
@daemedeor but what about plain "blabla", not even that is showing up
@daemedeor which makes me thing some syntax is wrong
Justin
@daemedeor
Apr 13 2016 08:12 UTC
once js breaks, it stops executing
Ashutosh Parmar Jain
@AshutoshParmar
Apr 13 2016 08:13 UTC

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

// Only change code below this line
function updateRecords(id, prop, value) {

return collection;
}

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

Justin
@daemedeor
Apr 13 2016 08:13 UTC
so you need to remove the data.streams[0] @EldarT90
Eldar Tinjić
@EldarT90
Apr 13 2016 08:13 UTC
@daemedeor aa, sec
Ashutosh Parmar Jain
@AshutoshParmar
Apr 13 2016 08:13 UTC
@brainyfarm
Eldar Tinjić
@EldarT90
Apr 13 2016 08:13 UTC
@daemedeor even when i remove, i dont see blabla :/
sorry i see
sorry
Justin
@daemedeor
Apr 13 2016 08:13 UTC
:D
Screen Shot 2016-04-13 at 4.13.46 AM.png
here ya go
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:14 UTC
@AshutoshParmar, now you need to do some testing + conditional statements.
Justin
@daemedeor
Apr 13 2016 08:14 UTC
gl;hf; XD
am i calling it on wrong way?
Olawale Akinseye
@brainyfarm
Apr 13 2016 08:15 UTC
Working fine now @EldarT90 :+1:
Eldar Tinjić
@EldarT90
Apr 13 2016 08:15 UTC
@brainyfarm okay ^^
Justin
@daemedeor
Apr 13 2016 08:16 UTC
@EldarT90 are you sending the right headers? with the api key and all
Eldar Tinjić
@EldarT90
Apr 13 2016 08:16 UTC
@daemedeor we need key for this api also ?
@daemedeor like the weather one or you mean keyvalue
Justin
@daemedeor
Apr 13 2016 08:17 UTC
@EldarT90 i think you do... but also this: Returns a stream object if live.
so it might not be live?
Eldar Tinjić
@EldarT90
Apr 13 2016 08:17 UTC
@daemedeor i chose 24/7 channel as testing
@daemedeor for testing*
it doesnt say anytihing about api key , onl streaming keys but thats for embedded streaming i think
Justin
@daemedeor
Apr 13 2016 08:19 UTC
hmmm
Dave
@copendaven
Apr 13 2016 08:22 UTC

can someone explain this in english please? I thought I had the language down but apparently not…

"If you specify any object, including a Boolean object whose value is false, as the initial value of a Boolean object, the new Boolean object has a value of true.”

var myFalse = new Boolean(false);   // initial value of false
Justin
@daemedeor
Apr 13 2016 08:22 UTC
@EldarT90 it looks liek the right api call but......
Eldar Tinjić
@EldarT90
Apr 13 2016 08:23 UTC
@daemedeor now i even try with direct link to streamer they provided there http://codepen.io/EldarT/pen/VaXLGV
Justin
@daemedeor
Apr 13 2016 08:24 UTC
@EldarT90 it says this: Returns a stream object if live.
damn wait
Screen Shot 2016-04-13 at 4.24.17 AM.png
Vlad Serebriakov
@Vargentum
Apr 13 2016 08:25 UTC
Can anybody explain test case with Object.keys in https://www.freecodecamp.com/challenges/make-a-person
I’ve defined methods of Person in prototype, so they aren’t visible from Object.keys. But if I do this, and has 6 methods, I need some helper props like this._firstName and this._lastName to glue methods together. So there will be 8 keys.
Any ideas?
Justin
@daemedeor
Apr 13 2016 08:26 UTC
@EldarT90 i have to think that you do need some authorization
Shivam Arora
@shivamarora13
Apr 13 2016 08:26 UTC
how can I get value from a bootstrap modal?
Eldar Tinjić
@EldarT90
Apr 13 2016 08:26 UTC
@daemedeor hmm
Frank XC
@tenkdayz
Apr 13 2016 08:27 UTC
@EldarT90 youre link should be "https://api.twitch.tv/kraken/channels" +userName
Justin
@daemedeor
Apr 13 2016 08:27 UTC
@tenkdayz you're forgeting a slash i'm sure
Frank XC
@tenkdayz
Apr 13 2016 08:27 UTC
true
Justin
@daemedeor
Apr 13 2016 08:28 UTC
i haven't played around with the twitch api so i'll just leave you guys to figure it out
Rada
@Radascript
Apr 13 2016 08:28 UTC
hey guys, can someone explain why my loop skips over second value? I made a copy array specifically so that shifting didn't mess up the indexes, but it seems to do so anyway:
Justin
@daemedeor
Apr 13 2016 08:28 UTC
XD
Eldar Tinjić
@EldarT90
Apr 13 2016 08:28 UTC
Rada
@Radascript
Apr 13 2016 08:28 UTC
function dropElements(arr, func) {

  var arrCopy = arr;

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

    console.log(arr[i]);
    console.log(func(arr[i]));


   if (func(arr[i]) === false) {
      arrCopy.shift();
      console.log(arrCopy);
    }

    else {
      console.log("result " + arrCopy);
      return arrCopy;
    }

  }

}

dropElements([1, 2, 3, 4], function(n) {return n >= 3;});
Eldar Tinjić
@EldarT90
Apr 13 2016 08:28 UTC
wont work :/
Rada
@Radascript
Apr 13 2016 08:29 UTC
sorry since question got lost: can someone explain why my loop skips over second value? I made a copy array specifically so that shifting didn't mess up the indexes, but it seems to do so anyway
Shivam Arora
@shivamarora13
Apr 13 2016 08:29 UTC
@Radascript declare var i
Justin
@daemedeor
Apr 13 2016 08:29 UTC
@shivamarora13 not an issue but you're right one that should be corrected
Shivam Arora
@shivamarora13
Apr 13 2016 08:29 UTC
@daemedeor I know, just told it, when saw it.
Rada
@Radascript
Apr 13 2016 08:30 UTC
@shivamarora13 you mean outside the for loop?
Frank XC
@tenkdayz
Apr 13 2016 08:30 UTC
@EldarT90 yes.. then create a var = data
Shivam Arora
@shivamarora13
Apr 13 2016 08:30 UTC
no like for(var i = 0; i<1;i++)
@Radascript
Eldar Tinjić
@EldarT90
Apr 13 2016 08:30 UTC
@tenkdayz its created by function ?
@tenkdayz i mean it is created already
Rada
@Radascript
Apr 13 2016 08:31 UTC
@shivamarora13 just tried it, same results in console
Justin
@daemedeor
Apr 13 2016 08:31 UTC
@Radascript are you sure you want to return arrCopy after its true?
Shivam Arora
@shivamarora13
Apr 13 2016 08:31 UTC
@Radascript results might not change, but it was also a problem, in your code.
Frank XC
@tenkdayz
Apr 13 2016 08:32 UTC
ok yes.. then use data to query the info you want to use from the obj
Rada
@Radascript
Apr 13 2016 08:32 UTC
@shivamarora13 I've never actually seen them use var within the for loop hm not sure that's the convention
Frank XC
@tenkdayz
Apr 13 2016 08:33 UTC
try data.display_name
Rada
@Radascript
Apr 13 2016 08:33 UTC
@daemedeor pretty sureee it's the Drop It challenge
Help Drop It
CamperBot
@camperbot
Apr 13 2016 08:33 UTC

:point_right: algorithm drop it [wiki]

Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

:pencil: read more about algorithm drop it on the FCC Wiki

Eldar Tinjić
@EldarT90
Apr 13 2016 08:33 UTC
@tenkdayz im not sure what you meant by that :/
Justin
@daemedeor
Apr 13 2016 08:35 UTC
@Radascript i'm sure there's a problem.......?
Frank XC
@tenkdayz
Apr 13 2016 08:35 UTC
download a tidy api plugin for your browser to understand it
Eldar Tinjić
@EldarT90
Apr 13 2016 08:35 UTC
@tenkdayz aa it works
@tenkdayz i found game and put game directly , and it says "Music"
Frank XC
@tenkdayz
Apr 13 2016 08:36 UTC
@EldarT90 yes that all information about that streamer..
Justin
@daemedeor
Apr 13 2016 08:36 UTC
@Radascript no its definitely the convention to use for(var i = 0; i < arr.length; i++), you can declare it before your loop but frequently you can find it like that
Eldar Tinjić
@EldarT90
Apr 13 2016 08:36 UTC
@tenkdayz yes i knew about this from previous exercises but problem was i couldnt "target" it, i was using some other attribute first than game, but its direct
@tenkdayz anyway tnx alot, now i will try to isolate the ones i need
CamperBot
@camperbot
Apr 13 2016 08:37 UTC
eldart90 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 374 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Rada
@Radascript
Apr 13 2016 08:37 UTC
@daemedeor ah ok I'll start doing that ty
Frank XC
@tenkdayz
Apr 13 2016 08:37 UTC
@EldarT90 the most relevant properties are data.display_name data.logo and data.status
Eldar Tinjić
@EldarT90
Apr 13 2016 08:38 UTC
@tenkdayz oke ty once again, also after i set it up for 1 box(streamer) i will have to make loop for other 16, i dont think its really efficient to do this for 16 individually, right ?
Frank XC
@tenkdayz
Apr 13 2016 08:39 UTC
yeas you will have to create an obj for each one and push those objs into an array at the end of the loop.
hjernefrys
@hjernefrys
Apr 13 2016 08:48 UTC
Hi can someone help me to understand what's going on with my code, "Check for Palindromes". It passes all the test except: "palindrome("A man, a plan, a canal. Panama") should return true." and "palindrome("My age is 0, 0 si ega ym.") should return true." here is the code I have so far:
function palindrome(str) {
  // Good luck!
  var myArray = [];

  reverseString = str.toLowerCase();
  reverseString = str.replace(/[^a-z0-9]/g,"");

  originalString = str.toLowerCase();
  originalString = str.replace(/[^a-z0-9]/g,"");
  originalString = str.split("");


  //Reverses the string:
  for(var x = reverseString.length -1; x >= 0; x--){

    myArray.push(reverseString[x]);
  }

  originalString = myArray.join("");


 if(reverseString === originalString){
    return true;
  } else{
    console.log(reverseString + " original: " + originalString);
    return false;
  }

}

palindrome("A man, a plan, a canal. Panama");
Rada
@Radascript
Apr 13 2016 08:51 UTC
@hjernefrys first thing I notice is make sure you are declaring variables (reverseString and originalString)
and make sure you are console.logging often to see that each action is functioning properly
your second reverseString action is messing it up:
reverseString = str.replace(/[^a-z0-9]/g, "");
console.log("now it's " + reverseString);
negyvenketto
@negyvenketto
Apr 13 2016 08:55 UTC
@hjernefrys you need
reverseString = str.toLowerCase();
  reverseString = reverseString.replace(/[^a-z0-9]/g,"");
hjernefrys
@hjernefrys
Apr 13 2016 08:55 UTC
aha, I'll try to change it
negyvenketto
@negyvenketto
Apr 13 2016 08:56 UTC
@Radascript you were faster :D
Rada
@Radascript
Apr 13 2016 08:56 UTC
@hjernefrys you can even tie them into one sentence if you'd like:
var reverseString = str.toLowerCase().replace(/[^a-z0-9]/g, "");
@negyvenketto it's not a race :D :P
hjernefrys
@hjernefrys
Apr 13 2016 08:57 UTC
@Radascript is that considered good practice? I find the code looks cleaner otherwise
negyvenketto
@negyvenketto
Apr 13 2016 08:58 UTC
@Radascript i know :D
hjernefrys
@hjernefrys
Apr 13 2016 08:58 UTC
thanks @Radascript and @negyvenketto it passed now
CamperBot
@camperbot
Apr 13 2016 08:58 UTC
hjernefrys sends brownie points to @radascript and @negyvenketto :sparkles: :thumbsup: :sparkles:
:star: 297 | @radascript | http://www.freecodecamp.com/radascript
:star: 352 | @negyvenketto | http://www.freecodecamp.com/negyvenketto
Eldar Tinjić
@EldarT90
Apr 13 2016 08:59 UTC
ok so first problem is how to take username and put it in json function, when i need to have json function to get the username
how do i bypass this crap?
Rada
@Radascript
Apr 13 2016 08:59 UTC
@hjernefrys I have no idea actually. I'm pretty new, we should ask someone with more experience
Eldar Tinjić
@EldarT90
Apr 13 2016 08:59 UTC
or actually i dont, i have an array
but should i put whole array as username variabl
Coy Sanders
@coymeetsworld
Apr 13 2016 09:00 UTC
think its fine to chain the functions together IMO
Eldar Tinjić
@EldarT90
Apr 13 2016 09:00 UTC
and than go with for loop ?
Coy Sanders
@coymeetsworld
Apr 13 2016 09:00 UTC
as long as its readable
negyvenketto
@negyvenketto
Apr 13 2016 09:01 UTC
@hjernefrys i'm pretty new as well, but i asked a senior developper often for code review, and it seems to me that the shorter, the more compact, the better
Mooli
@Mooli88
Apr 13 2016 09:01 UTC
finished with the twitch tv zipline. please let me know what you think
http://codepen.io/Mooli88/full/eZVbJw/
Rada
@Radascript
Apr 13 2016 09:01 UTC
I solved my Drop It challenge, now staring at the SteamRoll challenge trying to figure out how to start
hjernefrys
@hjernefrys
Apr 13 2016 09:01 UTC
@negyvenketto ok I see. Many language has pretty strict guidelines on how to properly format the code
Rada
@Radascript
Apr 13 2016 09:02 UTC
@Mooli88 holy crap this makes me feel like I half-assed mine. Looks great
Justin
@daemedeor
Apr 13 2016 09:02 UTC
@hjernefrys its okay to chain it, but don't chain it too long, if its too long you can just newline it
Coy Sanders
@coymeetsworld
Apr 13 2016 09:03 UTC
yeah looks nice @Mooli88
Rada
@Radascript
Apr 13 2016 09:03 UTC
man this makes me wonder if I should fluff up my ziplines more than I do. That's all I did for the twitch one: http://codepen.io/RadaCodes/pen/ONzVdb
negyvenketto
@negyvenketto
Apr 13 2016 09:03 UTC
@hjernefrys would you like other ideas on how to make your palindrome code shorter/cleaner?
Justin
@daemedeor
Apr 13 2016 09:04 UTC
return string.split('').reverse().join('') === string;
done sorta
haha
Mooli
@Mooli88
Apr 13 2016 09:04 UTC
@Radascript lol thanks . i think i missed up with the account status . not sure how to tell if its closed or not
CamperBot
@camperbot
Apr 13 2016 09:04 UTC
mooli88 sends brownie points to @radascript :sparkles: :thumbsup: :sparkles:
:star: 298 | @radascript | http://www.freecodecamp.com/radascript
hjernefrys
@hjernefrys
Apr 13 2016 09:04 UTC
@negyvenketto sure, go for it!
Brendan Kinahan
@BKinahan
Apr 13 2016 09:05 UTC
@daemedeor var?
Justin
@daemedeor
Apr 13 2016 09:05 UTC
@BKinahan im tired
Brendan Kinahan
@BKinahan
Apr 13 2016 09:05 UTC
oh, edited
hjernefrys
@hjernefrys
Apr 13 2016 09:05 UTC
@daemedeor that reverse method is quite convenient :-P
Mooli
@Mooli88
Apr 13 2016 09:06 UTC
@Radascript maybe consider to add target="_blank" since clicking on one of the channels doesn't do anything
Justin
@daemedeor
Apr 13 2016 09:06 UTC
@hjernefrys more so like this .... var replacedString = //regex here too lzy to put; return replacedString.split('').reverse.join('') === replacedString;
Rada
@Radascript
Apr 13 2016 09:07 UTC
@hjernefrys yeah looking back through older challenges you see all these things you coulda done easier it's fun
Justin
@daemedeor
Apr 13 2016 09:07 UTC
2 lines worth of js to do the palindrome XD
yippeeee
herochua
@herochua
Apr 13 2016 09:08 UTC
:(
I did 1 whole block code for it haha
Eldar Tinjić
@EldarT90
Apr 13 2016 09:08 UTC
$("#box"+[i]).append("<h1>" + data.display_name + "</h1>");
Rada
@Radascript
Apr 13 2016 09:08 UTC
@Mooli88 ohhh that's right tyty
Eldar Tinjić
@EldarT90
Apr 13 2016 09:08 UTC
is this correct way @daemedeor
Rada
@Radascript
Apr 13 2016 09:09 UTC
fixxed
hjernefrys
@hjernefrys
Apr 13 2016 09:09 UTC
it's certainly shorter, but perhaps writing longer code has it advantages for the beginner as well, as it's easier to walk trough each step and spot errors
Eldar Tinjić
@EldarT90
Apr 13 2016 09:09 UTC
@daemedeor when it comes to [i] addition to that
Mooli
@Mooli88
Apr 13 2016 09:09 UTC
can someone explain to me this bit
User Story: I will see a placeholder notification if a streamer has closed their Twitch account (or the account never existed). You can verify this works by adding brunofin and comster404 to your array of Twitch streamers.
Justin
@daemedeor
Apr 13 2016 09:10 UTC
@EldarT90 sure if its there
Eldar Tinjić
@EldarT90
Apr 13 2016 09:10 UTC
@daemedeor but it wont work, can you check it plz ? http://codepen.io/EldarT/pen/VaXLGV
Justin
@daemedeor
Apr 13 2016 09:10 UTC
@hjernefrys its better to understand than to do clever solutions like mine... it comes from experience
negyvenketto
@negyvenketto
Apr 13 2016 09:11 UTC
@hjernefrys ok, so:
1) you can define originalString and reverseString in this order, and reverse the original, that way you need the lowercase and regex only once.
2) you can reverse a string as @daemedeor has written it :point_up:
3) you can return a logical expression: when it's true, it will return true, when it's false, it will return false.
so the code becomes:
function palindrome(str) {
  // Good luck!
  var originalString = str.toLowerCase().replace(/[^a-z0-9]/g,"");
  var reverseString = originalString.split('').reverse().join('');
  return originalString === reverseString;
}
Justin
@daemedeor
Apr 13 2016 09:12 UTC
@negyvenketto i don't even bother with the making of a variable for the split reverse and join
negyvenketto
@negyvenketto
Apr 13 2016 09:12 UTC
it can be made even more compact, but i think this is pretty neat and easy to understand
usharya
@usharya
Apr 13 2016 09:12 UTC
hello everybody :)
Justin
@daemedeor
Apr 13 2016 09:12 UTC
hi @usharya
@negyvenketto you also have an extra array instantiated for near no reason XD
negyvenketto
@negyvenketto
Apr 13 2016 09:13 UTC
@daemedeor oh, yeah, i forgot to delete it :D
Flurb
@Flurb
Apr 13 2016 09:13 UTC
Anyone here knows how to convert ISO-8859-1 to UTF-8? I tried every page when I google to it
Anyone has experience with it?
negyvenketto
@negyvenketto
Apr 13 2016 09:13 UTC
@usharya hi :)
Eldar Tinjić
@EldarT90
Apr 13 2016 09:17 UTC
@daemedeor i mean if you know to what am i referring
Justin
@daemedeor
Apr 13 2016 09:17 UTC
@EldarT90 looking through it now, it looks like you have #img11?
@EldarT90 but you also have closure problems, since the last time i is defined, it'll be 5, so you should either do a self-invoking function and pass a parameter, a new scope (like with a .forEach) or use a named function to call that
karim khalfaoui
@Kaiiim
Apr 13 2016 09:24 UTC

hi everyone, can you help me please, i dont understand why my code doesn't works, for " Find the Longest Word in a String "
function findLongestWord(str) {
var i = str.split(' ');
var j = 0;
for ( j = 0; j < i.length; j++)
{
if (i[0].length < i[+1].length)

        {
          return i[+1].length;
        }
     else {
          return i[0].length;
        }         
    }     

return i;
}
findLongestWord("Google do a barrel roll");

Brendan Kinahan
@BKinahan
Apr 13 2016 09:25 UTC
re: the palindrome discussion earlier, I think I have shortened mine a bit:
palindrome = s => s.toLowerCase().match(/[^_\W]/g).every((v,i,a)=>v==a[a.length-i-1]);
karim khalfaoui
@Kaiiim
Apr 13 2016 09:26 UTC

function findLongestWord(str) {
var i = str.split(' ');
var j = 0;
for ( j = 0; j < i.length; j++)
{
if (i[0].length < i[+1].length)

        {
          return i[+1].length;
        }

     else {
          return i[0].length;
        }

    }    

return i;
}

findLongestWord("Google do a barrel roll");

Chris Cullen
@123xylem
Apr 13 2016 09:26 UTC

// Example
function ourFunction(ourMin, ourMax) {

return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}

ourFunction(1, 9);

// Only change code below this line.

function randomRange(myMin, myMax) {

if (Math.floor(Math.random() (myMin + myMax) ) <= myMin && (Math.floor(Math.random() (myMin + myMax) >= myMax) ))
{ return (Math.floor(Math.random() (myMin + myMax))) ;}
else Math.floor(Math.random()
(myMin + myMax));
}

// Change these values to test your function
var myRandom = randomRange(9, 15);


Any idea why this isnt working? I need to make a number more than myMin and less than myMax

Eldar Tinjić
@EldarT90
Apr 13 2016 09:26 UTC
@daemedeor well i can put .length , its ont an issue, issue is to make 1 element work, than its easy to edit detials :D
@daemedeor and 1 (any element) can work with streamers [0] or [5] or whatever, but NOT with for loop :/
so problem is in FOR loop
but i dont know where
Brendan Kinahan
@BKinahan
Apr 13 2016 09:26 UTC
@123xylem format your code, it's impossible to really read with the gitter markdown formatting like that with the italics instead of *
Olawale Akinseye
@brainyfarm
Apr 13 2016 09:27 UTC
wiki repeat
CamperBot
@camperbot
Apr 13 2016 09:27 UTC

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Justin
@daemedeor
Apr 13 2016 09:35 UTC
@EldarT90 sorry getting tired hopefully someone can sort it out... my hint is function closure and probably console loggin some responses
Kevin
@KevinBruland
Apr 13 2016 09:44 UTC
Is the "Passing Values to Functions with Arguments " section bugged currently?
Eldar Tinjić
@EldarT90
Apr 13 2016 09:44 UTC
@daemedeor oke mate dont worry thanks for your help, i also have to go afk for some hours
CamperBot
@camperbot
Apr 13 2016 09:44 UTC
eldart90 sends brownie points to @daemedeor :sparkles: :thumbsup: :sparkles:
:star: 340 | @daemedeor | http://www.freecodecamp.com/daemedeor
Eldar Tinjić
@EldarT90
Apr 13 2016 09:44 UTC
@daemedeor take care and cya later
Chris Cullen
@123xylem
Apr 13 2016 09:45 UTC
return Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin;
Can some1 explain how this equals a number <=MyMax and >=MyMin???
I dont get it
Kevin
@KevinBruland
Apr 13 2016 09:48 UTC
try substituting in numbers and it might help visualize why, @123xylem
Rujool Doshi
@rujool
Apr 13 2016 09:51 UTC
@123xylem
Lets say Math.random() returns x
0<=x < 1
Multiplying all sides by (myMax+1) - myMin
0<=x((myMax+1)-myMin)<(myMax+1-myMin)
Adding myMin to all sides
myMin <= x
((myMax+1)-myMin < myMax + 1
taking floor
Math.floor(myMin) <= Math.floor(x*(myMax+1)-myMin) <= myMax
where x is Math.random()
Chris Cullen
@123xylem
Apr 13 2016 09:55 UTC
Eurgh... I still cant grasp it... I used to be good at maths
:) This makes me feel so stupid lol
Blauelf
@Blauelf
Apr 13 2016 09:56 UTC
@rujool If you don't want to use code blocks for that, you can escape * in chat by prepending a backslash like \* (same for _).
Rujool Doshi
@rujool
Apr 13 2016 10:00 UTC
@123xylem sorry in the second last step onwards the middle part will be x*((myMax+1)-myMin)+myMin
Chris Cullen
@123xylem
Apr 13 2016 10:00 UTC
lets say mymin=5 myMax=10... can some1 run through Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin; How that is always between 5-10 inclusive?
Rujool Doshi
@rujool
Apr 13 2016 10:01 UTC
Lets say Math.random() = 0.3
Then floor(0.3((10+1)-5))+5
= floor(0.3
(11-5))+5
= floor(0.3*6)+5
= floor(1.8) + 5
= 1 + 5
= 6
Mohamed Ameen
@pmohdameen
Apr 13 2016 10:03 UTC

hey there,
I have a small doubt.

how to remove space from a string using String.replace() ?

Blauelf
@Blauelf
Apr 13 2016 10:03 UTC
0 <= x < 1
0 <= x * (10 - 5 + 1) < 10 - 5 + 1
5 <= x * 6 + 5 < 11
5 <= trunc(x * 6 + 5) <= 10 :)
Rujool Doshi
@rujool
Apr 13 2016 10:04 UTC
@Blauelf well explained
Blauelf
@Blauelf
Apr 13 2016 10:05 UTC
@pmohdameen "foo bar".replace(" ", "") maybe? What do you want to achieve with that?
Mohamed Ameen
@pmohdameen
Apr 13 2016 10:05 UTC
I want to remove white spaces along with special characters
Blauelf
@Blauelf
Apr 13 2016 10:05 UTC
@rujool Just following your path (and using \* instead of just *)
@pmohdameen Learn some regular expression then :)
help js regex
CamperBot
@camperbot
Apr 13 2016 10:06 UTC

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

Mohamed Ameen
@pmohdameen
Apr 13 2016 10:06 UTC
.replace(/ /g,'')
@Blauelf :) yeah. still this aint working .replace(/ /g,'')
Rujool Doshi
@rujool
Apr 13 2016 10:07 UTC
@pmohdameen u want to replace special characters also, so put them in the regex
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 13 2016 10:08 UTC

@malangaveuday
no case-sensitive and string will be random
example ["like", "Like"] ==> true
["like","keli"] => true
my code :
function mutation(arr) {
return (arr[0].toLowerCase().indexOf(arr1.toLowerCase())) !== -1;
}

mutation(["hello", "hey"]);
its not working for second exampl
please any one have idea about this

Mohamed Ameen
@pmohdameen
Apr 13 2016 10:09 UTC

@rujool I tried this

replace(/\s+/g, '');

still aint working
:(
Flurb
@Flurb
Apr 13 2016 10:09 UTC
Anyone here knows how to convert ISO-8859-1 to UTF-8? I tried every page when I google to it
Anyone has experience with it?
Rujool Doshi
@rujool
Apr 13 2016 10:09 UTC
@pmohdameen that would only work for whitespaces r8? which other characters do you want to replace?
Flurb
@Flurb
Apr 13 2016 10:09 UTC
Problem is: Our server responds with Latin1
And our frontend expects UTF-8
Blauelf
@Blauelf
Apr 13 2016 10:10 UTC
@pmohdameen Bad internet connection, so I'll write it again: Build a global (flag g) regex matching the to-be-removed characters. And remember that strings are immutable, so replace returns another string, you have to use that return value.
Flurb
@Flurb
Apr 13 2016 10:10 UTC
Best solution is ofcourse fix it in the backend, but in frontend is maybe faster
Mohamed Ameen
@pmohdameen
Apr 13 2016 10:11 UTC

@Blauelf @rujool will this help ?

val.replace(/^[^a-zA-Z0-9]|[^a-zA-Z0-9]$/g, '');

Blauelf
@Blauelf
Apr 13 2016 10:12 UTC
@Flurb Can you live with some characters not being able to be encoded in ISO-8859-1? So no names (where people might have spanish or turkish names, or even eastern european or kyrillic)
Rujool Doshi
@rujool
Apr 13 2016 10:13 UTC
@pmohdameen You have to remove the ^ and $ from the beginning and end respectively. Also use only one bracket
@pmohdameen Whats the difference between the two brackets
Chris Cullen
@123xylem
Apr 13 2016 10:14 UTC
Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin; Is this easy to understand for u guys? Imagine your explaining it to a 10 year old... Could you try explaining it again ? :)
Blauelf
@Blauelf
Apr 13 2016 10:14 UTC
@pmohdameen No need to be at the start or end of the string, so just val.replace(/[^a-zA-Z0-9]+/g, '') (also, remember you need that assignment, as replace cannot change the immutable string)
Mohamed Ameen
@pmohdameen
Apr 13 2016 10:15 UTC
@rujool @Blauelf :) let me try,
Blauelf
@Blauelf
Apr 13 2016 10:15 UTC
@rujool There's no difference between the brackets, just that one will only match at string start, the other only at string end. No idea why it's done like that.
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 13 2016 10:15 UTC
matching strings in array
no case-sensitive and string will be random
example ["like", "Like"] ==> true
["like","keli"] => true
my code :
function mutation(arr) {
return (arr[0].toLowerCase().indexOf(arr1.toLowerCase())) !== -1;
}
mutation(["hello", "hey"]);
its not working for second exampl
please any one have idea about this
Flurb
@Flurb
Apr 13 2016 10:16 UTC
@Blauelf
Its something like this:
Sîne klâwen durh die wolken sint geslagen
After trying to convert, it shows:
S�ne kl�wen durh die wolken sint geslagen
Sîne klâwen durh die wolken sint geslagen is what Im getting back from the backend
Not converting turns into: S�ne kl�wen durh die wolken sint geslagen
That wrong :smile:
Blauelf
@Blauelf
Apr 13 2016 10:18 UTC
@malangaveuday That would only work if the whole string would be included in the other string. You'll have to check for individual characters to all be included in the first string.
Flurb
@Flurb
Apr 13 2016 10:19 UTC
I wanna have UTF-8
Because frontend expects that
UDAY PRAPHULLA MALANGAVE
@malangaveuday
Apr 13 2016 10:25 UTC
@Blauelf Thank you, I will try to search any solution for this.
CamperBot
@camperbot
Apr 13 2016 10:25 UTC
malangaveuday sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1608 | @blauelf | http://www.freecodecamp.com/blauelf
Chris Cullen
@123xylem
Apr 13 2016 10:31 UTC
Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin; ---------------------------------------does the max+1 always guarantee you can get a number == max?
Blauelf
@Blauelf
Apr 13 2016 10:31 UTC
@Flurb I understand the problem, and the solution I am most familiar with is making it all UTF-8, in every place, everywhere (has quite some performance impact on counting characters). Those codes for î and â somehow look the same to me (I think it's the UTF-8 encoding of that unknown-character sign below), so it looks as if encoding already broke things completely.
@123xylem It does guarantee that you get (myMax - myMin + 1) different states. If your first state is myMin, then the last is myMax. Those should be integers in any case ;)
Flurb
@Flurb
Apr 13 2016 10:33 UTC
We use a database that doesn't use UTF-8, so thats not a solution
Blauelf
@Blauelf
Apr 13 2016 10:35 UTC
@Flurb The codes you showed us already have the information destroyed, can you track where that happens? At which point î and â are still different?
Flurb
@Flurb
Apr 13 2016 10:35 UTC
Its one sample code.
We have a JSON response
in ISO-8895-1
Lets say 'r'
What I do is unescape(encodeURIComponent(r))
response of r is Sîne klâwen durh die wolken sint geslagen is what Im getting back from the backend
output of unescape(encodeURIComponent(r)) is S�ne kl�wen durh die wolken sint geslagen
Thats it :package:
Thats it :smile: lol
Chris Cullen
@123xylem
Apr 13 2016 10:38 UTC
@Blauelf if it was just --- Math.floor(Math.random() * ((myMax + 1) ---- Would that always be max or less inclusive/
?
Blauelf
@Blauelf
Apr 13 2016 10:38 UTC
Have you tried using decodeURIComponent instead of unescape?
@123xylem Your parentheses don't match (missing two closing ones at least)
If you add two closing ), you effectively get the same code as for myMin=0
Flurb
@Flurb
Apr 13 2016 10:41 UTC
Turns out into S�ne kl�wen durh die wolken sint geslagen
Haha
Damn, tricky shizzle
Chris Cullen
@123xylem
Apr 13 2016 10:41 UTC
I lknow im just trying to understand the code
piece by piece
Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin;
Justin
@daemedeor
Apr 13 2016 10:41 UTC
@Flurb what was the solution?
Chris Cullen
@123xylem
Apr 13 2016 10:41 UTC
That doesnt make intuitive sense to me so im trying to break it down
Flurb
@Flurb
Apr 13 2016 10:41 UTC
I dont have the solution yet :smile:
E YG
@laed37
Apr 13 2016 10:42 UTC
Tip for those working on their intermediate front end development projects...CONSOLE LOGGING IS A GODSEND TO TROUBLESHOOT YOUR PROBLEMS. I'm sure all the experts here can agree with that haha
Justin
@daemedeor
Apr 13 2016 10:42 UTC
@Flurb oh hmmm
@laed37 ya it is... did you also know you can do console.table and console.warn
E YG
@laed37
Apr 13 2016 10:43 UTC
I spent almost 5 hours trying to fix my quote generator, it wasn't until in the last 10 mins I decided to console log each function's output to see the problem.
Justin
@daemedeor
Apr 13 2016 10:43 UTC
and also @laed37 did you know you can print out objects with phrases like console.log("hey",a.anotherObj,"this works");
usharya
@usharya
Apr 13 2016 10:43 UTC
for (var i = 0; i <= 5; i++) {
  myArray.push();
}
I am trying to push 1-5 to myArray, but its not working?
Brendan Kinahan
@BKinahan
Apr 13 2016 10:43 UTC
@usharya push needs an argument
Blauelf
@Blauelf
Apr 13 2016 10:43 UTC
@usharya You push nothing. Try myArray.push(i);
usharya
@usharya
Apr 13 2016 10:44 UTC
Ahh Thank you once more @Blauelf @BKinahan
You guys are online most of the times?
CamperBot
@camperbot
Apr 13 2016 10:44 UTC
usharya sends brownie points to @blauelf and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1609 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 1273 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Apr 13 2016 10:44 UTC
@laed37 congrats, you have learned to debug
Justin
@daemedeor
Apr 13 2016 10:44 UTC
console and all its methods are insane asylumns
XD
@Flurb are you using jquery?
E YG
@laed37
Apr 13 2016 10:46 UTC
my quote generator was sort of working before but it didnt always return a quote, turns out I 'forgot' that the filter function for my json iterates through each object and I was generating a new random number for each object (thirty in total)...all I did was move the random number var out of the filter function.
i feel accomplished lol...even though if I showed you guys the code.. you'd probably spot the issue in a heartbeat
Justin
@daemedeor
Apr 13 2016 10:47 UTC
@laed37 its a process
Flurb
@Flurb
Apr 13 2016 10:47 UTC
@Justin no React
jQuery is oldschool :smile:
Justin
@daemedeor
Apr 13 2016 10:48 UTC
@Flurb hmmmm did you try setting the header to contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",?
cannelflow
@cannelflow
Apr 13 2016 10:48 UTC
hey @BKinahan you there
long time WB
Brendan Kinahan
@BKinahan
Apr 13 2016 10:48 UTC
@cannelflow howdy
@cannelflow how's it going?
cannelflow
@cannelflow
Apr 13 2016 10:49 UTC
@BKinahan good @BKinahan finished d3
Brendan Kinahan
@BKinahan
Apr 13 2016 10:49 UTC
nice :)
cannelflow
@cannelflow
Apr 13 2016 10:49 UTC
@BKinahan need some help with leaflet tough
can you help
Brendan Kinahan
@BKinahan
Apr 13 2016 10:50 UTC
probably not, but maybe :D
Flurb
@Flurb
Apr 13 2016 10:51 UTC
@Justin frontend expects UTF-8. We have meta charset="utf-8"
Thats the problem
Justin
@daemedeor
Apr 13 2016 10:51 UTC
@Flurb when you grab it!
oh wait
hmm
Flurb
@Flurb
Apr 13 2016 10:52 UTC
Backend is ISO-8895-1, frontend is UTF-8
Justin
@daemedeor
Apr 13 2016 10:52 UTC
can't you change from charset utf-8?
cannelflow
@cannelflow
Apr 13 2016 10:52 UTC
this is what i got so far https://jsfiddle.net/cannelflow/fzrp4uvc/ @BKinahan need bigger radius and some help on implementing tool tip
Chris Cullen
@123xylem
Apr 13 2016 10:52 UTC
Math.floor(Math.random() * ((myMax + 1) - myMin)) + myMin; Can i just ask... How fast would you need to be able to work this out if you were making a number between min max inclusive? It would take me a long time to work it out...
Mohamed Ameen
@pmohdameen
Apr 13 2016 10:52 UTC
@Blauelf thanks mahn
CamperBot
@camperbot
Apr 13 2016 10:52 UTC
pmohdameen sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
Flurb
@Flurb
Apr 13 2016 10:52 UTC
That fucks a whole lot up haha
CamperBot
@camperbot
Apr 13 2016 10:52 UTC
:star: 1610 | @blauelf | http://www.freecodecamp.com/blauelf
Justin
@daemedeor
Apr 13 2016 10:52 UTC
@Flurb hmmmmmmmmmm solutions solutions
Flurb
@Flurb
Apr 13 2016 10:52 UTC
I just want to convert haha
Justin
@daemedeor
Apr 13 2016 10:54 UTC
@Flurb the thing is ... there is no simple convert like i said XD
@Flurb what's your backend/
or are you pulling straight
Flurb
@Flurb
Apr 13 2016 10:54 UTC
Backend is Latin1 (ISO-8895-1)
So UTF-8 has all the characters of Latin1, except on other places
Justin
@daemedeor
Apr 13 2016 10:55 UTC
no no i mean like language
Flurb
@Flurb
Apr 13 2016 10:55 UTC
Java
Spring
Justin
@daemedeor
Apr 13 2016 10:55 UTC
oh okay
@Flurb did you look up java solutions converting it to utf-8?
usharya
@usharya
Apr 13 2016 10:56 UTC
how will you make the for loop for "Iterate Through an Array with a For Loop"?
wiki Iterate Through an Array with a For Loop
CamperBot
@camperbot
Apr 13 2016 10:57 UTC

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

Challenge: Iterate Through an Array with a For Loop

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

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

Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1.

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

usharya
@usharya
Apr 13 2016 11:03 UTC
how will you make the for loop for "Iterate Through an Array with a For Loop"?
anyone there?
usharya
@usharya
Apr 13 2016 11:08 UTC
anyway, my code
var total = 0;

for (i = 0; i < myArr.length; i++){
  total = total + myArr;
}
Rujool Doshi
@rujool
Apr 13 2016 11:09 UTC
@usharya u have to access the element of the array myArr in each iteration, try to figure that out.
usharya
@usharya
Apr 13 2016 11:11 UTC
thats where I am having the problem. I don't know what to do :(
Ultras05
@Ultras05
Apr 13 2016 11:15 UTC
i need some help

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

celsius = 9/5;

// Only change code above this line
return fahrenheit ;

}

// Change the inputs below to test your code
convertToF(20);

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

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

// Change the inputs below to test your code
convertToF(30);

tom
@tpercival01
Apr 13 2016 11:22 UTC
Can anyone help me with "Make object properties private"?
dennis-noah
@dennis-noah
Apr 13 2016 11:24 UTC
hey everyone
I am struggling with a not that difficult javascript task
can anyone help me?
Rujool Doshi
@rujool
Apr 13 2016 11:24 UTC
@usharya read up on how to access array elements in javascript
dennis-noah
@dennis-noah
Apr 13 2016 11:24 UTC

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

// Your code above this line
return result;
}

// Change the words here to test your function
wordBlanks(myNoun + "" + myAdjective + "" + myVerb + "" + myAdverb);
this is my code

first of all, it tells me : referenceerror: myNoun is not defined even though I clearly define it?
kirbyedy
@kirbyedy
Apr 13 2016 11:26 UTC
in order to define it you need a var infront
but anyway the approach you are taking is not good
dennis-noah
@dennis-noah
Apr 13 2016 11:26 UTC
@kirbyedy what should I change?
@kirbyedy but it was already defined in the function
kirbyedy
@kirbyedy
Apr 13 2016 11:26 UTC
it should be similar to this line: myNoun + "" + myAdjective + "" + myVerb + "" + myAdverb);
dennis-noah
@dennis-noah
Apr 13 2016 11:26 UTC
@kirbyedy in the first line: function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
Nari Roh
@NariRoh
Apr 13 2016 11:27 UTC
help Golf Code
CamperBot
@camperbot
Apr 13 2016 11:27 UTC

:point_right: checkpoint golf code [wiki]

Details

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

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

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

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

par and strokes will always be numeric and positive.

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

Ultras05
@Ultras05
Apr 13 2016 11:27 UTC

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

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

// Change the inputs below to test your code
convertToF(30);

dennis-noah
@dennis-noah
Apr 13 2016 11:27 UTC
@kirbyedy thats what I did isnt it?: wordBlanks(myNoun + "" + myAdjective + "" + myVerb + "" + myAdverb);
kirbyedy
@kirbyedy
Apr 13 2016 11:27 UTC
not really
// Your code below this line
myNoun="dog";
myAdjective="big";
myVerb="ran";
myAdverb="quickly";
// Your code above this line
return result;
this is what you wrote
note the return
dennis-noah
@dennis-noah
Apr 13 2016 11:28 UTC
@kirbyedy if I define it with var it tell me myNoun is alreadydefined
kirbyedy
@kirbyedy
Apr 13 2016 11:28 UTC
as I said the approach is wrong from the start
myNoun + "" + myAdjective + "" + myVerb + "" + myAdverb follow this
but assign it to the result
dennis-noah
@dennis-noah
Apr 13 2016 11:29 UTC
@kirbyedy but it says your code below this line
kirbyedy
@kirbyedy
Apr 13 2016 11:29 UTC
because as you see in the code that i pasted you are returning the result
dennis-noah
@dennis-noah
Apr 13 2016 11:29 UTC
@kirbyedy ahh
Ultras05
@Ultras05
Apr 13 2016 11:29 UTC
I need some help plz
dennis-noah
@dennis-noah
Apr 13 2016 11:30 UTC
@Ultras05 with what?
@kirbyedy but it still says myNoun is not defined
Ultras05
@Ultras05
Apr 13 2016 11:30 UTC

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

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

// Change the inputs below to test your code
convertToF(30);

dennis-noah
@dennis-noah
Apr 13 2016 11:30 UTC
@kirbyedy myNoun = "dog"
it says not defined all the time
@Ultras05 do you not understand the task?
Ultras05
@Ultras05
Apr 13 2016 11:30 UTC
Yup
dennis-noah
@dennis-noah
Apr 13 2016 11:31 UTC
@Ultras05 I can help you but send the description again please
Aleksa Rakic
@aleksarakic
Apr 13 2016 11:31 UTC

Can someone explain me what is happening in this code?

var an_obj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(an_obj)); // console: ['2', '7', '100']

Why its [2,7,100] and not [100,2,7]?

Justin
@daemedeor
Apr 13 2016 11:32 UTC
@aleksarakic object keys don't inheriently have an order
so its arbitary
dennis-noah
@dennis-noah
Apr 13 2016 11:33 UTC
@Ultras05 ?
Ultras05
@Ultras05
Apr 13 2016 11:33 UTC

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

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

// Change the inputs below to test your code
convertToF(30);

dennis-noah
@dennis-noah
Apr 13 2016 11:33 UTC
@kirbyedy pleasee help me. I really dont get it
kirbyedy
@kirbyedy
Apr 13 2016 11:34 UTC
myNoun + "" + myAdjective + "" + myVerb + "" + myAdverb follow this
erase what you have, reset the challenge
and follow this line above
try to assign your arguments to the result
your last line says 'return result'
dennis-noah
@dennis-noah
Apr 13 2016 11:35 UTC
@kirbyedy thank you :* I got it
CamperBot
@camperbot
Apr 13 2016 11:35 UTC
dennis-noah sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:star: 848 | @kirbyedy | http://www.freecodecamp.com/kirbyedy
dennis-noah
@dennis-noah
Apr 13 2016 11:35 UTC
:package:
:panda_face:
kirbyedy
@kirbyedy
Apr 13 2016 11:35 UTC
paste it here
dennis-noah
@dennis-noah
Apr 13 2016 11:35 UTC
@kirbyedy it worked
kirbyedy
@kirbyedy
Apr 13 2016 11:36 UTC
let me see what you did
dennis-noah
@dennis-noah
Apr 13 2016 11:36 UTC
@kirbyedy okay wait

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

// Your code above this line
return result;
}

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

kirbyedy
@kirbyedy
Apr 13 2016 11:36 UTC
good
dennis-noah
@dennis-noah
Apr 13 2016 11:36 UTC
@kirbyedy Thanks for your help, appreciate it!
CamperBot
@camperbot
Apr 13 2016 11:36 UTC
dennis-noah sends brownie points to @kirbyedy :sparkles: :thumbsup: :sparkles:
:warning: dennis-noah already gave kirbyedy points
kirbyedy
@kirbyedy
Apr 13 2016 11:36 UTC
:thumbsup:
Ultras05
@Ultras05
Apr 13 2016 11:37 UTC
@dennis-noah ?
dennis-noah
@dennis-noah
Apr 13 2016 11:37 UTC
@Ultras05 if you want my help send me the description of the task I know how it goes but I forgot the formular for the calculation of celsius/fahreinheit
@kirbyedy By the way, nice page! Did you make it during your training here?
Aleksa Rakic
@aleksarakic
Apr 13 2016 11:38 UTC
@daemedeor i am trying to understand that, but I cant :) How it is arbitrary? When it is ordered this odd way, and when it is 'normal'?
Ultras05
@Ultras05
Apr 13 2016 11:38 UTC
convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
here's the description
MahaAwaad
@MahaAwaad
Apr 13 2016 11:38 UTC
Change the provided string from double to single quotes and remove the escaping.
var myStr = '<a href = "http://www.example.com" target = "_blank" >Link</a>';
kirbyedy
@kirbyedy
Apr 13 2016 11:39 UTC
@dennis-noah well I did some html before, so I am not totally new to this, but still need lot to learn
MahaAwaad
@MahaAwaad
Apr 13 2016 11:39 UTC
Not Run Why ?@MahaAwaad
Change the provided string from double to single quotes and remove the escaping.
var myStr = '<a href = "http://www.example.com" target = "_blank" >Link</a>';
can help me
Aleksa Rakic
@aleksarakic
Apr 13 2016 11:45 UTC
var an_obj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(an_obj)); // console: ['2', '7', '100']
Why not [100,2,7]? When are keys ordered 'normal' way and when like this?
dennis-noah
@dennis-noah
Apr 13 2016 11:48 UTC
$(document).ready(function){
$("h1").addClass("animated bounce");
};
where do I have a missing or wrong token here?
Aleksa Rakic
@aleksarakic
Apr 13 2016 11:48 UTC
anyone?
kirbyedy
@kirbyedy
Apr 13 2016 11:49 UTC
@daemedeor already answered you @aleksarakic
dennis-noah
@dennis-noah
Apr 13 2016 11:49 UTC
  • $(document).ready(function){
    $("h1").addClass("animated bounce");
    });
made it work:
$(function() {
$("h1").addClass("animated bounce");
});
Dmitry Frolov
@ayatorii
Apr 13 2016 11:51 UTC
Hi guys
cannelflow
@cannelflow
Apr 13 2016 11:52 UTC
@dennis-noah which exercise?
@dennis-noah i think you need to target something else
Dmitry Frolov
@ayatorii
Apr 13 2016 11:52 UTC
I have a brief question about javascript objects
can i ask it here?
Olawale Akinseye
@brainyfarm
Apr 13 2016 11:52 UTC
Go on @ayatorii
cannelflow
@cannelflow
Apr 13 2016 11:52 UTC
@ayatorii yes you can ppl will help if they can
Shivam Arora
@shivamarora13
Apr 13 2016 11:53 UTC

when I pass idStore = '1'

      if (idStore === '2' || '4' || '6' || '8') {
        $("#5").replaceWith('<p id="5">' + comp + '</p>');
      } else if (idStore === '1' || '3' || '9' || '5') {
        $("#7").replaceWith('<p id="7">' + comp + '</p>');
      }

with this code
than also, only the if loop runs, and not the else if,
even though I think, else if loop should run
can anyone tell why?

Dmitry Frolov
@ayatorii
Apr 13 2016 11:54 UTC
following Javascript lessons here on FreeCodeCamp i noticed, that properties in objects sometimes typed as strings in quotes, and sometimes without them. What does it mean?
I understand that values can be anything, i.e. arrays, strings etc
Olawale Akinseye
@brainyfarm
Apr 13 2016 11:54 UTC

The correct way to do it @dennis-noah is:

$(document).ready(function{

   $("h1").addClass("animated bounce");

});

You added an unnecessary ) after function

cannelflow
@cannelflow
Apr 13 2016 11:54 UTC
@ayatorii without strings are variable i guess
Dmitry Frolov
@ayatorii
Apr 13 2016 11:55 UTC
in lessons i encountered this: "Hunter" : Doberman, ... And this: 16: Ibragimobich, 27: ...
does it make difference to how i get a value from a property of an object?
Islam Ibakaev
@dagman
Apr 13 2016 11:56 UTC
@aleksarakic the documentation says that this method traverse object keys in same order like for...in method do.
Dmitry Frolov
@ayatorii
Apr 13 2016 11:57 UTC
var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]
};
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};
myDog has properties as strings, testObj has props as numbers
Islam Ibakaev
@dagman
Apr 13 2016 11:58 UTC
@aleksarakic the documentation says that for...in traverse object keys in arbitrary order
Dmitry Frolov
@ayatorii
Apr 13 2016 11:58 UTC
Does it make any difference in JAvascript?
Shivam Arora
@shivamarora13
Apr 13 2016 11:58 UTC
When I pass idStore === '1',
console.log(idStore === '2' || '4' || '6' || '8');
this returns me, 4, how I can't understand.
Can anyone tell?
dennis-noah
@dennis-noah
Apr 13 2016 11:59 UTC

@brainyfarm I did it like this: $(document).ready(function() {
$("h1").addClass("text-center");
$("h2").addClass("text-center");

});

Theodore P.
@Ierofantis
Apr 13 2016 11:59 UTC
i have two problems in my tic tac toe project. First of all my reload function for the reload button(the last function)is not working and secondly when I push for example the 'o' that i already add It changes to x.
http://codepen.io/Ierofantis/pen/aNVMQd
Islam Ibakaev
@dagman
Apr 13 2016 11:59 UTC
@shivamarora13 what the whole code look like?
dennis-noah
@dennis-noah
Apr 13 2016 12:00 UTC
@brainyfarm http://codepen.io/Dennis_Noah/pen/PNQpwE my tribute page it's finished :D
Olawale Akinseye
@brainyfarm
Apr 13 2016 12:00 UTC
Good job @dennis-noah :+1:
Arryn
@arnoac
Apr 13 2016 12:00 UTC

So I have this cose:

switch(val){
case 1:
return 'alpha';
break;
case 2:
return 'beta';
break;
case 3:
return 'gamma';
break;
case 4:
return 'delta';
break;
}

it runs but the breaks give warnings that they are unreachable after retun, why's that?

Ali Hammad
@alihammad-gist
Apr 13 2016 12:00 UTC
@shivamarora13 don't you mean to write
console.log(idStore === '2' || idStore === '4' || idStore === '6' || idStore === '8');
kirbyedy
@kirbyedy
Apr 13 2016 12:00 UTC
dont use return @arnoac
dennis-noah
@dennis-noah
Apr 13 2016 12:00 UTC
@brainyfarm thanks :D
CamperBot
@camperbot
Apr 13 2016 12:00 UTC
dennis-noah sends brownie points to @brainyfarm :sparkles: :thumbsup: :sparkles:
:star: 1824 | @brainyfarm | http://www.freecodecamp.com/brainyfarm
Arryn
@arnoac
Apr 13 2016 12:00 UTC
@kirbyedy then what do i use instead
Olawale Akinseye
@brainyfarm
Apr 13 2016 12:01 UTC
Are you trying to animate h1 and h2 @dennis-noah ?