These are chat archives for FreeCodeCamp/HelpJavaScript

28th
Jun 2016
Lauren Adam
@laurenamy
Jun 28 2016 00:00
onto the advanced scripting! having trouble with Validate US Telephone Numbers. there are a handful of tests that aren't testing true when they should, I'd be most grateful if someone could take a look!
function telephoneCheck(str) {
  // Good luck!
  var numbers = [];
  var flag;

  for (var i = 0; i < str.length; i++) {
    //check that parenthesis are in correct relation to each other
    if (str[i] === "(" && str[i+4] !== ")" || str[i] === ")") {
      flag = false;
      break;
    }
    //push to array if value is a number
    if (!isNaN(str[i]) && str[i] !== " ") {
      numbers.push(str[i]);
    }
  }

  var length = numbers.length;
  //check if right length & right area code
  if (length === 11 && numbers[0] === 1) {
    flag = true;
    //check if too short or too long
  } else if (length < 10 || length > 11) {
    flag = false;
    //check if correct length
  } else if (length === 10) {
    flag = true;
  } else {
    flag = false;
  }

  console.log(length);
  console.log(numbers);

  return flag;
}
Kraig Kistler
@kwkistler
Jun 28 2016 00:02
@sayedafif Thanks
CamperBot
@camperbot
Jun 28 2016 00:02
kwkistler sends brownie points to @sayedafif :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @sayedafif |http://www.freecodecamp.com/sayedafif
sixtus9
@sixtus9
Jun 28 2016 00:02

// Declare your variable here

function fun1() {
// Assign 5 to oopsGlobal Here

}

// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}

Declare a global variable myGlobal outside of any function. Initialize it to have a value of 10

Inside function fun1, assign 5 to oopsGlobal without using the var keyword.

whaaat does it mean
Diego Mayer
@Chrono79
Jun 28 2016 00:03
@sixtus9 review previous challenges, those instructions are pretty self-explanatory
sixtus9
@sixtus9
Jun 28 2016 00:05
says you
Diego Mayer
@Chrono79
Jun 28 2016 00:06
@laurenamy look at this condition again: if (str[i] === "(" && str[i+4] !== ")" || str[i] === ")") {
@sixtus9
Declare a global variable myGlobal outside of any function. Initialize it to have a value of 10
// Declare your variable here
Declare JavaScript Variables
Initializing Variables with the Equal Operator
Those are previous challenges you should review in order to do what is asked
sixtus9
@sixtus9
Jun 28 2016 00:08
ok i got it thx @Chrono79
CamperBot
@camperbot
Jun 28 2016 00:08
sixtus9 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1333 | @chrono79 |http://www.freecodecamp.com/chrono79
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:08
am i close ?
function smallestCommons(arr) {
  arr = arr.sort();
  var number = arr[0];
  var secArr = [];
  // create a new list with all values to check against.
  while (number >= arr[0] && number <= arr[1]) {
    secArr.push(number);
    number++;
  }

  var commonMultiple = 0;

  while (true) {
    for (var i = 0; i < secArr.length; i++) {
      if (i % commonMultiple !== 0) {
        commonMultiple++;
        break;
      }
    }
    return commonMultiple;
  }
}

smallestCommons([1,5]);
i have to find the LCM of the numbers in the range
but its returning 1, should return 60
Diego Mayer
@Chrono79
Jun 28 2016 00:09
@Sperkajugglite look at this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort sort by itself doesn't work with numbers
llamatarianism
@llamatarianism
Jun 28 2016 00:10
@Sperkajugglite simpler solution:
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:10
the sort is working for me
llamatarianism
@llamatarianism
Jun 28 2016 00:11
use some algorithm to find the highest common factor of 2 numbers
Diego Mayer
@Chrono79
Jun 28 2016 00:11
@Sperkajugglite just by chance, it sorts alphabetically
      if (i % commonMultiple !== 0) { //at i === 1 this is true and you exit your loop
        commonMultiple++;
        break;
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:11
eulest algorithm?
its too long
llamatarianism
@llamatarianism
Jun 28 2016 00:11
use that to find the lowest common multiple of 2 numbers (a * b) / gcd(a, b)
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:11
i know
but that way its longer
llamatarianism
@llamatarianism
Jun 28 2016 00:12
no it isn't
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:12
do you see the problem in the while loop?
Lauren Adam
@laurenamy
Jun 28 2016 00:12
@Chrono79 Sorry, I'm just not picking up what you're throwing down :(
llamatarianism
@llamatarianism
Jun 28 2016 00:12
the euclidean algorithm is 1 line of code
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:12
besides i forgot the secure[]
uniforlyff
@uniforlyff
Jun 28 2016 00:12
How do I get rid of the quotes here's my code for Caesar's Cipher :
function rot13(str) { 
  var a = [];
  var c = [];
  for(var i = String.charCodeAt('a'); i <= String.charCodeAt('z'); i++) {
    a.push(i);
  }

  a.splice(13, 26);
  for(var i = 0; i < str.length; i++) {
    c.push(String.charCodeAt(str[i]));
  }

  for(var i = 0; i < c.length; i++) {
    if(c[i] === String.charCodeAt(' ')) {
      c[i] = String.charCodeAt(' ');
    } else if(c[i] <= a[a.length - 1]) {
      c[i] += 13;
    } else {
      c[i] -= 13; 
    }
  }
  str = c.join(); //"96,82,95,95,32,93,79,94,95,32,93,91,103,80" > 96,82,95,95,32,93,79,94,95,32,93,91,103,80
  return String.fromCharCode(str).toUpperCase();
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
llamatarianism
@llamatarianism
Jun 28 2016 00:12
const gcd = (a, b) => a === 0 ? b : gcd(b, a % b)
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:13
ok ill try thanks@llamatarianism @Chrono79
sixtus9
@sixtus9
Jun 28 2016 00:13

function myLocalScope() {
'use strict';

console.log(myVar);
}
myLocalScope();

// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);

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

CamperBot
@camperbot
Jun 28 2016 00:13
sperkajugglite sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1334 | @chrono79 |http://www.freecodecamp.com/chrono79
sixtus9
@sixtus9
Jun 28 2016 00:13
i dont get what to do
Santiago Gómez
@Sperkajugglite
Jun 28 2016 00:13
thanks @llamatarianism
CamperBot
@camperbot
Jun 28 2016 00:13
sperkajugglite sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 847 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Stephen James
@sjames1958gm
Jun 28 2016 00:13
@sixtus9 remove the line above the comment
Richard
@codecampergg
Jun 28 2016 00:14

Hi everyone! I'm on the Title Case a Sentence but I'm stuck, can anyone help me? This is my code


function titleCase(str) {
var bn = str.split(" ");

for(i = 0; i < bn.length; i++) {
   console.log(bn[i][0]);
}

  bn[i][0].toUpperCase();


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

What do I have wrong?

sixtus9
@sixtus9
Jun 28 2016 00:14
myLocalScope(); this?
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:14
Did anybody do switch case statement for the romanNumberal problem? What approach did you take?
Richard
@codecampergg
Jun 28 2016 00:14
I'm on the Title Case a Sentence challenge*
sorry about that
Diego Mayer
@Chrono79
Jun 28 2016 00:15
@laurenamy what are you using flag for?
uniforlyff
@uniforlyff
Jun 28 2016 00:15
Eh how to:
'23, 34, 54, 56, 75, 76, 67, 46' into 23, 34, 54, 56, 75, 76, 67, 46
sixtus9
@sixtus9
Jun 28 2016 00:15
i removed console.log(myVar); and it didnt work
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:15
@Chrono79 did you use a switch case statement for the Roman Numeral problem??
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:15
stuck on javascript?
Diego Mayer
@Chrono79
Jun 28 2016 00:16
@codecampergg this for itself doesn't modify the string: bn[i][0].toUpperCase();
Lauren Adam
@laurenamy
Jun 28 2016 00:16
@Chrono79 to decide if the statement returns true or false?
Stephen James
@sjames1958gm
Jun 28 2016 00:16
@Vanhealen I did a sequence of if/else if testing if the current value was greater than each numeral value. Subtracting until zero
Diego Mayer
@Chrono79
Jun 28 2016 00:16
@Vanhealen yes
@sjames1958gm solution seemed more elegant
Richard
@codecampergg
Jun 28 2016 00:17
mm so what can I do? @Chrono79
llamatarianism
@llamatarianism
Jun 28 2016 00:17
blugh sorry
Diego Mayer
@Chrono79
Jun 28 2016 00:17
@laurenamy aren't you overwriting flag later?
Richard
@codecampergg
Jun 28 2016 00:17
give me a hint or something
llamatarianism
@llamatarianism
Jun 28 2016 00:17
internet broke
@Sperkajugglite you're returning inside the lip
loop*
so you only ever go through it once
Diego Mayer
@Chrono79
Jun 28 2016 00:18
@codecampergg you can replace a word with another word, you can make it with a letter plus the rest of the word, or use String.replace method
sixtus9
@sixtus9
Jun 28 2016 00:19

function myLocalScope(myVar) {
'use strict';

console.log(myVar);
}
myLocalScope();

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

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

Diego Mayer
@Chrono79
Jun 28 2016 00:19
@sixtus9 you have to declare myVar inside the function and give it a value
sixtus9
@sixtus9
Jun 28 2016 00:20
how
Richard
@codecampergg
Jun 28 2016 00:20
Thanks @Chrono79
CamperBot
@camperbot
Jun 28 2016 00:20
codecampergg sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1335 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 28 2016 00:21
@sixtus9 myVar = "something";
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:21
@Chrono79 yeah but how did you add in the character into the middle of the string using splice?? That would be a lot of code for each case
Diego Mayer
@Chrono79
Jun 28 2016 00:21
@Vanhealen you can take a look at my FCC profile if you want
llamatarianism
@llamatarianism
Jun 28 2016 00:22
@Vanhealen I used a greedy algorithm
sixtus9
@sixtus9
Jun 28 2016 00:22

function myLocalScope(myVar) {
'use strict';
var loc = "myVar";
myVar = "something";
console.log(myVar);
}
myLocalScope();

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

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

didnt work
llamatarianism
@llamatarianism
Jun 28 2016 00:23
if the number's bigger than 1000, keep taking away 1000 from it and adding "M" to the string until it isn't
then do the same with 900 and "CM" and so on until the number is 0
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:24
please can anyone help me in level 165
anybody please??
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:24
@llamatarianism did you just do a bunch of if/else chaining inside something like a while loop?
llamatarianism
@llamatarianism
Jun 28 2016 00:24
@MohammadHasham challenges don't have numbers
@Vanhealen no
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:24
how did you create all the cases then?
llamatarianism
@llamatarianism
Jun 28 2016 00:24
I used an object for lookup
and I kept track of which letter was the current letter using a variable
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:25
you saved everything into an object?
llamatarianism
@llamatarianism
Jun 28 2016 00:25
define "everything"
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:25
the num key and values
llamatarianism
@llamatarianism
Jun 28 2016 00:25
yes
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:25
did you make keys for "V" and "C" and "L"
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:25
what does that mean "myStr should not have ant spaces in between consecutive escape sequences"
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:25
okay ill check out ur code
llamatarianism
@llamatarianism
Jun 28 2016 00:26
not sure if I've updated it recently
if I haven't it might be a mess
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:26
@llamatarianism yeah i cant find it
Diego Mayer
@Chrono79
Jun 28 2016 00:26
@sixtus9 delete this: var loc = "myVar"; and add var before myVar = "something";
llamatarianism
@llamatarianism
Jun 28 2016 00:26
gimme a sec
Diego Mayer
@Chrono79
Jun 28 2016 00:27
@MohammadHasham that \t \t is wrong and \t\t is ok
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:27
@Chrono79 thanks
CamperBot
@camperbot
Jun 28 2016 00:27
mohammadhasham sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1336 | @chrono79 |http://www.freecodecamp.com/chrono79
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:28
i'll check that
sixtus9
@sixtus9
Jun 28 2016 00:28
thx @Chrono79
CamperBot
@camperbot
Jun 28 2016 00:28
sixtus9 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: sixtus9 already gave chrono79 points
llamatarianism
@llamatarianism
Jun 28 2016 00:28
@Vanhealen yep it's recent
linky mclinkface%20%7B%0A%20%20const%20numerals%20%3D%20%7B%0A%20%20%20%20%22M%22%3A1000%2C%0A%20%20%20%20%22CM%22%3A900%2C%0A%20%20%20%20%22D%22%3A500%2C%0A%20%20%20%20%22CD%22%3A400%2C%0A%20%20%20%20%22C%22%3A100%2C%0A%20%20%20%20%22XC%22%3A90%2C%0A%20%20%20%20%22L%22%3A50%2C%0A%20%20%20%20%22XL%22%3A40%2C%0A%20%20%20%20%22X%22%3A10%2C%0A%20%20%20%20%22IX%22%3A9%2C%0A%20%20%20%20%22V%22%3A5%2C%0A%20%20%20%20%22IV%22%3A4%2C%0A%20%20%20%20%22I%22%3A1%0A%20%20%7D%3B%0A%20%20const%20letters%20%3D%20Object.keys(numerals)%3B%0A%20%20%0A%20%20function%20doConversion(n%2C%20keys%2C%20romanised)%20%7B%0A%20%20%20%20const%20currentNum%20%3D%20numerals%5Bkeys%5B0%5D%5D%3B%0A%20%20%20%20if%20(n%20%3D%3D%3D%200%20%7C%7C%20keys.length%20%3D%3D%3D%200)%20%7B%0A%20%20%20%20%20%20return%20romanised%3B%0A%20%20%20%20%7D%20else%20if%20(n%20%3E%3D%20currentNum)%20%7B%0A%20%20%20%20%20%20return%20doConversion(n%20-%20currentNum%2C%20keys%2C%20romanised%20%2B%20keys%5B0%5D)%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20return%20doConversion(n%2C%20keys.slice(1)%2C%20romanised)%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20%0A%20%20return%20doConversion(number%2C%20letters%2C%20%22%22)%3B%0A%7D%0A%0AconvertToRoman(2)%3B)
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:29
@llamatarianism i dont see it on ur github
@llamatarianism I also don't know where to look exactly
llamatarianism
@llamatarianism
Jun 28 2016 00:29
markdown you have betrayed me
just look on my freecodecamp profile
Diego Mayer
@Chrono79
Jun 28 2016 00:29
@MohammadHasham don't leave a space after the last \t and Here either
Jonathan Mitchell
@Vanhealen
Jun 28 2016 00:30
@llamatarianism how
llamatarianism
@llamatarianism
Jun 28 2016 00:30
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:30
okay ill check @Chrono79
llamatarianism
@llamatarianism
Jun 28 2016 00:30
then ctrl F "roman"
Diego Mayer
@Chrono79
Jun 28 2016 00:30
@llamatarianism your code fails for 4000 :P
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:31
@Chrono79 still the error is there.
Diego Mayer
@Chrono79
Jun 28 2016 00:31
@MohammadHasham show your code
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:31
var myStr='\I am a good\t\tboy\n.';
@Chrono79 var myStr='\I am a good\t\tboy\n.';
llamatarianism
@llamatarianism
Jun 28 2016 00:32
@Chrono79 really?
Diego Mayer
@Chrono79
Jun 28 2016 00:32

@MohammadHasham
Instructions
Assign the following two lines of text into the single variable myStr using escape sequences.

Here is a backslash: .
Here is a new line with two tabs.
You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above with no additional spaces between each escape sequence.

Here is the text with the escape sequences written out.

Here is a backslash: backslash.newline tab tab Here is a new line with two tabs.

@llamatarianism yes, but I'm just pulling your hair, it gives MMMM and the greatest test number is 3999
llamatarianism
@llamatarianism
Jun 28 2016 00:33
I thought MMMM was right
I suppose it fails for 0 actually
Diego Mayer
@Chrono79
Jun 28 2016 00:34
I don't know if romans had 0
llamatarianism
@llamatarianism
Jun 28 2016 00:34
since it just returns "" instead of "nvlla"
Diego Mayer
@Chrono79
Jun 28 2016 00:34
I think not
Gary Siu
@GarySiu
Jun 28 2016 00:34
Romans don't have 0 or 4000 ;)
llamatarianism
@llamatarianism
Jun 28 2016 00:34
they didn't have the number 0
but I'm pretty sure they still had a word for it
Gary Siu
@GarySiu
Jun 28 2016 00:35
I think it's the root for null but I don't dare guess
Wikipedia to the rescue! The number zero does not have its own Roman numeral, but the word nulla (the Latin word meaning "none") was used by medieval scholars in lieu of 0.
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:36
@Chrono79 var myStr="Here is a\:\n\t\t\Here is a newline with two tabs.";
please can anyone help?
Thomas hadley
@Thadley17
Jun 28 2016 00:37
Hey guys, I've been stuck on "Profile Lookup", specifically getting names who don't exist to return "No such contact". I am able to get everything else working. I feel like I am close but I am clearly missing something. Is anyone able to give me some direction? :)
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:37
Anybody???
Paul Borawski
@iAmNawa
Jun 28 2016 00:38
@MohammadHasham hello how can I help?
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:38
i would be really thankful if u would help
myStr should not have any spaces in between consecutive escape sequences.
Diego Mayer
@Chrono79
Jun 28 2016 00:38
@MohammadHasham why is there a backslash before the : ? You deleted a period there too
Muhammad Hasham
@MohammadHasham
Jun 28 2016 00:38
in var myStr="Here is a\:\n\t\t\Here is a newline with two tabs."
var myStr="Here is a\:\n\t\t\Here is a newline with two tabs."
sorry @Chrono79
var myStr="Here is a\:\n\t\t\Here is a newline with two tabs."
there are two backlashes i wonder why it isnot showing
on gitter
i have two backlashes before :
@iAmNawa var myStr="Here is a\:\n\t\t\Here is a newline with two tabs."
i am realley sstuck
anyone?????
Diego Mayer
@Chrono79
Jun 28 2016 00:45
@MohammadHasham
Here is a backslash: backslash.newline tab tab Here is a new line with two tabs.
the bold text is what you have to replace with the escaped codes
@llamatarianism http://romannumerals.babuo.com/4000-in-roman-numerals <- I thought this was the right way of doing it. It seems to be called Vinculum: https://en.wikipedia.org/wiki/Roman_numerals
http://artlung.com/smorgasborg/roman-numerals/?page=4 <- here they keep adding Ms
llamatarianism
@llamatarianism
Jun 28 2016 00:53
odd
Diego Mayer
@Chrono79
Jun 28 2016 00:53
@Thadley17 show your code
llamatarianism
@llamatarianism
Jun 28 2016 00:53
well people only ever use roman numerals for what year it is anyways
and I'll be dead long before the year ĪV
(close enough)
Raj Sharma
@rajsharma1612
Jun 28 2016 00:54
how to solve Counting Cards problem..
Diego Mayer
@Chrono79
Jun 28 2016 00:54
@llamatarianism They'll remember your code didn't work for them :P Like Y2K
Surely someone will make a profit from that too
Raj Sharma
@rajsharma1612
Jun 28 2016 00:54
I am having problem.
llamatarianism
@llamatarianism
Jun 28 2016 00:57
@rajsharma1612 what's the problem and what does your code look like
Raj Sharma
@rajsharma1612
Jun 28 2016 00:57
@llamatarianism problem name is Counting Cards
@llamatarianism and my code looks like as below-

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 7:
case 8:
case 9:
count=0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
break;
}

if(count>0){
return count+" Bet";
}
else if(count ===0 || count < 0){
return count+" Hold";
}
// Only change code above this line
}

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

Diego Mayer
@Chrono79
Jun 28 2016 00:58
@rajsharma1612 count=0; that's a problem
llamatarianism
@llamatarianism
Jun 28 2016 00:58
yeah you're supposed to do nothing in those cases
not reset count entirely
Raj Sharma
@rajsharma1612
Jun 28 2016 00:59
but in the table it is written 0 when 7,8,9?
llamatarianism
@llamatarianism
Jun 28 2016 00:59
by the way, you can replace count ===0 || count < 0 with count <= 0
that means you're supposed to add 0 to it
and adding
Diego Mayer
@Chrono79
Jun 28 2016 00:59
@rajsharma1612 Count Change, if it's 0 it means it remains the same
llamatarianism
@llamatarianism
Jun 28 2016 00:59
0 to something is the same as doing nothing
Raj Sharma
@rajsharma1612
Jun 28 2016 01:01
@Chrono79 thanks I understood...
CamperBot
@camperbot
Jun 28 2016 01:01
rajsharma1612 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1337 | @chrono79 |http://www.freecodecamp.com/chrono79
Raj Sharma
@rajsharma1612
Jun 28 2016 01:01
@llamatarianism ton of thanks. I worked and I replaced my conditions also as per your suggestions.
CamperBot
@camperbot
Jun 28 2016 01:01
rajsharma1612 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 849 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
uniforlyff
@uniforlyff
Jun 28 2016 01:19
Read the comments, can't figure it out :P
function rot13(str) { 
  var a = [];
  var c = [];
  for(var i = String.charCodeAt('A'); i <= String.charCodeAt('Z'); i++) {
    a.push(i);
  }

  a.splice(13, 26);
  for(var i = 0; i < str.length; i++) {
    c.push(String.charCodeAt(str[i]));
  }

  for(var i = 0; i < c.length; i++) {
    if(c[i] < String.charCodeAt('A')) {
      c[i] = c[i];
    } else if(c[i] <= a[a.length - 1]) {
      c[i] += 13;
    } else {
      c[i] -= 13; 
    }
  }
  str = c.join();
  // turn this string 
  // "70,82,69,69,32,67,79,68,69,32,67,65,77,80"
  // into 
  // 70,82,69,69,32,67,79,68,69,32,67,65,77,80
  return String.fromCharCode(str);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Fernand
@Ferdyboy81
Jun 28 2016 01:20
guys,,, how do i turn these numbers into a string?

function arrayToString() {
var numbers = [4,3,5,3,2,3];
var x = arrayToString;

x.function = numbers.join();

uniforlyff
@uniforlyff
Jun 28 2016 01:27
you can just go numbers.join() @Ferdyboy81
sixtus9
@sixtus9
Jun 28 2016 01:28

// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var Outfit = "sweater";

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

myOutfit();

can someone tell me why this is wrong
Fernand
@Ferdyboy81
Jun 28 2016 01:28
@uniforlyff what am i missing here:

function arrayToString(numbers) {
numbers.join();

}

arrayToString([3,4,5,6]);

sixtus9
@sixtus9
Jun 28 2016 01:29
nvm i got it
Daniel Ekwuazi
@Dcwind
Jun 28 2016 01:31

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

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

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

Alexander Køpke
@alexanderkopke
Jun 28 2016 01:32
@Ferdyboy81 are you suppose to return it?
Daniel Ekwuazi
@Dcwind
Jun 28 2016 01:32
please I need help, I solved it but it seems messy to me.
Stephen James
@sjames1958gm
Jun 28 2016 01:33
@Dcwind you will need to use if/else if to compare strokes to par. There is a special case for hole in one
@Dcwind post code
Michael Wolf Hoffman
@mwolfhoffman
Jun 28 2016 01:37

Can I get some guidance on the "Counting Card" assignment

var count = 0;

function cc(card) {
// Only change code below this line
if (card <= 6){
count = 1card;
return count + "Bet";
}else if (card >= 7 && card <= 9){
count = 0;
return count + "Hold";
}else{
count = -1
card;
return count + "Hold";
}

Stephen James
@sjames1958gm
Jun 28 2016 01:38
Help format
CamperBot
@camperbot
Jun 28 2016 01:38

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

sixtus9
@sixtus9
Jun 28 2016 01:39

// Example
var changed = 0;

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

changed = change(10);

// Setup
var processed = 0;

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

// Only change code below this line

Call the processArg function with an argument of 7 and assign its return value to the variable processed.
ion get it, what do
Thomas hadley
@Thadley17
Jun 28 2016 01:40

@Chrono79

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

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

I'm not sure if you are still here. I was away. I just can't seem to get the "no such contact" part to work. They rest does though :s I am kinda stuck on this

Stephen James
@sjames1958gm
Jun 28 2016 01:41
@sixtus9 the line above Setup is calling the function change with an argument of 10 and signing the return value to the variable changed
Diego Mayer
@Chrono79
Jun 28 2016 01:41
@Thadley17 when should you return "No such contact"? After you've looked over the whole list
Also look at this:
 if(contacts[i].firstName == firstName){
  ...
  } else if(contacts[i].firstName != firstName){
sixtus9
@sixtus9
Jun 28 2016 01:42
what does that even mean
Stephen James
@sjames1958gm
Jun 28 2016 01:42
@Thadley17 the check for not equal to first name is inside an if that has first name equal. If you move your return no such contact after the for loop it will be correct
@sixtus9 I was describing his
Nick Neuman
@neecholaus
Jun 28 2016 01:44
hey i need help. when i run the requirements it says are not met, it returns what it says it should. but its not letting me pass. anyone know whats going on?
Stephen James
@sjames1958gm
Jun 28 2016 01:44
How similar code above can be used as a pattern
Diego Mayer
@Chrono79
Jun 28 2016 01:45
@neecholaus we need some code to see what is happening
Nick Neuman
@neecholaus
Jun 28 2016 01:45
i know its not letting me paste it for some reason
@Chrono79 how do i add a comment with a block of code like you posted just a bit ago
Diego Mayer
@Chrono79
Jun 28 2016 01:48
help format
CamperBot
@camperbot
Jun 28 2016 01:48

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Nick Neuman
@neecholaus
Jun 28 2016 01:48

'''// Setup
function abTest(a, b) {
// Only change code below this line
if (a < 0 || 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);

CamperBot
@camperbot
Jun 28 2016 01:48
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Jun 28 2016 01:49
@neecholaus remove the " around undefined
Stephen James
@sjames1958gm
Jun 28 2016 01:50
@neecholaus with the quotes that is a string. They want you to return the value undefined which is a special value in JavaScript
Nick Neuman
@neecholaus
Jun 28 2016 01:50
@Chrono79 ok so they wanted it to be the keyword and not just a string?
Diego Mayer
@Chrono79
Jun 28 2016 01:50
exactly
Nick Neuman
@neecholaus
Jun 28 2016 01:50
@Chrono79 @sjames1958gm sweet thanks guys
CamperBot
@camperbot
Jun 28 2016 01:50
neecholaus sends brownie points to @chrono79 and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1662 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1338 | @chrono79 |http://www.freecodecamp.com/chrono79
Thomas Nguyen
@thomasnguyen
Jun 28 2016 02:00
http://thomasnguyen.co/admin/
how can I make it so when i click on the hamgburger icon the rest of the content moves left too
Landon West
@LandonWest
Jun 28 2016 02:04
Can anyone tell me - does the browser navigator function not work in codepen? I'm trying to get a user's location for the current weather project...
Stephen James
@sjames1958gm
Jun 28 2016 02:05
When using http and chrome it does allow
Recent change in chrome. You can use the ip-api.com site to get location based on ip address
Landon West
@LandonWest
Jun 28 2016 02:06
I am using chrome and http, but when the page refreshes it's not giving me the popup to ask if I want to allow location...
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$('#geoweather').html('latitude: ' + position.coords.latitude + '<br>longitude: ' + position.coords.longitude);
});
}
Stephen James
@sjames1958gm
Jun 28 2016 02:07
Open your devtools you should see an error
It won't even ask for permission
Landon West
@LandonWest
Jun 28 2016 02:08
yep, you're right, it says it's depricated and to use https
Stephen James
@sjames1958gm
Jun 28 2016 02:09
If you use https then the open weather site went work :( unless you pay them
Gary Siu
@GarySiu
Jun 28 2016 02:10
I've seen people recommend forecast.io as an alternative api
Haven't tried their API yet but their apps are good :)
Landon West
@LandonWest
Jun 28 2016 02:12
I was looking at the WeatherUnderground api, but it's only 10 calls per minute-free, vs. open weather which is 60
Samuel Odians
@samogba
Jun 28 2016 02:13
Could anyone help provide solution to the Stand in Line excercise?
Landon West
@LandonWest
Jun 28 2016 02:16
wow, forecast.io says first 1,000 request/day are free and it appears to be https!
Francisco Pena
@daiky00
Jun 28 2016 02:37
anyone knows laravel really well here
?
Juan Morban
@cao2828
Jun 28 2016 02:43

var convert = function(num) {

// Create arrays with default conversion with matching indices.
var decimalValue = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000];
var romanNumeral = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M'];

// Create a copy of num to work on and an empty string variable for the final roman number
var numCopy = num;
var romanized = '';

// While the decimal number is greater than 0,
while (numCopy > 0) {
// Loop through the indices of the decimalValue array.
for (var index = 0; index < decimalValue.length; index++) {
// Get the maximum decimal number less or equal then the decimal number.
if (+decimalValue[index] <= numCopy && +decimalValue[+index + 1] > numCopy) {
// Add the Roman numeral & decrease numCopy by the decimal equivalent.
romanized += romanNumeral[index];
numCopy -= decimalValue[index];
}
}
}

return romanized;

Need roman numeral convert
Thomas hadley
@Thadley17
Jun 28 2016 02:50
@sjames1958gm ok so I put the part that evaluates the no such contact outside of the loop, it tells me that it cannot read the property firstName of undefined and if I put it inside the loop but outside the main if statement, it works but everything is fails.
everything else * fails
LonePoop
@LonePoop
Jun 28 2016 02:57
Having trouble with "Record Collection" exercise of javascript?
Thomas hadley
@Thadley17
Jun 28 2016 02:57
me?
LonePoop
@LonePoop
Jun 28 2016 02:58
Nah me haha
Thomas hadley
@Thadley17
Jun 28 2016 02:58
what are you stuck on?
haamza
@haamza
Jun 28 2016 02:59
Hi, can some one help me in 'Title Case a Sentence' ?
Juan Morban
@cao2828
Jun 28 2016 02:59
I got it guys Thanks
haamza
@haamza
Jun 28 2016 03:00
Anyone?
Thomas hadley
@Thadley17
Jun 28 2016 03:01
I'm not there yet :(
haamza
@haamza
Jun 28 2016 03:01
No problem bro
Thomas hadley
@Thadley17
Jun 28 2016 03:02
I'd try and help if I could lol. Stuck on profile lookup myself lol
Been working on this algorithm for awhile now. I can't seem to get my code to return false. All the checks for return true are good but none of the checks for return false are.
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:06
Is anyone up and able to help me out with this JS challenge?
Matt
@TheeMattOliver
Jun 28 2016 03:07
@IAmJohnOconnell which challenge are you working on
John Calhoun
@DougCal
Jun 28 2016 03:08
Forgot to mention, the challenge is called "Check for Palindromes."
Daniel Cartín
@Danielcv93
Jun 28 2016 03:09
hi, i want to know why the button doesn't work :worried:
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:09
@TheeMattOliver Stand In Line
KSchmieg
@KSchmieg
Jun 28 2016 03:09
Hi everyone! I am randomly stuck on the dumbest thing... if anyone has a minute for a novice!
Matt
@TheeMattOliver
Jun 28 2016 03:09
lay it on us @KSchmieg
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:09
I'm assuming I'm supposed to use shift and unshift to makee the function work..
Matt
@TheeMattOliver
Jun 28 2016 03:09
ok @IAmJohnOconnell what do you have so far?
KSchmieg
@KSchmieg
Jun 28 2016 03:09
OK, I'm doing the escape sequences in strings.
It's supposed to look like this:
Matt
@TheeMattOliver
Jun 28 2016 03:10
@KSchmieg paste your code here by typing three backticks (```), then paste the code, then another three backticks
KSchmieg
@KSchmieg
Jun 28 2016 03:10
Here is a backslash: .
Here is a new line with two tabs.
Here's my code: var myStr = "Here is a backslash: \.\n\t\t Here is a new lin with two tabs.";
Matt
@TheeMattOliver
Jun 28 2016 03:10
@KSchmieg yep, familiar with that one, it's very unforgiving syntax-wise, make sure you have no spaces between your escape sequences
KSchmieg
@KSchmieg
Jun 28 2016 03:10
But it's not taking it, and I don't know what's wrong.
Daniel Cartín
@Danielcv93
Jun 28 2016 03:11
someone?
:(
Matt
@TheeMattOliver
Jun 28 2016 03:12
@IAmJohnOconnell So we've got an array (arr) and a number (item) as arguments.
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:13
right, I'm thinking i need to do something along the lines of item.shift() and item.unshift() but i'm not sure.
Matt
@TheeMattOliver
Jun 28 2016 03:13
We want to add the number to the end of the array (which would involve what?) -- that's the first part
@KSchmieg compare that to this:
var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs.";
@IAmJohnOconnell then, after we get that number added to the array
Boris
@boris-in-london
Jun 28 2016 03:14
@DougCal , you still here?
Matt
@TheeMattOliver
Jun 28 2016 03:14
we have to remove the first element of array. (so how would we do that?)
KSchmieg
@KSchmieg
Jun 28 2016 03:14
Thanks! So frustrating!
It's fixed now!
John Calhoun
@DougCal
Jun 28 2016 03:14
@boris-in-london Yeah, I'm still here.
Matt
@TheeMattOliver
Jun 28 2016 03:14
then, at the end of all that, we have to actually return that thing
so now that it's broken into manageable chunks, let's grab that first bit we have to do
Boris
@boris-in-london
Jun 28 2016 03:15
@DougCal, i went over your code, seems that you are comparing two NULL everytime.
and not the actual palindrome.
Matt
@TheeMattOliver
Jun 28 2016 03:16
@IAmJohnOconnell we have our arr ('arr') and our item ('item') -- how can we add our item to our array?
Boris
@boris-in-london
Jun 28 2016 03:16
thats why all null === null are true and no false values work
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:17
that would be the shift method. Adds an item to the end of an array.
Matt
@TheeMattOliver
Jun 28 2016 03:17
@IAmJohnOconnell you're on the right track...but it's the push() method :)
so that gives us
arr.push(item);
right?
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:18
Ok. so thats where I began to lose myself. I kept thinking I needed to do item.push(??)
Matt
@TheeMattOliver
Jun 28 2016 03:18
then we will use shift() to remove the first element
Norvin Burrus
@ndburrus
Jun 28 2016 03:18
@damole8u replit & send, i'll take a look at it... :sparkles:
Matt
@TheeMattOliver
Jun 28 2016 03:18
BUT
Rajdeep Roy
@RajdeepRoy
Jun 28 2016 03:18
Guys can you help me with this challenge.

playerNumber should be a number
The variable player should be a string
The value of player should be "Montana"
You should use bracket notation to access testObj
You should be using the variable playerNumber in your bracket notation

1

2
// Setup
3
var testObj = {
4
12 : "Namath",
5
16 : "Montana" ,
6
19 : "Unitas"
7
};
8

9
// Only change code below this line;
10

11
var playerNumber=testObj[player]; // Change this Line
12
var player = "Montana";

Matt
@TheeMattOliver
Jun 28 2016 03:19
we have to return that thing
so we can set it equal to a variable, and return that variable
John Calhoun
@DougCal
Jun 28 2016 03:19
@boris-in-london I had a feeling it was something like that. In that case, you know how to make my RegExp not return null? Do you think it involves line 11?
Boris
@boris-in-london
Jun 28 2016 03:19
@DougCal something went wrong here var purgePrep = /w+/; var purgedStr = str.match(purgePrep); var purgedIsItPalin = isItPalin.match(purgePrep);
Matt
@TheeMattOliver
Jun 28 2016 03:20
@IAmJohnOconnell like this:
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:20

Now, i'm seeing that its arr.push(item). Because I'm 'pushing' whatever item, to the end of the array. Ok. so that would be

var x = arr.unshift(item) ?

Matt
@TheeMattOliver
Jun 28 2016 03:20
arr.push(item);

  var shifted = arr.shift();

  return shifted;
John Calhoun
@DougCal
Jun 28 2016 03:20
@boris-in-london I'm looking at previous lessons and the .match seems to consistently work when using other RegExp. I've been experimenting to get this algorithm to work.
Matt
@TheeMattOliver
Jun 28 2016 03:20
you were close, but we are actually going to use shift()
i know it's weird, but unshift() actually adds elements to the array
@IAmJohnOconnell does that make sense? push() to add, shift() to remove
Boris
@boris-in-london
Jun 28 2016 03:24
@DougCal this seems to work.
function palindrome(str) {
  // Good luck!
  var datArray = [];
  var blank = [];
  var isItPalin = "";

  datArray = str.split("");
  blank = datArray.reverse();
  isItPalin = blank.join("");

  return isItPalin === str
}



palindrome("eye33k");
John O'Connell
@IAmJohnOconnell
Jun 28 2016 03:25
@TheeMattOliver it does, thank you. At least the solution to the problme makes sense. It’ll take some practice to get myself thinking programatically.
CamperBot
@camperbot
Jun 28 2016 03:25
iamjohnoconnell sends brownie points to @theemattoliver :sparkles: :thumbsup: :sparkles:
:cookie: 291 | @theemattoliver |http://www.freecodecamp.com/theemattoliver
Matt
@TheeMattOliver
Jun 28 2016 03:27
definitely @IAmJohnOconnell. you'll get used to using both of those methods for sure.
Daniel Cartín
@Danielcv93
Jun 28 2016 03:29
hi, i want to know why the button doesn't work :worried:
http://codepen.io/Danielcv_93/pen/VjPwoQ?editors=1000
Nany
@NanyR
Jun 28 2016 03:30

help!, I cannot figure out how to filter with multiple arguments; I need to filter the first array for each following argument :s here is my code: function destroyer() {
// Remove all the values

var finalArr=[];

function filterArr(value){
return value!== j;
}
for(var i =1; i<arguments.length; i++){
var j= arguments[i];

finalArr= arguments[0].filter(filterArr);

}
return finalArr;

}

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

CamperBot
@camperbot
Jun 28 2016 03:30
no wiki entry for: i cannot figure out how to filter with multiple arguments i need to filter the first array for each following argument s here is my code function destroyer remove all the values var finalarr function filterarrvaluereturn value jforvar i 1 iargumentslength ivar j argumentsi finalarr arguments0filterfilterarr return finalarr destroyer1 2 3 1 2 3 2 3
Daniel Cartín
@Danielcv93
Jun 28 2016 03:31
someone?
John Calhoun
@DougCal
Jun 28 2016 03:31
@boris-in-london Kind of. It's not ignoring case, spaces, or special characters; this challenge wants me to ignore those things. What I put on line 11 was my attempt at doing that.
Boris
@boris-in-london
Jun 28 2016 03:34
@DougCal try this... str.toLowerCase().replace(/[. ,_\(\)\:-]/g, '').split("");.
there's probably a cleaner way to go about it, but... i should work.
kiaito
@kiaito
Jun 28 2016 03:36
var myStr = "Here is a backslash: \.\n\t\t Here is a new line with two tabs."; // Change this line please help what am i doing wrong?
Joseph
@revisualize
Jun 28 2016 03:36
@kiaito \t H remove the space.
Daniel Cartín
@Danielcv93
Jun 28 2016 03:37
heeelp :(
kiaito
@kiaito
Jun 28 2016 03:37
@revisualize thank you can't believe one little space can give me so much problems
CamperBot
@camperbot
Jun 28 2016 03:37
:star2: 1321 | @revisualize |http://www.freecodecamp.com/revisualize
kiaito sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
Boris
@boris-in-london
Jun 28 2016 03:39
@DougCal, so something like this?
function palindrome(str) {
  // Good luck!
  var datArray = [];
  var blank = [];
  var isItPalin = "";

  datArray = str.toLowerCase().replace(/[. ,_\(\)\:-]/g, '').split("");
  blank = datArray.reverse();
  isItPalin = blank.join("");

  return isItPalin === datArray.join("");
}



palindrome("eye");
true
Joseph
@revisualize
Jun 28 2016 03:41
@boris-in-london You're really close.
@boris-in-london Let me give you a good clue.

@boris-in-london The \W metacharacter is used to find a non-word character.

A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.

@boris-in-london Does the code that you posted work?
John Calhoun
@DougCal
Jun 28 2016 03:44
@revisualize @boris-in-london I tried to use the \w character thinking it would just ignore the other characters. Instead, it only carries the first character of the string ignoring all the other characters following it.
I presume \W will have a similar affect.
Robert
@Brayn7
Jun 28 2016 03:45
@Danielcv93 did your question get answered?
Joseph
@revisualize
Jun 28 2016 03:45
@DougCal Did you use \w or \W ?
Daniel Cartín
@Danielcv93
Jun 28 2016 03:47
Hi @Brayn7 not yet...
Robert
@Brayn7
Jun 28 2016 03:47
@Danielcv93 im working on it then :)
John Calhoun
@DougCal
Jun 28 2016 03:48
@revisualize @boris-in-london I used \w. And @boris-in-london , I appreciate the help, but the line of code you're suggesting for me is very hard for me to understand. In order for me to learn how do I get this, could we try to have it in a similar format from where I started?
@boris-in-london @revisualize I even went as far as using \w+ thinking that would help but it would still return null.
Joseph
@revisualize
Jun 28 2016 03:49
There is something else wrong with this code for palindrome challenge. It always returns true for some reason.
I think there are too many variables.
DC*
@desyncr
Jun 28 2016 03:51
@Danielcv93 The problem with your code is that you're calling the Action function, rather than passing it's reference
Joseph
@revisualize
Jun 28 2016 03:52
There is something wrong.
John Calhoun
@DougCal
Jun 28 2016 03:52
@revisualize I do have a lot of variables. The /\w/ keeps returning null.
Joseph
@revisualize
Jun 28 2016 03:52
function palindrome(str) {
  // Good luck!

  var datArray = str.toLowerCase().replace(/[. ,_\(\)\:-]/g, '');
  var isItPalin = datArray.split("").reverse().join("");

  return isItPalin === datArray;
}
DC*
@desyncr
Jun 28 2016 03:52
@Danielcv93 $("#change").click(Action()); should be: $("#change").click(Action);
Joseph
@revisualize
Jun 28 2016 03:53
I moved stuff around. I don't know why but, something was really really broken.
Daniel Cartín
@Danielcv93
Jun 28 2016 03:54
I try it, but it still doesnt work... @desyncr
DC*
@desyncr
Jun 28 2016 03:59
@Danielcv93 Well, I don't know what's supposed to happen when clicking the change button but your Switch statement is returning right away rather than returning at the end of the function
Boris
@boris-in-london
Jun 28 2016 04:01
@revisualize thank you. you are right /W is much cleaner.
CamperBot
@camperbot
Jun 28 2016 04:01
boris-in-london sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1322 | @revisualize |http://www.freecodecamp.com/revisualize
Daniel Cartín
@Danielcv93
Jun 28 2016 04:01
it should change the temp value in the html form Celsius to Farenheith and backwards.. so, the button run the function action, and then in shoul replace the value of temp in #info1.. but in don't.. :(
Boris
@boris-in-london
Jun 28 2016 04:01
@DougCal i think this is it.
function palindrome(str) {
  // Good luck!
  var datArray = [];
  var blank = [];
  var isItPalin = "";

  datArray = str.toLowerCase().replace(/\W/g, '').split("");
  isItPalin = datArray.reverse().join("");
  return isItPalin === str.toLowerCase().replace(/\W/, '');
}



palindrome("EYe");
Daniel Cartín
@Danielcv93
Jun 28 2016 04:01
it don't**
@desyncr
Daniel Ekwuazi
@Dcwind
Jun 28 2016 04:02

@sjames1958gm here is code. It worked, but please I would like to know if there is a way I could have written it better. Input from everyone is very much appreciated.

function golfScore(par, strokes) {
// Only change code below this line
var a = strokes - par;

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

} else if (strokes === par) {
return "Par";

} else if (a <= -2 ) {
return "Eagle";

} else if (a <= -1 ) {
return "Birdie";

} else if (a === 1 ) {
return "Bogey";

} else if (a === 2 ) {
return "Double Bogey";

} else if (a >= 3 ) {
return "Go Home!";

}

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

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

DC*
@desyncr
Jun 28 2016 04:03
@Danielcv93 Well, there you go, check out the switch statement. It never reach the $('#info') statement
Joseph
@revisualize
Jun 28 2016 04:04
@Dcwind By not replacing strokes - par with a
John Calhoun
@DougCal
Jun 28 2016 04:05
@boris-in-london @revisualize It didn't work but it does seem to be very close to what we're looking for.
Boris
@boris-in-london
Jun 28 2016 04:05
what error did you get?
Joseph
@revisualize
Jun 28 2016 04:05
@DougCal What didn't work?
John Calhoun
@DougCal
Jun 28 2016 04:05
It didn't ignore spaces and underscores.
Boris
@boris-in-london
Jun 28 2016 04:05
it filters for capital letters and non word characters
oh....
well thats an easy fix.
add those to the regex
Joseph
@revisualize
Jun 28 2016 04:05
Talk is cheap show me the code.
Also, if you're using \w when I said to use \W ... I'm going to be pissed.
Boris
@boris-in-london
Jun 28 2016 04:07
lol joseph, i used /W
Robert
@Brayn7
Jun 28 2016 04:07
having trouble making regex? i use this its really helpful http://regexr.com/
John Calhoun
@DougCal
Jun 28 2016 04:07
Lol
Boris
@boris-in-london
Jun 28 2016 04:07
@DougCal try this.
function palindrome(str) {
  // Good luck!
  var datArray = [];
  var blank = [];
  var isItPalin = "";

  datArray = str.toLowerCase().replace(/\W/g, '').split("");
  isItPalin = datArray.reverse().join("");
  return isItPalin === str.toLowerCase().replace(/\W/g, '');
}



palindrome("EYe");
Joseph
@revisualize
Jun 28 2016 04:08
.replace(/\W/g, '');
Read.
The \W metacharacter is used to find a non-word character.
A word character is a character from a-z, A-Z, 0-9, including the _ (underscore) character.
See the kicker in there?
_ is classified as a word character.
Boris
@boris-in-london
Jun 28 2016 04:09
ah....
Daniel Cartín
@Danielcv93
Jun 28 2016 04:09
ok, I change it, I put it in to the switch statement, so, in each case it should return and change('#info'), right? @desyncr
John Calhoun
@DougCal
Jun 28 2016 04:09
Makes sense
Daniel Cartín
@Danielcv93
Jun 28 2016 04:09
but it doesn't... :(
Joseph
@revisualize
Jun 28 2016 04:10
Seriously.. Too much code.
Robert
@Brayn7
Jun 28 2016 04:10
@Danielcv93 dude you should only hafta add one line of code
DC*
@desyncr
Jun 28 2016 04:10
@Danielcv93 It's a good practice to put a single return per-function as too keep your code more readable and easy to reason and follow
Daniel Ekwuazi
@Dcwind
Jun 28 2016 04:11
@revisualize Thanks
CamperBot
@camperbot
Jun 28 2016 04:11
dcwind sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1323 | @revisualize |http://www.freecodecamp.com/revisualize
Robert
@Brayn7
Jun 28 2016 04:11
@Danielcv93 if you are talking bout weather app ofcourse
Kikelomo
@queennectarine
Jun 28 2016 04:11
Hey yall, I'm trying to complete the Arguments Optional challenge, but whenever I try to test it using something like addTogether(2)(3); I get an error saying "TypeError: addTogether(...) is not a function;". Any help?
DC*
@desyncr
Jun 28 2016 04:12
@Danielcv93 I'd put the return at the end of the Action function and each case in the switch statement should change the value of the variable that it references later on
Robert
@Brayn7
Jun 28 2016 04:12
@Danielcv93 sent you a private message that has a hint and a link to the solution
Joseph
@revisualize
Jun 28 2016 04:12
function palindrome(str) {
  str = str.toLowerCase().replace(/\W|_/g, '');
  return str === str.split('').reverse().join('');
}
@DougCal @boris-in-london See how simple that shit looks when you consolidate the code?
John Calhoun
@DougCal
Jun 28 2016 04:14
@revisualize @boris-in-london Just pooped a little. The most concise code worked.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:14
hello
Joseph
@revisualize
Jun 28 2016 04:14
No confusion.
The code is easy to read and understand.
You know exactly what is going on.
John Calhoun
@DougCal
Jun 28 2016 04:15
Thanks a lot guys. Now I can sleep peacefully tonight. @revisualize @boris-in-london
CamperBot
@camperbot
Jun 28 2016 04:15
dougcal sends brownie points to @revisualize and @boris-in-london :sparkles: :thumbsup: :sparkles:
:star2: 1324 | @revisualize |http://www.freecodecamp.com/revisualize
:cookie: 335 | @boris-in-london |http://www.freecodecamp.com/boris-in-london
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:15
i'm attempting to do the Seek and Destroy challenge.
Joseph
@revisualize
Jun 28 2016 04:15
@alexwilkerson GOOD LUCK!
revisualize @revisualize :running: away.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:15
i need help.
Robert
@Brayn7
Jun 28 2016 04:15
@alexwilkerson whats your code look like
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:15
function destroyer(arr) {
// Remove all the values
var args = Array.from(arguments);
arr = arr.filter(function(val){
for (var i = 1; i < args.length; i++){
if (val === args[i]){
return false;
}
return true;
}
});
return arr;
}
revisualize @revisualize has a love hate relationship with "Seek and Destroy". (He loves to hate it.)
John Calhoun
@DougCal
Jun 28 2016 04:15
@revisualize Here I am trying to write 20 lines of friggin code.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:16
not sure how to paste it pretty
Joseph
@revisualize
Jun 28 2016 04:16
help format
CamperBot
@camperbot
Jun 28 2016 04:16

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Joseph
@revisualize
Jun 28 2016 04:17
```js [SHIFT+ENTER]
// your code here
```[CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
var code = true;
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:17
function destroyer(arr) {
  // Remove all the values
  var args = Array.from(arguments);
  arr = arr.filter(function(val){
    for (var i = 1; i < args.length; i++){
      if (val === args[i]){
        return false;
      }
      return true;
    }
  });
  return arr;
}
there ya go
i'm sure it's something simple...
Joseph
@revisualize
Jun 28 2016 04:19
@alexwilkerson args.length is 2
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:19
?
what do you mean?
Joseph
@revisualize
Jun 28 2016 04:19
if your for loop is only going to run once.
Nevermind.
I'm wrong.
I'm going away. I really don't like that challenge.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:21
this is my first time encountering arguments so that's why i'm sure i'm just missing something
hm
well thank you anyway @revisualize
CamperBot
@camperbot
Jun 28 2016 04:21
alexwilkerson sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1325 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 28 2016 04:23
@alexwilkerson That challenge took me two hours a day across four days. I then skipped it and had to come back around asking for a ton of help.
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:24
function palindrome(str)
{
var newStr=str.replace(/[^a-z]/gi,"");
var LowNewStr=newStr.toLowerCase();
var rev=LowNewStr.split("").reverse().join("");
if(rev===LowNewStr)
{
return true;
}
else
{
return false;
}
}
palindrome("eye");
is it right? since challenge is not being passed because of "1 eye for of 1 eye"
Joseph
@revisualize
Jun 28 2016 04:25
@sherdildeveloper Your order of operations.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:25
@sherdildeveloper your regex is incorrect
Joseph
@revisualize
Jun 28 2016 04:25
and your regex is incorrect.
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:25
regex?
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:25
regular expression
Joseph
@revisualize
Jun 28 2016 04:25
@sherdildeveloper if you want to use [^a-z] you need to .toLowerCase(); before the replace.
and you need to keep numbers.
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:26
Yeah but I think the "i" flag makes up for the lack of toLowerCase
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:26
it is working for all palindrome but 1 eye for of 1 eye
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:26
since it means "ignore case"
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:26
you also need to include numbers in your regex
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:26
regular expression is correct , try it for yourself
chaitanya ashtekar
@chaitanyaashtekar
Jun 28 2016 04:26
@alexwilkerson love your dp man :smile:
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:27
[^a-z0-9]
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:27
and why should "1 eye for of 1 eye." return false? eyeforofeye, it is palindrome
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:27
in any case you'd think of œœ[backslash]W
instead of the charset
allon-z
@allon-z
Jun 28 2016 04:27

so I thought i understood this but I keep getting "TypeError: Cannot read property 'length' of undefined." Here is my code:
function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i=0; i < multiplyAll.length; i++){
for(var j=0; j < multiplyAll[i].length; j++){
product*=multiplyAll[i][j];
}
}
// Only change code above this line
return product;
}

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

sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:28
guys "1 eye for of 1 eye." is it palindrome or not?
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:28
No because the extremes don't match, "1" !== "."
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:29
yes, but we have to ignore digits
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:29
in that case, if you also ignore the dot, yes
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:29
@sherdildeveloper it's alphanumeric
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:29
i @luishendrix92 we have to ignore everything but letters
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:29
@sherdildeveloper meaning letters and numbers
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:29
I thought the numbers were also included when I did mine
so yeah, aplhanum
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:29
@alexwilkerson oh my bad :)
Joseph
@revisualize
Jun 28 2016 04:30
Okay. I'm off to bed.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:30
@sherdildeveloper ;)
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:30
i thought only alphabets
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:30
your regex should be /[^a-z0-9]/gi
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:31
@alexwilkerson yes got it !
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:31
@sherdildeveloper k
Chris Cuevo
@ccuevo
Jun 28 2016 04:31
need help on the longest word in a string problem
sherdildeveloper
@sherdildeveloper
Jun 28 2016 04:31
@alexwilkerson thanks
CamperBot
@camperbot
Jun 28 2016 04:31
sherdildeveloper sends brownie points to @alexwilkerson :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @alexwilkerson |http://www.freecodecamp.com/alexwilkerson
Chris Cuevo
@ccuevo
Jun 28 2016 04:31
not sure what i'm doing wrong :(
function findLongestWord(str) {
  var splitStr = str.split(" ");
  for (i = 0; i < splitStr[i].length; i++) {
    var longest = 0;
    if (splitStr[i].length > longest) {
      longest = splitStr[i].length;
      return longest;
    } 
  }

}
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:31
@sherdildeveloper np
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:32
@ccuevo i < splitStr[i].length that's not something someone would do in this situation
you're saying that you should always compare the index against each word's length
when you do iteration of an array, make sure you check against the length of the array, not their sub-elements
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:33
@ccuevo you're also declaring the longest var inside the loop which means it's resetting every time
Chris Cuevo
@ccuevo
Jun 28 2016 04:35
thanks @luishendrix92 and @alexwilkerson
CamperBot
@camperbot
Jun 28 2016 04:35
ccuevo sends brownie points to @luishendrix92 and @alexwilkerson :sparkles: :thumbsup: :sparkles:
:cookie: 808 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
:cookie: 254 | @alexwilkerson |http://www.freecodecamp.com/alexwilkerson
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:35
@ccuevo np
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:36
@ccuevo Also the return statement should be after the loop, not inside it, it will exit as soon as the comparison returns true
Chris Cuevo
@ccuevo
Jun 28 2016 04:36
OH
got it!
thank you!
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:37
does anyone have a simple javascript playground to use?
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:37
@alexwilkerson Repl.it or JSBin
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:37
trying to solve these challenges without being able to access the console is a headache
thank you love @luishendrix92
CamperBot
@camperbot
Jun 28 2016 04:37
alexwilkerson sends brownie points to @luishendrix92 :sparkles: :thumbsup: :sparkles:
:cookie: 809 | @luishendrix92 |http://www.freecodecamp.com/luishendrix92
Luis Felipe López G.
@luishendrix92
Jun 28 2016 04:37
for algos I prefer Repl, for things that need the browser API I use jsbin
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:37
awesome
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:45
ahhhh! i figured it out. my return true; statement was inside the for loop!
:worried:
Syed Taha
@Spawn12
Jun 28 2016 04:51

var mystr=;

myStr should have encoded text with the proper escape sequences and spacing.
myStr should have two tab characters \t
myStr should have one newline character \n
myStr should have a correctly escaped backslash character \
myStr should not have any spaces in between consecutive escape sequences.

bitgrower
@bitgrower
Jun 28 2016 04:51
@alexwilkerson -- I like pythontutor.com/javascript.html -- because it gives you some visualizations ...
Alex Wilkerson
@alexwilkerson
Jun 28 2016 04:52
ah interesting. thanks @bitgrower
CamperBot
@camperbot
Jun 28 2016 04:52
alexwilkerson sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1117 | @bitgrower |http://www.freecodecamp.com/bitgrower
andreas2249
@andreas2249
Jun 28 2016 04:56
@bitgrower, thanks for that link. That's insanely cool !
CamperBot
@camperbot
Jun 28 2016 04:56
:star2: 1118 | @bitgrower |http://www.freecodecamp.com/bitgrower
andreas2249 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:03
okay I have a question about Where do I belong...
function getIndexToIns(arr, num) {
  // Find my place in this sorted array.
  arr.sort();
  for (var i = 0; i < arr.length; i++){
    if (num <= arr[i]){
      return i;
    }
  }
  return arr.length;
}
getIndexToIns([5, 3, 20, 3], 5);
this is failing with a return of 0
because sort() is sorting those numbers to [20, 3, 3, 5] for some reason
Markus Kiili
@Masd925
Jun 28 2016 05:05
@alexwilkerson The default sort is not numerical sort. It is unicode sort (as text).
You have to pass a callback function to sort that tells the sorting you need.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:05
i see. thank you @Masd925
CamperBot
@camperbot
Jun 28 2016 05:05
alexwilkerson sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1987 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 28 2016 05:06
@alexwilkerson The problem is easier if you first push num into arr. After sorting, the result is the first index of num in arr.
LonePoop
@LonePoop
Jun 28 2016 05:06
doing the Fatorialize a Number Challenge, and my code works fine. but I can't get the pass
Markus Kiili
@Masd925
Jun 28 2016 05:07
@LonePoop Don't use global variable.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:07
i see
Syed Taha
@Spawn12
Jun 28 2016 05:07
Screenshot (80).png
help me out:
CamperBot
@camperbot
Jun 28 2016 05:07
no wiki entry for: me out
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:09
@Spawn12 which challenge are you on?
Syed Taha
@Spawn12
Jun 28 2016 05:10
Escape Sequences in Strings @alexwilkerson
Nick Irvine
@irvin3
Jun 28 2016 05:11
post your code and not a screenshot
Do you know why you are putting a backslash behind the words? @Spawn12
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:12
you only need a total of 5 backslashes in your answer @Spawn12
the page tells you exactly what you need to use backslashes for in red
Syed Taha
@Spawn12
Jun 28 2016 05:13
@alexwilkerson plx write here
@irvin3 plxx write the code here
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:16
challenge yourself to figure out the reasoning behind the exercise @Spawn12
if we give you the answer you won't learn anything
Nick Irvine
@irvin3
Jun 28 2016 05:17
@Spawn12 that exercise is a matter of if you can read and follow instructions, no real outside knowledge. can't help you there
Syed Taha
@Spawn12
Jun 28 2016 05:19
@alexwilkerson its suck bro... good sayin
Markus Kiili
@Masd925
Jun 28 2016 05:20
@geecheeche Copy/paste your code here formatted
explain format
CamperBot
@camperbot
Jun 28 2016 05:20

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

geecheechee
@geecheeche
Jun 28 2016 05:21

@Masd925
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.car["glove box"]; // Change this line

Markus Kiili
@Masd925
Jun 28 2016 05:21
@geecheeche car has no key "glove box"
Indent the code so you see the object structure.
Syed Taha
@Spawn12
Jun 28 2016 05:22
@alexwilkerson i have done it "Here is a backslash: \.\n\t\tHere is a new line with two tabs.";
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:23
you're missing an escape character for the first backslash
geecheechee
@geecheeche
Jun 28 2016 05:23
so which one encompasses "glov box"? @Masd925 , "inside?
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:23
@Spawn12
Syed Taha
@Spawn12
Jun 28 2016 05:24
@alexwilkerson i have already pass it
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:24
oh okay. good job @Spawn12
Markus Kiili
@Masd925
Jun 28 2016 05:24
@geecheeche Try to see the two keys that car object has.
Syed Taha
@Spawn12
Jun 28 2016 05:25
@alexwilkerson thankxxxxxx for ur motivation..
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:25
@Spawn12 np
Markus Kiili
@Masd925
Jun 28 2016 05:25
@geecheeche Yes, "inside".
Syed Taha
@Spawn12
Jun 28 2016 05:26
@alexwilkerson are u girl or boy
geecheechee
@geecheeche
Jun 28 2016 05:26
@Masd925 I see them, inside and outside.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:26
i'm a burly old man @Spawn12
Eric Bezanson
@ericbezanson
Jun 28 2016 05:26
im working on chunkymonkey and im stuck, im wondering if there is a method like .slice() that will permanently change the array that is is being called on. like if you sliced a section off an array that array becomes whatever was remaining? am i even making sense lol
Markus Kiili
@Masd925
Jun 28 2016 05:27
@ericbezanson splice
Syed Taha
@Spawn12
Jun 28 2016 05:27
@alexwilkerson ur look like a transgender
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:27
thank you @Spawn12
CamperBot
@camperbot
Jun 28 2016 05:27
:cookie: 156 | @spawn12 |http://www.freecodecamp.com/spawn12
alexwilkerson sends brownie points to @spawn12 :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jun 28 2016 05:27
@ericbezanson Either slice or splice can be used here.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:28
@ericbezanson you can also create a new array.
var newArray = arr.splice().......
or even arr = arr.splice()
or slice
Syed Taha
@Spawn12
Jun 28 2016 05:29
@alexwilkerson dont mind it sir..
Markus Kiili
@Masd925
Jun 28 2016 05:30
@alexwilkerson arr.splice() is not very good way to make a new empty array.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:30
i wasn't being specific
Markus Kiili
@Masd925
Jun 28 2016 05:30
ok
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:31
major issue on one particular problem
need to know if it is a bug or if there is something wrong with my code
how do we post code here?
Markus Kiili
@Masd925
Jun 28 2016 05:31
explain format
CamperBot
@camperbot
Jun 28 2016 05:31

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:31
i just meant in general whilst using the splice function you can assign the array to a new array @Masd925
Eric Bezanson
@ericbezanson
Jun 28 2016 05:32

hmm maybe it will make more sense what im asking if I show you my code/logic

basically im finding the size of groups by dividing arr.length and size and creating an empty array to store the answer. then the for loops is supposed to create all the sub arrays but im pretty sure this is where the wheels come off . i think the condtition in the for loop makes sense as it will run though the right amount of times based on how many sub arrays need to be made im just not sure how to actually make them :P

function chunkArrayInGroups(arr, size) {
  var groups = arr.length / size;
  var chunkArr = [];

  for (i=groups; i < arr.length; i+groups) {
    chunkArr = arr.slice(0, i);
  }
  console.log(chunkArr);
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Markus Kiili
@Masd925
Jun 28 2016 05:32
@alexwilkerson Yes, yes.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:33
function updateRecords(id, prop, value) {
    if (value) {
        if (prop === 'tracks') {
            collection[id][prop].push(value);
        } else {
            collection[id][prop] = value;
        }
    } else {
        delete collection[id][prop];
    }
  return collection;
}
Eric Bezanson
@ericbezanson
Jun 28 2016 05:33
(ignore the console log, i just use that to check my work)
Markus Kiili
@Masd925
Jun 28 2016 05:34
@ericbezanson It is easier if you just loop arr elements and increment with i+=size, and then push slices into result array.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:35
function updateRecords(id, prop, value) {


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

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


  else {
    delete collection[id][prop];
  }


// first check what happens when the property is passed
 return collection;

}
Markus Kiili
@Masd925
Jun 28 2016 05:35
@AleCx4 You have to generate the tracks array if it is absent.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:35
That is the other code I wrote for that particular problem
@Masd925 thanks, I actually tried doing that a couple of times, my guess is that if collection[id][prop] == "" or undefined then collection[id][prop] = []
CamperBot
@camperbot
Jun 28 2016 05:36
alecx4 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1988 | @masd925 |http://www.freecodecamp.com/masd925
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:36
but I can't get it to work, what am I not seeing in here?
Markus Kiili
@Masd925
Jun 28 2016 05:36
@AleCx4 .hasOwnProperty() check is the proper way. Either push value or assign [value] depending on the result.
Norvin Burrus
@ndburrus
Jun 28 2016 05:37
yasin rayan
@yasinrayan
Jun 28 2016 05:38
please help me with chapter : Record Collection
iam not understanding what to do first.
record collection in javascript
Markus Kiili
@Masd925
Jun 28 2016 05:39
@yasinrayan Check value and prop and access collection as told.
yasin rayan
@yasinrayan
Jun 28 2016 05:39
how to check value and prop
Eric Bezanson
@ericbezanson
Jun 28 2016 05:39
@Masd925 yeah i guess creating a groups var is not needed. however if the first run through the loop I slice say (0,i) (which is 2 in this case) then the next time through it would be (0,4) since the orginal arr doesnt actually change
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:40
@Masd925 all of those things I have tried already :/
Markus Kiili
@Masd925
Jun 28 2016 05:40
@ericbezanson If you use slice, the array should not change.
@yasinrayan 2 or 3 if's
Eric Bezanson
@ericbezanson
Jun 28 2016 05:40
hmm maybe i could do like arr.splice(i-size, i)
yasin rayan
@yasinrayan
Jun 28 2016 05:40
@markus plz give me some extra hind
hint
CamperBot
@camperbot
Jun 28 2016 05:40
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:40
property: obj.hasOwnProperty("prop");
value: obj["propName"] obj[someVar]
Markus Kiili
@Masd925
Jun 28 2016 05:41
@ericbezanson You can use while+splice or for+slice. Otherwise it gets tricky.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:41
function rot13(str) { // LBH QVQ VG!
  var newStr = "";
  for (var i = 0; i < str.length; i++){
    var charCode = str.charCodeAt(i);
    if (charCode >= 65 && charCode <= 90){
      charCode += 13;
      if (charCode > 90){
        charCode = charCode - 26;
      }
    }
    newStr += String.fromCharCode(charCode);
  }
  return newStr;
}
is there a more elegant way of doing the Cipher challenge?
yasin rayan
@yasinrayan
Jun 28 2016 05:41
so i have to give " on prop?
Markus Kiili
@Masd925
Jun 28 2016 05:42
@alexwilkerson Better place for working code is https://gitter.im/FreeCodeCamp/CodeReview
yasin rayan
@yasinrayan
Jun 28 2016 05:42
obj.hasOwnProperty("prop");
Markus Kiili
@Masd925
Jun 28 2016 05:42
@yasinrayan No quotes on a variable.
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:42
thanks @Masd925
CamperBot
@camperbot
Jun 28 2016 05:42
alexwilkerson sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Eric Bezanson
@ericbezanson
Jun 28 2016 05:42
thank you @ndburrus I will check these out right now
CamperBot
@camperbot
Jun 28 2016 05:42
ericbezanson sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: alexwilkerson already gave masd925 points
:cookie: 746 | @ndburrus |http://www.freecodecamp.com/ndburrus
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:42
@yasinrayan That's to check if the object has a property (or key) called "prop"
if you have a variable, you can also use the variable
Norvin Burrus
@ndburrus
Jun 28 2016 05:43
@ericbezanson it looks like the value of chunkArr gets/is changed per loop. reference: slice() method returns the selected element(s) in an array, as a new array object. this does not support your getting the desired result of all array chunks into a single array... :sparkles:
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:43
to access values from properties that have spaces or weird symbols you can use bracket notation obj[something] or obj["some thing"]
it also accepts variables
yasin rayan
@yasinrayan
Jun 28 2016 05:43
let me try and comeback.
clintonjohn
@clintonjohn
Jun 28 2016 05:44

var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats",
};

// Only change code below this line

var hatValue = testObj.hat; // Change this line
var shirtValue = testObj.shirt;

i have a question. why is the testObj.hat; at the bottom not testObj."hat"
yasin rayan
@yasinrayan
Jun 28 2016 05:44
but to add can i use push(value)
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:44
var propertyName = "daily activities";
var student = {
  name: "Charles",
  "daily activities": ["play", "develop", "sleep"],
  age: 21
}

console.log( student.hasOwnProperty(propertyName) );
// -> true
console.log( student[propertyName] );
// -> Array(3) ["play", "develop", "sleep"]
Eric Bezanson
@ericbezanson
Jun 28 2016 05:45

@AleCx4 this is a psudo code answer to how to solve the record collection, these are the logical steps i took first before i converted it to code. hope this helps.

If value entered is not equal to nothing we check the prop value
If the prop value is not equal to "tracks" add the property to the id and assign the value to it
If the prop value equals "tracks" check if the id has a "tracks" property ( collection[id].tracls resolved true)
If the id does not have a "tracks" property create an empty array called "tracks" and push the value property to it
Otherwise remove the prop value from the id.

Norvin Burrus
@ndburrus
Jun 28 2016 05:45
@ericbezanson you're welcome.. :sparkles:
@clintonjohn Which exercise (name) is this?
yasin rayan
@yasinrayan
Jun 28 2016 05:47
ok thanks ericbezanson
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 05:49
@ericbezanson the hints and clues are great and I do appreciate them, but I can't see what I am missing, the logic you just described is the same that I have been following as it is exactly the same as the instructions
mwandama
@mwandama
Jun 28 2016 05:51

I'm having trouble with the adding and subtraction assignment. a = a - 6;
b = b - 15;
c = c - 1;

The instruct states to add a -= symbol a +=a-6 is wrong so can i get this to work

Iczac Icecold
@Iczac
Jun 28 2016 05:52
The idea of -= and += is to shorten the length of the code
mwandama
@mwandama
Jun 28 2016 05:52
a += a + 6 is wrong
Markus Kiili
@Masd925
Jun 28 2016 05:52
@mwandama a+=1 is the same as a=a+1.
Iczac Icecold
@Iczac
Jun 28 2016 05:52
so for example...if u are gonna add more number to the same variable like "result"
it should be result += 1;
result += 2;
instead of result = result + 1;
result = result + 2;
Eric Bezanson
@ericbezanson
Jun 28 2016 05:53
@AleCx4 i would look at it a little more closely, for example the first line checks if both prop and value are = to "" not just value... among other things... look at that psudo code like a checklist and make sure yours meets that criteria
Ravi Kumar
@codeintegrator
Jun 28 2016 05:53
Hi! everyone
Need help with "Profile lookup"
function lookUpProfile(firstName, prop){
for(var i=0; i<4;i++){
  if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)===true){
    return contacts[i].prop;
    break;
  }
  else if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)===false){
    return "No such property";
    break;
  } 
  else return "No such contact";
}
}
Markus Kiili
@Masd925
Jun 28 2016 05:54
@codeintegrator Don't hardcode the number of contacts.
@codeintegrator .prop won't work as intended because
The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
mwandama
@mwandama
Jun 28 2016 05:55
i'm not doing what you have pasted.
Markus Kiili
@Masd925
Jun 28 2016 05:55
@codeintegrator No need to break after returning.
mwandama
@mwandama
Jun 28 2016 05:55
tired of trying nothing is working
Markus Kiili
@Masd925
Jun 28 2016 05:56
@codeintegrator Return no such contact only after checking all the contacts.
mwandama
@mwandama
Jun 28 2016 05:56
what do u mean
Eric Bezanson
@ericbezanson
Jun 28 2016 05:56
@mwandama what is the name of the problem you are stuck on?
Iczac Icecold
@Iczac
Jun 28 2016 05:57
How do I create empty array?
Alex Wilkerson
@alexwilkerson
Jun 28 2016 05:57
var arr = []; @Iczac
Eric Bezanson
@ericbezanson
Jun 28 2016 05:57
@Iczac emptyArray = []
Iczac Icecold
@Iczac
Jun 28 2016 05:57
thanks
Norvin Burrus
@ndburrus
Jun 28 2016 05:57
@Iczac arr = [];
Duran Deari
@DuranDeari
Jun 28 2016 05:58
@mwandama I believe the solution is a -= 6
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:58
The empty array is awesome, you can also use it to rever to the Array object
clintonjohn
@clintonjohn
Jun 28 2016 05:58
@ndburrus Accessing Objects Properties with the Dot Operator
mwandama
@mwandama
Jun 28 2016 05:58
This the problema = a - 6;
b = b - 15;
c = c - 1;
the y want me to add -= symbol
Luis Felipe López G.
@luishendrix92
Jun 28 2016 05:58
This message was deleted
Duran Deari
@DuranDeari
Jun 28 2016 06:00
@mwandama Did it work?
mwandama
@mwandama
Jun 28 2016 06:00
can some help
kirbyedy
@kirbyedy
Jun 28 2016 06:00
@mwandama what is the question
Eric Bezanson
@ericbezanson
Jun 28 2016 06:00
@mwandama is it Compound Assignment With Augmented Subtraction?
Alex Wilkerson
@alexwilkerson
Jun 28 2016 06:00
@mwandama a -= 6;
@mwandama b -= 15;
@mwandama c -= 1;
clintonjohn
@clintonjohn
Jun 28 2016 06:01
if you are reading in property values that are a string, like "hat" :
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:01
@ericbezanson will do bud, thanks
CamperBot
@camperbot
Jun 28 2016 06:01
alecx4 sends brownie points to @ericbezanson :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @ericbezanson |http://www.freecodecamp.com/ericbezanson
clintonjohn
@clintonjohn
Jun 28 2016 06:01
why would the computer let me do testObj.hat
without the quotes?
Norvin Burrus
@ndburrus
Jun 28 2016 06:02
@clintonjohn this may be useful:
Eric Bezanson
@ericbezanson
Jun 28 2016 06:02
yeah @mwandama @alexwilkerson just gave you the answer lol.. -= is basically a short way to write a = a -6
Ravi Kumar
@codeintegrator
Jun 28 2016 06:04
Thanks a lot @Masd925
CamperBot
@camperbot
Jun 28 2016 06:04
codeintegrator sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1989 | @masd925 |http://www.freecodecamp.com/masd925
Duran Deari
@DuranDeari
Jun 28 2016 06:06
If anybody can assist me, I've hit a wall and I'm completely lost on https://www.freecodecamp.com/challenges/word-blanks
clintonjohn
@clintonjohn
Jun 28 2016 06:07
@ndburrus thanks. that syntax is what i assumed, but the tutorial wouldn't let me input the bracket way, which is what i had intuited
CamperBot
@camperbot
Jun 28 2016 06:07
clintonjohn sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 747 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 28 2016 06:07
@mwandama these may be helpful in understanding:
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 06:07
@DuranDeari show me what you've tried
Norvin Burrus
@ndburrus
Jun 28 2016 06:08
@clintonjohn ...most excellent! :balloon:
Duran Deari
@DuranDeari
Jun 28 2016 06:09
@Krish2704 The issue is I don't quite understand what it's asking me to do.
Eric Bezanson
@ericbezanson
Jun 28 2016 06:09
still stuck on this chunking problem I feel like im close but its returning an empty array and im not sure why
function chunkArrayInGroups(arr, size) {
  var chunkArr = [];

  for (i=size; i > arr.length; i+size) {
    chunkArr.push(arr.slice(i-size, i));
  }
  console.log(chunkArr);
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Markus Kiili
@Masd925
Jun 28 2016 06:10
@ericbezanson Do: for (i=0; i < arr.length; i+=size) {
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 06:10
@DuranDeari you'll be given four words as argguments and you'll have to join them
Norvin Burrus
@ndburrus
Jun 28 2016 06:11
@ericbezanson check/review the loop & size logic :fire: here: slice(i-size, i) & i > arr.length;
Markus Kiili
@Masd925
Jun 28 2016 06:11
@ericbezanson and figure out the slice arguments.
Mimi
@mimi26
Jun 28 2016 06:11

I have code for chunky monkey that works, but I'm not totally sure why.

function chunkArrayInGroups(arr, size) {
  // Break it up.
  var R = [];
  for (var i=0,len=arr.length; i<len; i+=size)
    R.push(arr.slice(i,i+size));
  return R;


}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

I don't understand why "i + size" slices the array in the right place. For example, if size is 2 (as in the example given, if i+0, wouldn't that slice the array at index position 2 which in this example is c?

Markus Kiili
@Masd925
Jun 28 2016 06:11
@mimi26 The second index is excluded.
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 06:12
@mimi26 in the slice arguments, first one is inclusive and 2nd one is exclusive
Mimi
@mimi26
Jun 28 2016 06:12
oh ok, thanks. I wasn't clear about that at all.
Iczac Icecold
@Iczac
Jun 28 2016 06:13
is this the correct way to push a value to existing property ? ----> [id][prop].push(value);
Markus Kiili
@Masd925
Jun 28 2016 06:13
@mimi26 Good solution. Even slightly more elegant can be done with while and splice.
This message was deleted
V Arun Kumar
@arunvkumr
Jun 28 2016 06:15
@Iczac if contacts is included in the statement then yes..that is correct, if not you have to add contacts before [i][prop].push(value);
Markus Kiili
@Masd925
Jun 28 2016 06:15
@Iczac collection[id][prop].push(value)
Norvin Burrus
@ndburrus
Jun 28 2016 06:15
@DuranDeari the exercise is asking for a sentence (madlib) build/constrution. There are four word types given (adj, noun, verb, etc.). It may be helpful to make the sentence you'd like to build (so you can see the goal/target). A few extra words (and punctuation) will be needed to ensure it is a complete sentence. :sparkles:
Iczac Icecold
@Iczac
Jun 28 2016 06:16
Thanks guys....I just figured why it doesn't work anymore....
yasin rayan
@yasinrayan
Jun 28 2016 06:16
@Masd925
clintonjohn
@clintonjohn
Jun 28 2016 06:16
@ndburrus i may not figure out tonight, or with that article, just why the program likes the dot operator over brackets for a string
Chris Cullen
@123xylem
Jun 28 2016 06:16
function checkCashRegister(price, cash, cid) {
  var change = cash - price;

var register = cid.reduce(function(acc, curr) {
    acc.total += curr[1];//First arg acc gets property total that is added to by currs 2nd element
    acc[curr[0]] = curr[1];//acc's first arg(total) gets curr0 value which is made equal to curr 1??????????????????????????????????????????
    return acc;  //end returning acc total
  }, {total: 0});//THIS is the starting value of acc.
}
checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 10], ["DIME", 0.50], ["QUARTER", 0], ["ONE", 1.00]]);
HEY Question!:::
Can some1 tell me if my logicc is right on the questionmark line?
Also if i take .total from acc at the start why does the value of cid get added differently??
Duran Deari
@DuranDeari
Jun 28 2016 06:16
@ndburrus result = myNoun + "dog" + myAdjective + "big" + myVerb + "ran" + myAdverb + "quickly"; is what I assume it wants me to do, but it's not working.
clintonjohn
@clintonjohn
Jun 28 2016 06:17
because most of the examples use brackets to enclose a string
V Arun Kumar
@arunvkumr
Jun 28 2016 06:17
@DuranDeari you need spaces between the words.
yasin rayan
@yasinrayan
Jun 28 2016 06:17
i dont know my code is correct.
function updateRecords(id, prop, value) {
if (value !== ""){
if (prop !== "tracks"){
collection[id] = [prop];
collection[id][prop].push(value);
}
else if (collection[id].tracks){
collection[id].tracks.push(value);
}
else { delete collection[prop];}
}
Norvin Burrus
@ndburrus
Jun 28 2016 06:18
@clintonjohn ...may it have something to do with the lesson name? Accessing Objects Properties with the Dot Operator :hamster:
clintonjohn
@clintonjohn
Jun 28 2016 06:18
@ndburrus haha!
Duran Deari
@DuranDeari
Jun 28 2016 06:18
@arunkumrv There are spaces in my code, it just doesn't show it well in the chat.
Norvin Burrus
@ndburrus
Jun 28 2016 06:19
@clintonjohn :+1:
V Arun Kumar
@arunvkumr
Jun 28 2016 06:19
@DuranDeari not spaces in the code. i mean in your string.. to markdown your code in chat read what camperbot has to say.
bot format
CamperBot
@camperbot
Jun 28 2016 06:19

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Duran Deari
@DuranDeari
Jun 28 2016 06:19
@arunkumrv Woops I'm stupid. Didn't realize you needed a space in the ""
Norvin Burrus
@ndburrus
Jun 28 2016 06:21
@DuranDeari right, look at what the code is being asked to do, and if the result forms a complete sentence... for example: for the code, you have: result = myNoun + "dog" this means the code would produce (so far) - dogdog. how useful is that?
Duran Deari
@DuranDeari
Jun 28 2016 06:21
result = "dog" + myNoun + "big" + myAdjective + "ran" + myVerb + "quickly" + myAdverb;

Was incorrect

result = " dog " + myNoun + " big " + myAdjective + " ran " + myVerb + " quickly " + myAdverb;

Was correct. Thanks for the help guys. :+1:

yasin rayan
@yasinrayan
Jun 28 2016 06:22
when i use collection.id it shows "type error. Collection.id is undefined"?
@ndburrus when i use collection.id it shows "type error. Collection.id is undefined"?
Norvin Burrus
@ndburrus
Jun 28 2016 06:23
@yasinrayan is id a variable? and, can you reference a variable using dot notation?
Duran Deari
@DuranDeari
Jun 28 2016 06:24
@ndburrus Now that I look at it, it did create a weird double-everything sentence, but it took it anyways.
yasin rayan
@yasinrayan
Jun 28 2016 06:24
its an arr
Norvin Burrus
@ndburrus
Jun 28 2016 06:25
@DuranDeari ok, well, you may (or not) want to adjust it so it makes sense.... :sparkles:
V Arun Kumar
@arunvkumr
Jun 28 2016 06:25
@yasinrayan dot is used for direct referencing the object property. in your case if have written collection.id it means that id should be a key present in the collection object which doesn't. so for that you have to use the bracket notation which is more like indirect referencing. collection[id] search of the key of value id in collection object.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:26
// 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) delete collection[id][prop];
  if (!!value && prop === 'tracks') collection[id][prop].push(value);
  if (!!value && prop === 'artist') collection[id][prop] = value;
  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
can't do it
Norvin Burrus
@ndburrus
Jun 28 2016 06:26
@yasinrayan this may be useful:
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:26
literally can't understand why every test passes except for 1
Duran Deari
@DuranDeari
Jun 28 2016 06:26

@ndburrus I modified it so

result = " My " + myNoun + " was " + myAdjective + " and " + myVerb + " very " + myAdverb;

Creates the sentence: My dog was big and ran very quickly. Which makes a lot more sense then what was before. xD

Iczac Icecold
@Iczac
Jun 28 2016 06:27
excuse me How do i add my code to this chat room to show others? like the rest of you guys did at top
Norvin Burrus
@ndburrus
Jun 28 2016 06:27
@DuranDeari you are on fire! :fire: ...nice job :+1: (it didn't check for punctuation - just curious?)
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:27
@Iczac type 3 back ticks, then press shift and enter
V Arun Kumar
@arunvkumr
Jun 28 2016 06:27
wiki format
CamperBot
@camperbot
Jun 28 2016 06:27

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

V Arun Kumar
@arunvkumr
Jun 28 2016 06:27
@Iczac :point_up_2:
Iczac Icecold
@Iczac
Jun 28 2016 06:28
@AleCx4 Thanks @arunkumrv Thanks
CamperBot
@camperbot
Jun 28 2016 06:28
iczac sends brownie points to @alecx4 and @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for arunkumrv
:cookie: 231 | @alecx4 |http://www.freecodecamp.com/alecx4
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:28
no problem bud
// Based on map assignment [230] from FreeCodeCamp
// 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 (prop === "tracks" && value !== "" ){
    collection[id][prop].push(value);
  } 

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


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


  else {
    delete collection[id][prop];
  }


// first check what happens when the property is passed
 return collection;

}
*/
function updateRecords(id, prop, value) {



  if(!collection[id].hasOwnProperty(prop)) {
    collection[id][prop] = [];
    collection[id][prop].push(value);
  }

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


  else {
    delete collection[id][prop];
  }


// first check what happens when the property is passed
 return collection;

}

console.log(updateRecords(5439, "artist", "ABBA"));
//console.log(updateRecords(5439,"tracks","Take a Chance on Me"));
/*
console.log(collection["5439"]["tracks"]);
if(!collection["5439"].hasOwnProperty["tracks"]) {
    collection["5439"]["tracks"] = [];
    collection["5439"]["tracks"].push("todos me la pelan");
}

console.log(collection["5439"]);
*/

if (collection["5439"].hasOwnProperty("album")){
  console.log("caca");
}
yasin rayan
@yasinrayan
Jun 28 2016 06:29
@arunkumrv @AleCx4 @ndburrus thanks
CamperBot
@camperbot
Jun 28 2016 06:29
yasinrayan sends brownie points to @arunkumrv and @alecx4 and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for arunkumrv
:cookie: 748 | @ndburrus |http://www.freecodecamp.com/ndburrus
:cookie: 232 | @alecx4 |http://www.freecodecamp.com/alecx4
Iczac Icecold
@Iczac
Jun 28 2016 06:29
function updateRecords(id, prop, value) {
    if (prop !== "tracks" && prop !== null) {
      collection[id][prop] = value;
    }
    else if (prop === "tracks" && id.hasOwnProperty(prop)) {
      collection[id][prop].push(value);
    }
    else if (value === "") {
      delete collection[id][prop];
    } 
    else {
      collection[id][prop] = [];
      collection[id][prop].push(value);
    }

  return collection;
It works for everything except this Objective
After updateRecords(2548, "artist", ""), artist should not be set
Norvin Burrus
@ndburrus
Jun 28 2016 06:29
@yasinrayan you're welcome! :dart:
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:30
@Iczac I have multiple implementations
most of them fail ont he second test
Hussein Zaki
@Hussein90
Jun 28 2016 06:30
please help me
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:30
I have no clue what is going on and this is driving me nuts
Hussein Zaki
@Hussein90
Jun 28 2016 06:30
i want to find api
for quote machine
Iczac Icecold
@Iczac
Jun 28 2016 06:31
@AleCx4 I don't know why this isn't working while it works for After updateRecords(2548, "tracks", ""), tracks should not be set
Hussein Zaki
@Hussein90
Jun 28 2016 06:31
comics quote or "doctor who"
Iczac Icecold
@Iczac
Jun 28 2016 06:31
it has the same Obj
Duran Deari
@DuranDeari
Jun 28 2016 06:31
@ndburrus Thank you for the tips. JS is slowly starting to make sense, but I have a long way to go. The code that occasionally gets posted here makes my brain explode lol. I enjoyed the jQuery tutorials more. The $(document).ready(function() clicked much faster for me.
CamperBot
@camperbot
Jun 28 2016 06:31
durandeari sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 749 | @ndburrus |http://www.freecodecamp.com/ndburrus
kirbyedy
@kirbyedy
Jun 28 2016 06:32
@Hussein90 search forismatic, or quotes on design, or famous quotes
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:32
@Iczac this one passes most of them
function updateRecords(id, prop, value) {


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




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


  else {
    delete collection[id][prop];
  }


// first check what happens when the property is passed
 return collection;

}
except for the second test
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 06:32
@kirbyedy In the wikipedia viewer the api data is an array?
Norvin Burrus
@ndburrus
Jun 28 2016 06:33
@DuranDeari you're welcome! :game_die: it may help to see what the code ouputs. are you using http://replit.com/ ?
Hussein Zaki
@Hussein90
Jun 28 2016 06:33
@kirbyedy i have already search by word quote api
chaitanya ashtekar
@chaitanyaashtekar
Jun 28 2016 06:33
@Krish2704 Object
Iczac Icecold
@Iczac
Jun 28 2016 06:33
@AleCx4 thanks I will find to make it work for everything
CamperBot
@camperbot
Jun 28 2016 06:33
iczac sends brownie points to @alecx4 :sparkles: :thumbsup: :sparkles:
:warning: iczac already gave alecx4 points
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:34
@Iczac so basically, if the key passed is tracks and the value is not blank then we push the value into the existing array, if not then we could do something like
Hussein Zaki
@Hussein90
Jun 28 2016 06:34
@kirbyedy i want to make quote machine
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:34
if(!collection["5439"].hasOwnProperty["tracks"]) {
    collection["5439"]["tracks"] = [];
    collection["5439"]["tracks"].push("todos me la pelan");
}
Duran Deari
@DuranDeari
Jun 28 2016 06:34
@ndburrus I actually haven't heard of that site till now. I've just been going on and hoping I get it correct through the "Run Tests" button for each section. Thanks a ton for that link, I'm gonna bookmark it.
CamperBot
@camperbot
Jun 28 2016 06:34
durandeari sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: durandeari already gave ndburrus points
V Arun Kumar
@arunvkumr
Jun 28 2016 06:35
@Hussein90
https://market.mashape.com/andruxnet/random-famous-quotes
i used this, you have register to get the key, then only you can use them..
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:35
@Iczac that is basically the gist of it, but that applies only to tracks, with very few modifications we can make it work for everything
Iczac Icecold
@Iczac
Jun 28 2016 06:35
@AleCx4 mine doesn't work for 2nd part
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:35
mine works for everything except the second part
Iczac Icecold
@Iczac
Jun 28 2016 06:35
@AleCx4 i see...i will try to fix it
Hussein Zaki
@Hussein90
Jun 28 2016 06:36
@arunkumrv is it free register
V Arun Kumar
@arunvkumr
Jun 28 2016 06:36
@Hussein90 yes it is.
Norvin Burrus
@ndburrus
Jun 28 2016 06:36
@DuranDeari enjoy! you can paste the code, and play around (edit, comment, format, etc.) with it... it helps by giving you more room to work with and freedom to explore - oh, and see the output quickly... :+1:
Hussein Zaki
@Hussein90
Jun 28 2016 06:36
@arunkumrv thanks
CamperBot
@camperbot
Jun 28 2016 06:36
hussein90 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 562 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:39
@Iczac I am guessing you are stuck at the same part?
Iczac Icecold
@Iczac
Jun 28 2016 06:40
@AleCx4 I have figured it out....i just can't make it work yet...haha :D
Rajdeep Roy
@RajdeepRoy
Jun 28 2016 06:40
can anyone help me wth this?
Iczac Icecold
@Iczac
Jun 28 2016 06:40
blank Value with Tracks works because it is Track...so it was executed above
Rajdeep Roy
@RajdeepRoy
Jun 28 2016 06:40

playerNumber should be a number
The variable player should be a string
The value of player should be "Montana"
You should use bracket notation to access testObj
You should be using the variable playerNumber in your bracket notation

1

2
// Setup
3
var testObj = {
4
12 : "Namath",
5
16 : "Montana",
6
19 : "Unitas"
7
};
8

9
// Only change code below this line;
10

11
var playerNumber=testObj[player]; // Change this Line
12
var player = "Montana"; // Change this Line
13

V Arun Kumar
@arunvkumr
Jun 28 2016 06:41
@RajdeepRoy format your code please..
wiki format
CamperBot
@camperbot
Jun 28 2016 06:41

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Iczac Icecold
@Iczac
Jun 28 2016 06:41
else if (prop === "tracks" && id.hasOwnProperty(prop)) {
      collection[id][prop].push(value);
    }
    else if (value === "") {
     delete collection[id][prop] ;
    }
it was executed before delete part
V Arun Kumar
@arunvkumr
Jun 28 2016 06:42
@Iczac id.hasOwnProperty doesn't look right.
Iczac Icecold
@Iczac
Jun 28 2016 06:43
@arunkumrv Hmm...it does work though...
the problem currently having is that when the blank value is passed...it replaced the current value with blank
V Arun Kumar
@arunvkumr
Jun 28 2016 06:43
@Iczac does it push anything to the tracks array?
Iczac Icecold
@Iczac
Jun 28 2016 06:44
yes it does
@arunkumrv everything works except that part that i mentioned above
V Arun Kumar
@arunvkumr
Jun 28 2016 06:45
@Iczac can you share your entire code..
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:46
@arunkumrv could you give your opinon on mine as well?

// 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 prop passed is equal to tracks and the vaue is equal to "" then we just push the value to the collection
  // this can be considered an update, what happens if it does not exist?

   if(!collection[id].hasOwnProperty(prop) && value !== ""){
    collection[id][prop] = value;
  }

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


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

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


  else {
    delete collection[id][prop];
  }


// first check what happens when the property is passed
 return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
it is for the same problem set
Mine passes every option except for the second set
Iczac Icecold
@Iczac
Jun 28 2016 06:47

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

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

  return collection;
}

// Alter values below to test your code
updateRecords(2548, "artist", "");
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:47
It is basically not giving the correct output for
updateRecords(5439, "tracks", "Take a Chance on Me");
Iczac Icecold
@Iczac
Jun 28 2016 06:48
@AleCx4 Is the 2nd one After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:48
@Iczac yup, it is not adding that one song
Iczac Icecold
@Iczac
Jun 28 2016 06:50
@AleCx4 5439 doesn't have Prop called tracks...so you have to create an empty array with collectionp[id][prop] = []; first
put that code above your collection[id][prop] = value; of first if statement
if(!collection[id].hasOwnProperty(prop) && value !== ""){
    collection[id][prop] = [];
     collection[id][prop] = value;
  }
it should work
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:52
@Iczac nope, still not working
that logci was already covered in my code though
Markus Kiili
@Masd925
Jun 28 2016 06:53
@Iczac .push() is missing from the code.
V Arun Kumar
@arunvkumr
Jun 28 2016 06:53
@Iczac id.hasOwnProperty(prop) this statement is not working. it is not pusing anything to the array. make it with collection[id] and you get another green tick.
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 06:53
@AleCx4 the way you chain your else if statements is not correct
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:54
@o0Ignition0o I had that feeling that my if statements were messed up
@o0Ignition0o logic-wise, am I missing anything?
V Arun Kumar
@arunvkumr
Jun 28 2016 06:55
@Iczac you didn't write any code for deleting the prop.
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 06:55
@AleCx4 the second else if statements Will almost never be executed since the first One will almost be satisfied
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:56
@o0Ignition0o boooooooooooom
@o0Ignition0o oh man, thank you so much
CamperBot
@camperbot
Jun 28 2016 06:56
alecx4 sends brownie points to @o0ignition0o :sparkles: :thumbsup: :sparkles:
:cookie: 299 | @o0ignition0o |http://www.freecodecamp.com/o0ignition0o
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 06:56
@AleCx4 you might want to check if the property exists before
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:56
@o0Ignition0o it was the logic! I did not see it
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 06:56
You re welcome ! :)
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:56
thanks man!!
@o0Ignition0o if you don't mind me asking, were you able to see it at first glance or did you apply a debugger to it?
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 06:58
@AleCx4 I m on my phone, on my way to work so no debugger here, the key is to tell yourself the computer is always right. Then you set values in your head and run the code line after line in your head. Don't read it globally and guess what it s supposed to do, read each line and see what it exactly does
@AleCx4 it takes a bit of practice but anyone can achieve it :+1:
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 06:59
@o0Ignition0o I will take your advice to heart my friend, thank you
CamperBot
@camperbot
Jun 28 2016 06:59
alecx4 sends brownie points to @o0ignition0o :sparkles: :thumbsup: :sparkles:
:warning: alecx4 already gave o0ignition0o points
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Jun 28 2016 07:00
@o0Ignition0o aaand also, I am finally able to sleep, this has kept me going for an hour and a half already! Hope to talk to you again some time!
Iczac Icecold
@Iczac
Jun 28 2016 07:00
@Masd925 @arunkumrv Sorry guys was on Bio....what am I missing again?
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:00
@AleCx4 cheers mate, and good night !
gagandeeps543
@gagandeeps543
Jun 28 2016 07:03
help me in this guys - challenge is" Escaping Literal Quotes in Strings"
CamperBot
@camperbot
Jun 28 2016 07:03
no wiki entry for: me in this guys - challenge is escaping literal quotes in strings
Iczac Icecold
@Iczac
Jun 28 2016 07:03
function updateRecords(id, prop, value) {
    if (prop !== "tracks" && prop !== null) {
      collection[id][prop] = value;
    }
    else if (prop === "tracks" && id.hasOwnProperty(prop)) {
      collection[id][prop].push(value);
    }
    else if (value === "") {
     delete collection[id][prop];
    }
    else {
      collection[id][prop] = [];
      collection[id][prop].push(value);
    }

  return collection;
}
this third one still doesn't work after adding the delete ---->After updateRecords(2548, "artist", ""), artist should not be set
gagandeeps543
@gagandeeps543
Jun 28 2016 07:04
the codes that i have written -----var myStr = "I am a \"double quoted\" string inside\"double quotes\".";
This message was deleted
and the answer coming- I am a "double quoted" string inside "double quotes".
sorrry the result is - I am a "double quoted" string inside "double quotes".
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:05
@Iczac in your test case the first if condition is satisfied, so the code deleting the prop won't be run. Consider an other way to chain your if statements
shweta rajput
@ShwetaRajput
Jun 28 2016 07:05
can someone help me with the challenge return erlypattern for fnctions?
gagandeeps543
@gagandeeps543
Jun 28 2016 07:05
their is no difference b/w answer and result
then also it is not accepting?
Iczac Icecold
@Iczac
Jun 28 2016 07:07
@o0Ignition0o Thank you....I changed the first condition and it works...Thanks a lot
CamperBot
@camperbot
Jun 28 2016 07:07
iczac sends brownie points to @o0ignition0o :sparkles: :thumbsup: :sparkles:
:cookie: 300 | @o0ignition0o |http://www.freecodecamp.com/o0ignition0o
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:07
@gagandeeps543 there's a space missing
Wan Jong Kim
@wanjongkim
Jun 28 2016 07:07
you forgot a space between inside and \" @gagandeeps543
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:07
After inside
@Iczac you're welcome
shweta rajput
@ShwetaRajput
Jun 28 2016 07:07
@gagandeeps543 var myStr= "I am a \"double quoted\" string inside \"double quotes\".";
can someone help me with the challenge return early pattern for functions
Keone Martin
@Athaman
Jun 28 2016 07:09
sure thing @ShwetaRajput
gagandeeps543
@gagandeeps543
Jun 28 2016 07:10
yes it worked ,but still didn't understood
where the space was lacking
Keone Martin
@Athaman
Jun 28 2016 07:10
you need to put an if statement in checking if either of the variables passed to the function (a and b) are less than 0, if they are you need to return undefined. (return; defaults to undefined)
shweta rajput
@ShwetaRajput
Jun 28 2016 07:11

@Athaman function abTest(a, b) {
// Only change code below this line
var a;
var b;

if(a||b<0)
{

// Only change code above this line
return ;
return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2));
}
}

// Change values below to test your code
abTest(2,2);

Keone Martin
@Athaman
Jun 28 2016 07:11
@gagandeeps543 after inside and before \"
shweta rajput
@ShwetaRajput
Jun 28 2016 07:11
this is my code
Keone Martin
@Athaman
Jun 28 2016 07:11
@ShwetaRajput you need to write out (a <0 || b < 0)
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:11
@gagandeeps543 right after the word inside
Keone Martin
@Athaman
Jun 28 2016 07:12
unfortunately the computer can't figure out how to test 2 variables against one condition, you have to put it in explicitly
also you should end you're if statement before the return Math.round... line
gagandeeps543
@gagandeeps543
Jun 28 2016 07:12
oh , ok thank you all ,now i got it .
shweta rajput
@ShwetaRajput
Jun 28 2016 07:14
@Athaman thanku once again for solving a challenge
CamperBot
@camperbot
Jun 28 2016 07:14
shwetarajput sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 475 | @athaman |http://www.freecodecamp.com/athaman
Keone Martin
@Athaman
Jun 28 2016 07:14
@ShwetaRajput also you don't need to define a or b with new var lines. they're passed into the function inside the arguments and you can just use them from there.
no problem :)
shweta rajput
@ShwetaRajput
Jun 28 2016 07:15
@Athaman have u finished these challenges earlier?
Keone Martin
@Athaman
Jun 28 2016 07:15
Yeah, i've finished til the end of the intermediate section
so it's easier to look at my code and see where they are different
shweta rajput
@ShwetaRajput
Jun 28 2016 07:17
@Athaman ohkay..good and thanku
CamperBot
@camperbot
Jun 28 2016 07:17
shwetarajput sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:warning: shwetarajput already gave athaman points
Yrureta
@Yrureta
Jun 28 2016 07:19
Hi, how can I get to the string "- Hello, what can I do for you?" from this object?
var texts = {
  "es": {
    "text_1": [
      {
        "character_1": "- ¡Qué calor!, voy a comprar un helado."
      }
    ],
    "text_2": [
      {
        "character_1": "- Hola buenos días."
      },
      {
        "character_2": "- Hola, ¿qué quieres?"
      }
    ],
  },
  "en": {
    "text_1": [
      {
        "character_1": "- It's very hot, I'm going to buy an icecream."
      }
    ],
    "text_2": [
      {
        "character_1": "Hello, good morning."
      },
      {
        "character_2": "- Hello, what can I do for you?"
      }
    ],

  }
};var texts = {
  "es": {
    "text_1": [
      {
        "character_1": "- ¡Qué calor!, voy a comprar un helado."
      }
    ],
    "text_2": [
      {
        "character_1": "- Hola buenos días."
      },
      {
        "character_2": "- Hola, ¿qué quieres?"
      }
    ],
  },
  "en": {
    "text_1": [
      {
        "character_1": "- It's very hot, I'm going to buy an icecream."
      }
    ],
    "text_2": [
      {
        "character_1": "Hello, good morning."
      },
      {
        "character_2": "- Hello, what can I do for you?"
      }
    ],

  }
};
Markus Kiili
@Masd925
Jun 28 2016 07:21
@Yrureta texts["en"]["text_2"][1]["character_2"];
["1"] would work too.
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:23
@Masd925 texts["en"]["text_2"]["character_2"]; ?
Markus Kiili
@Masd925
Jun 28 2016 07:24
@o0Ignition0o text_2 is an array.
kirbyedy
@kirbyedy
Jun 28 2016 07:25
can we do that with dot notation as well ?
Markus Kiili
@Masd925
Jun 28 2016 07:26
@kirbyedy Yes texts.en.text_2[1].character_2;
kirbyedy
@kirbyedy
Jun 28 2016 07:26
cool thanks @Masd925
CamperBot
@camperbot
Jun 28 2016 07:26
kirbyedy sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1992 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 28 2016 07:26
"1" is the only non-valid identifier.
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:27
@Masd925 true ! then ["en"]["text_2"][0]["character_2"];
hold on i ll get a debugger :p
mwandama
@mwandama
Jun 28 2016 07:28
i am asked to use backslashes
I am a "double quoted" string inside "double quotes". where can i put them
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:29
@Masd925
console.log(texts["en"]["text_2"][1]["character_2"]); does work for me in the debugger
Markus Kiili
@Masd925
Jun 28 2016 07:29
@o0Ignition0o Yes, it should.
Jeremy Lempereur
@o0Ignition0o
Jun 28 2016 07:30
@Masd925 thank you !
CamperBot
@camperbot
Jun 28 2016 07:30
o0ignition0o sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1993 | @masd925 |http://www.freecodecamp.com/masd925
Janodus
@janodus
Jun 28 2016 07:30
hey everyone. quick question:
var numbers = [4, 2, 5, 1, 3];
numbers.sort(function(a, b) {
  return a - b;
});
so this is a basic sort function... but... just curious why am I subtracting b from a?
can someone explain the logic behind this?
Markus Kiili
@Masd925
Jun 28 2016 07:32
@janodus Sort method passes elements into the callback and puts a before b, if the return value is negative.
So with the return value you define the ordering of two arbitrary elements a and b(to whatever you wan't).
Janodus
@janodus
Jun 28 2016 07:32
so in this case... what is a - b?
would it be 4-2 first?
Markus Kiili
@Masd925
Jun 28 2016 07:34
@janodus Sort might pass 4 and 2 into the callback under the hood and see that the return value is positive, so it knows to put 2 before 4. The precise sorting algorithm might differ from browser to browser. You just tell sort how to sort two arbitrary elements.
Janodus
@janodus
Jun 28 2016 07:36
@Masd925 understood. so the important thing is that the function actually checks all the numbers in some way, and the logic is that if the number is negative, then a is considered lower than b, which means it should go BEFORE b
Markus Kiili
@Masd925
Jun 28 2016 07:36
@janodus Yes.
Janodus
@janodus
Jun 28 2016 07:37
done and done. thank you.
Keone Martin
@Athaman
Jun 28 2016 07:37
@mwandama you need to make a string using the \ to 'escape' the special characters and have them print literally
in the double quoted string case you just need to put that sentence into a string then place a single \ in front of each internal "
jklaz
@jklaz
Jun 28 2016 07:41
hello i stuck in a js challenge long time, i think i do it right but the output from the run test is wrong,btw im in the card counting problem,and a global variable count seems not to be affected when i incr or decr it inside the asked function thanks in advance
Keone Martin
@Athaman
Jun 28 2016 07:41
copy paste your code @jklaz
jklaz
@jklaz
Jun 28 2016 07:41

ar count = 0;

function cc(card) {
var stri="";
// Only change code below this line
switch(card){
case 2,3,4,5,6:
count++;
break;
case 10,'J','Q','K','A':
count--;
break;
}
if(count>0){
stri=count + " Bet";
}else{
stri=count + " Hold";
}
return stri;

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

Keone Martin
@Athaman
Jun 28 2016 07:42
I don't think you can use commas to separate cases inside switches
jklaz
@jklaz
Jun 28 2016 07:42
ok i will try it without
Keone Martin
@Athaman
Jun 28 2016 07:42
write them out as
case 2:
case 3:
case 4:
AnshulDawar
@anshuldawar
Jun 28 2016 07:42

I get error in my code
var myStr="(I am a \"double quoted\" string inside \"double quotes.\")"; // Change this line

ERROR:Variable myStr should contain the string: I am a "double quoted" string inside "double quotes".

Keone Martin
@Athaman
Jun 28 2016 07:43
@anshuldawar get rid of the parens ()
those will be inside the final string and aren't meant to be included.
AnshulDawar
@anshuldawar
Jun 28 2016 07:45
thanks @Athaman
CamperBot
@camperbot
Jun 28 2016 07:45
anshuldawar sends brownie points to @athaman :sparkles: :thumbsup: :sparkles:
:cookie: 476 | @athaman |http://www.freecodecamp.com/athaman
jklaz
@jklaz
Jun 28 2016 07:45
it worked withoput the comas,strange because it was the default program with comas
Keone Martin
@Athaman
Jun 28 2016 07:45
No problem
@jklaz that's a little odd, as far as i know in JS (and all other languages i've worked in) switches need to have the full syntax
jklaz
@jklaz
Jun 28 2016 07:46
alright, thanks
x981
@x981
Jun 28 2016 07:51
http://codepen.io/FreeCodeCamp/full/bELRjV => I view source of this page and found AngularJs in it, but this challenge haven't knowledge about AngularJs. Why?
Fourbits
@Fourbits
Jun 28 2016 07:52
@x981 You don't need AngularJS to do it. jQuery is fine, although Angular is worth learning.
Janodus
@janodus
Jun 28 2016 07:52
hmm... could someone point me to the right direction?
Fourbits
@Fourbits
Jun 28 2016 07:52
Also, you're not really supposed to look at the code :P
Janodus
@janodus
Jun 28 2016 07:52

function getIndexToIns(arr, num) {
  var numbers = arr;
  var sorted = numbers.sort(function(a, b) {
  return a - b;

});

  var numIndex = 0; 

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

  if (sorted[i] > num) {
    numIndex = sorted.indexOf(i) - 1;
    return numIndex;
  }

  }
  return "Didn't get it.";
}

getIndexToIns([10, 20, 40, 30, 50], 35);
Markus Kiili
@Masd925
Jun 28 2016 07:52
@Athaman Most likely 10,'J','Q','K','A' just evaluates to 'A' because of the JS comma operator.
Fourbits
@Fourbits
Jun 28 2016 07:54
@x981 Apparently, FCC used to teach campers to use Angular, but now they have switched to just jQuery and React.
Yrureta
@Yrureta
Jun 28 2016 07:54
@Masd925 thank you very much
CamperBot
@camperbot
Jun 28 2016 07:54
yrureta sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1994 | @masd925 |http://www.freecodecamp.com/masd925
Yrureta
@Yrureta
Jun 28 2016 07:55
@o0Ignition0o thank you
CamperBot
@camperbot
Jun 28 2016 07:55
yrureta sends brownie points to @o0ignition0o :sparkles: :thumbsup: :sparkles:
:cookie: 301 | @o0ignition0o |http://www.freecodecamp.com/o0ignition0o
reviews please :)
x981
@x981
Jun 28 2016 07:57
@Fourbits Thank you.
CamperBot
@camperbot
Jun 28 2016 07:57
x981 sends brownie points to @fourbits :sparkles: :thumbsup: :sparkles:
:cookie: 334 | @fourbits |http://www.freecodecamp.com/fourbits
Daniel González Reina
@dgrcode
Jun 28 2016 08:02
@Krish2704 The logo make it look very good!
@Krish2704 Random works perfectly, but the search functionality is not the same as the real wikipedia. I mean, the results you show are ordered, but not by importance
@Krish2704 here you can find info about the search api https://www.mediawiki.org/wiki/API:Search
Janodus
@janodus
Jun 28 2016 08:04
could anyone help me?
Daniel González Reina
@dgrcode
Jun 28 2016 08:06
@Krish2704 I have used the following data with the query, and gives the results by importance:
action: 'query',
format: 'json',
list: 'search',
srsearch: keywords
@janodus how can we help you?
Janodus
@janodus
Jun 28 2016 08:07
@Danoso89 could you tell me what's wrong here:
function getIndexToIns(arr, num) {
  var numbers = arr;
  var sorted = numbers.sort(function(a, b) {
  return a - b;});

  for (var i = 0; i < sorted.length; i++) {
  var numIndex = 0;  
  if (sorted[i] > num) {
    numIndex = sorted.indexOf(i) - 1;
    return numIndex;
  }
 }
}
getIndexToIns([10, 20, 40, 30, 50], 35);
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 08:08
@Danoso89 i've used the API they've provided in the challenge link
Janodus
@janodus
Jun 28 2016 08:09
@Danoso89 I'm getting -2 as the returned numIndex value.
Daniel González Reina
@dgrcode
Jun 28 2016 08:11
@janodus This is because your i is already the index, you don't have to get the sorted.indexOf(i) - 1
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 08:13
@Danoso89 can you help me how to modify that
Janodus
@janodus
Jun 28 2016 08:13
ah... so the sorted.indexOf is actually screwing it up... it should just be i - 1
Hassan ben haj
@Hassanbhb
Jun 28 2016 08:13
I think I found another solution to "Find the Longest word in a string" challenge, it's not like new or anything but it's not in the wiki solutions.
Daniel González Reina
@dgrcode
Jun 28 2016 08:13
@janodus you are iterating with i = 0, then i = 1, etc. In this case, indexOf(i) will return -1 as i value is not at the string sorted. If you do -1 minus 1, you have your -2 result
Janodus
@janodus
Jun 28 2016 08:14
@Danoso89 understood. thanks! i'm working out the rest of the problem now :)
CamperBot
@camperbot
Jun 28 2016 08:14
janodus sends brownie points to @danoso89 :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @danoso89 |http://www.freecodecamp.com/danoso89
Daniel González Reina
@dgrcode
Jun 28 2016 08:15
@janodus in fact, it should be just i. Imagine that you find that the first number in the array is already bigger that your key number. In that case you would try to insert it at position -1, when it should be actually at position 0
@janodus thanks for the brownie! ;)
CamperBot
@camperbot
Jun 28 2016 08:15
danoso89 sends brownie points to @janodus :sparkles: :thumbsup: :sparkles:
:cookie: 268 | @janodus |http://www.freecodecamp.com/janodus
Daniel González Reina
@dgrcode
Jun 28 2016 08:16
I don't know how that works haha
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:16

// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};

// Only change code below this line

var gloveBoxContents = myStorage.car["inside"].; // Change this line

got stuck here !
its not working accordingly !
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:17
@Ahmed-Maruf what exactly aren't you understanding?
good morning everybody, btw. and the according phrase to everyone else in other time zones ;)
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:17
Use dot and bracket notation to access myStorage
what this mean ?
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:18
well you cann access JavaScript objects in two ways
as you should have learnt earlier, but here to refresh your knowledge:
you can access the property of an object by accessing it through dot notation
which goes like myObject.myProperty
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:19
var gloveBoxContents = myStorage.car["inside"].;
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:19
or you can access it by bracket notation which goes like myObject["myProperty"]
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:19
I wrote up to this !
Daniel González Reina
@dgrcode
Jun 28 2016 08:19
@Krish2704 Of course, the thing is that for the API call, you should redirect to: https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=keyword , where keyword should be replaced by the words you want to search
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:19
in this particular task, as far as I remember you have to access the glove box of your car
Daniel González Reina
@dgrcode
Jun 28 2016 08:20
@Krish2704 let me know if you have another problem
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:20
so try to navigate your way through the objects until you get the value that is stored inside the "glove box" property
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:20
I got confused !
Krishna Sai Gullapalli
@Krish2704
Jun 28 2016 08:20
@Danoso89 this is what I have now
Janodus
@janodus
Jun 28 2016 08:20
thanks again @Danoso89 . Got the final solution (though I can reduce it by 2 lines:
CamperBot
@camperbot
Jun 28 2016 08:20
janodus sends brownie points to @danoso89 :sparkles: :thumbsup: :sparkles:
:warning: janodus already gave danoso89 points
Janodus
@janodus
Jun 28 2016 08:20

function getIndexToIns(arr, num) {
  var numbers = arr;
  var sorted = numbers.sort(function(a, b) {
  return a - b;});

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

 } return arr.length;

}

getIndexToIns([10, 20, 30, 40, 50], 35);
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:21
@Ahmed-Maruf all you need to do now is the access the value of "glove box" and that's it :)
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:21
will you give more clue
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:21
@Ahmed-Maruf okay, let's look what we exactly have
myStorage starts with an { so it seems to be an object, right?
Ahmed Maruf
@Ahmed-Maruf
Jun 28 2016 08:22
ya
Oliver Jumpertz
@excelbrium
Jun 28 2016 08:22
great
we want to get to "glove box" so...let's see
inside myStorage there is car
Daniel González Reina
@dgrcode
Jun 28 2016 08:23
@Krish2704 "https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch= " + search + "&callback=?" should be your url api call then :D