These are chat archives for FreeCodeCamp/HelpJavaScript

24th
Nov 2016
Spokanetechs
@Spokanetechs
Nov 24 2016 00:19
Hello I am not fully understanding the challenge "Record Collection". Am I to amend the data that is missing then write a function to work with completed data, or am I supposed to be writing a function that fixes the incomplete data while organizing it?
Stephen James
@sjames1958gm
Nov 24 2016 00:24
@Spokanetechs Your function should take the input parameters to the function along with the collection and make the checks listed in the instructions.
Stephen James
@sjames1958gm
Nov 24 2016 00:29
All quiet on the javascript front
Spokanetechs
@Spokanetechs
Nov 24 2016 00:30
ok thank you, I was thinking that it wanted me to write a function that added the missing components. i.e. album names and years etc. which seemed like a lot of coding for this lol
Max Rohrer
@maxroar
Nov 24 2016 00:36
I'm doing the "Check for Palindromes" excercise and for some reason all inputs are returning true and none are returning false
function palindrome(str) {

  var newStr = str.replace(/[<|>|?|:|;|" "|'|,|.|!|@|#|$|%|^|&|*|(|)|_|+|-|=|\s+]/gi, "");
  newStr = newStr.toLowerCase();
  var forwardArr = newStr.split("");
  var backwardArr = forwardArr.reverse();
  var backwardStr = backwardArr.join();
  var forwardStr = forwardArr.join();
  if(forwardStr == backwardStr){
    return true;
  }else return false;

}
Michael Albonetti
@MikeAlbo
Nov 24 2016 00:40
Record Collection: I'm setting the property to undefined with the value is "", thus removing it from the object but it keeps failing the test. I've also tried setting it to null and "" but it continues o fail. The JSON output shows that it was removed. Any ideas?
Max Rohrer
@maxroar
Nov 24 2016 00:46
@MikeAlbo can you post the function? I spent all morning on that one so I might be able to help
Spokanetechs
@Spokanetechs
Nov 24 2016 00:46
I am working on it now and still trying to wrap my brain lol
Michael Albonetti
@MikeAlbo
Nov 24 2016 00:48

@maxroar sure, it's just a bunch of if/ else if statements. 'unction updateRecords(id, prop, value) {
var col = collection[id];

if(prop == "artist" && value){
  col[prop] = value;
} 

else if (prop == 'artist' && !value){
  if(col.hasOwnProperty(prop)){
    col[prop] = undefined;
  }
}
else if(prop != "tracks" && value){
  col.album = value;
} 


else if (!col.hasOwnProperty('tracks')){
  var x = [];
  x.push(value);
  col.tracks = x;
           }

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

else if(prop == "tracks" && !value){
col[prop] = [];
//alert("this one");
}
// else {col[prop] = value;}

return collection; '

oh, sorry I screwed up the formatting, lol
Max Rohrer
@maxroar
Nov 24 2016 00:49
haha its all good
you want to only use value in the if() to clarify whether or not a vaue was given
so for example if there is no value then the prop needs to be deleted, so you would have
``if(value == "")'' would indicate that there is no value and the prop should be deleted
messed up my formatting too. whoops
Michael Albonetti
@MikeAlbo
Nov 24 2016 00:54
it's cool. I'm using !value which actually works the same way so... ' if(!value)' is the same as ' value == "" '
Max Rohrer
@maxroar
Nov 24 2016 00:54
oh gotcha I missed the !
Michael Albonetti
@MikeAlbo
Nov 24 2016 00:55
no worries, it's easy to look over.
Max Rohrer
@maxroar
Nov 24 2016 00:55
think I found a potential issue
you havent added the [id] after collection
so when adding an artist tag and artist name, it would have to be
collection[id][prop] = value;

by only doing

collection[prop] = value;

it doesnt know which array to change

you want to make sure that you are making changes to the sub-array specified by the ID tag that was input
Stephen James
@sjames1958gm
Nov 24 2016 01:06
@maxroar Did you get a response? When you reverse your array it does it in place so both references are to the same array
@MikeAlbo Use delete not setting the value to "" to delete
@MikeAlbo Actually !value would also be true if the value was 0 - but since this challenge is only strings it probably doesn't apply
Max Rohrer
@maxroar
Nov 24 2016 01:09
@sjames1958gm that makes sense why everything is appearing true haha. So should I create seperate array equal to the forward array then reverse that?
Stephen James
@sjames1958gm
Nov 24 2016 01:10
@maxroar newStr is already the forward string - you only need to produced the reversed string.
Max Rohrer
@maxroar
Nov 24 2016 01:11
ahhhhhhh
ok got it
@sjames1958gm thanks I changed the if statements to compare newStr to backwardStr and it worked
CamperBot
@camperbot
Nov 24 2016 01:12
:star2: 4497 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
maxroar sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Stephen James
@sjames1958gm
Nov 24 2016 01:12
@maxroar :+1:
Michael Robin
@michaelrobin
Nov 24 2016 01:14
how would I print this out with escape sequences? cant seem to get the right answer FirstLine
\SecondLine\
ThirdLine
FirstLine
\SecondLine\
ThirdLine
figured it out :)
Ryan Marten
@RyanMarten
Nov 24 2016 01:23
@michaelrobin need any help still?
c0d0er
@c0d0er
Nov 24 2016 01:27
@0x0936 thanks
CamperBot
@camperbot
Nov 24 2016 01:27
c0d0er sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1970 | @0x0936 |http://www.freecodecamp.com/0x0936
Babawale Patrick Okare
@waleOkare
Nov 24 2016 01:37

//Counting card task...Please help??
var count = 0;
var answer;
function cc(card) {
// Only change code below this line
switch(card){

case 2:
case 3:
case 4:
case 5:
case 6:
count ++;
answer =" Bet";
break;

case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count--;
answer = " Hold";
break;
case 7:
case 8:
case 9:
answer = " Hold";
if (card == 7 && card == 8 && card == 9){
answer =" Bet";
// }
}
break;
}
return count + answer;
// 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');

Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"??? not working. don't know why
Stephen James
@sjames1958gm
Nov 24 2016 01:39
@waleOkare Your answer should be based on the count value after the switch statement. if count > 0 then Bet else Hold
Babawale Patrick Okare
@waleOkare
Nov 24 2016 01:42
@sjames1958gm Okay thanks, will debug it now...
CamperBot
@camperbot
Nov 24 2016 01:42
waleokare sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4498 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Nov 24 2016 01:42
@waleOkare :+1: Good Luck
Walid Ashri
@walidashri
Nov 24 2016 01:43
@sjames1958gm what do u think code pen?
Steven Bigham
@volv
Nov 24 2016 01:44
@walidashri Nice, looking good. I would like to be able to hit enter to submit my answer however. And either auto next question or enter for that too
Stephen James
@sjames1958gm
Nov 24 2016 01:44
Maybe one button that switches from start to answer - also allow enter to submit answer.
@walidashri The background could be more muted
Walid Ashri
@walidashri
Nov 24 2016 01:45
@volv @sjames1958gm Thanks this one for my grade 1 kid :)
CamperBot
@camperbot
Nov 24 2016 01:45
walidashri sends brownie points to @volv and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 4499 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 349 | @volv |http://www.freecodecamp.com/volv
Stephen James
@sjames1958gm
Nov 24 2016 01:46
@walidashri Then you want to make it even easier to use so not distracted by the mechanics
When you press start you should move the focus automatically to the input
Walid Ashri
@walidashri
Nov 24 2016 01:47
@sjames1958gm very nice point thanks
CamperBot
@camperbot
Nov 24 2016 01:47
walidashri sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: walidashri already gave sjames1958gm points
Stephen James
@sjames1958gm
Nov 24 2016 01:47
@walidashri :)
Ghadir Mira
@GhadirMira
Nov 24 2016 01:48
how do I turn a string into an array
Moisés Man
@moigithub
Nov 24 2016 01:49
http://mdn.io/split @GhadirMira
Ayo
@ayondot
Nov 24 2016 01:49
@GhadirMira check out the .split() method
Stephen James
@sjames1958gm
Nov 24 2016 01:49
@GhadirMira split("") will turn a string into an array of 1 character letters
Ghadir Mira
@GhadirMira
Nov 24 2016 01:49
ok Thanks
Johnny Vineyard
@javineya
Nov 24 2016 01:54
Any tips for keeping this stuff fresh in your mind?
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 01:56
Keep practicing
Johnny Vineyard
@javineya
Nov 24 2016 01:59
Okay, next question: Any worthwhile certifications out there to get after the FCC ones?
Sakitha
@Sakitha
Nov 24 2016 02:00

```function reverseString(str) {
var l=str.lenght;
var s="";
for(var i=0;i<l;i++){
s=s+str[l-i-1];
}
return s;
}

reverseString("hello");```why this is not working?

Johnny Vineyard
@javineya
Nov 24 2016 02:00
You spelled "length" wrong, for one thing.
@Sakitha
Sakitha
@Sakitha
Nov 24 2016 02:01
@javineya its working,thank you...
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 02:03
@javineya you could get the front end one, start some backend, and with thag in your portfolio, try to get a job, unless you want to get completely certified with what you know
Most people that ive met have done that
Babawale Patrick Okare
@waleOkare
Nov 24 2016 02:04
@sjames1958gm it worked!! :smile:
theremdim
@theremdim
Nov 24 2016 02:04
Super basic question: why does the following not require a "function" at the start of it? Thanks!
if (num > 15) {
return "Bigger than 15";
} else if (num < 5) {
return "Smaller than 5";
} else {
return "Between 5 and 15";
}
Johnny Vineyard
@javineya
Nov 24 2016 02:04
@jenkynolasco11 Done which? Got certified, or just got a job? For me, the job is the important part, haha.
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 02:07
Got the front end cert, then started doing some backend (making them full stack devs), so there, having skills to get a job
Johnny Vineyard
@javineya
Nov 24 2016 02:07
@jenkynolasco11 I see. Thanks!
CamperBot
@camperbot
Nov 24 2016 02:07
:cookie: 412 | @jenkynolasco11 |http://www.freecodecamp.com/jenkynolasco11
javineya sends brownie points to @jenkynolasco11 :sparkles: :thumbsup: :sparkles:
Margaret
@Margaret2
Nov 24 2016 02:19
MDN says
"The if statement executes a statement if a specified condition is true. If the condition is false, another statement can be executed."
so i guess the difference is an if statement immediately executes the process, whereas a function stores a process until it is called later or by another function
@theremdim
Ennio Nuñez
@enniorlando
Nov 24 2016 02:46
Hi people, I'm stock with Record Collection excercice, can anybody give me a cable please? This is my code:

function updateRecords(id, prop, value) {
for (id in collection) {

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

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

}

return collection;
}

Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 03:06
Hola mundo o/
Margaret
@Margaret2
Nov 24 2016 03:07
Ciao!
ericlok
@ericlok
Nov 24 2016 03:14

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

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

// Change this value to test
caseInSwitch(1);

could someone tell me why there's an error for the line with case 1

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

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

// Change this value to test
caseInSwitch(1);

Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 03:16
@ericlok is: switch (val){ case "something": / do something / break;
}
Johnny Vineyard
@javineya
Nov 24 2016 03:19
@enniorlando In your first 'if' statement, you need to add the 'value' to the 'artist' index, not the 'prop'. This will pass the test case " After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA" ".
ericlok
@ericlok
Nov 24 2016 03:19
thank you! i’m going to attempt this again
Gerard
@gmoneymaster24
Nov 24 2016 03:19
@enniorlando try removing 1 } above your return collection;
Johnny Vineyard
@javineya
Nov 24 2016 03:20
@enniorlando And for your next 'else-if' statement, you need to make sure that the 'tracks' index exists. For that, use '.hasOwnProperty'.
Gerard
@gmoneymaster24
Nov 24 2016 03:20

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

else if(value === ""){
delete [collection][id][prop];
}
} <<<< remove this
return collection;
}

Christopher Villaba
@chrisvillaba
Nov 24 2016 03:20
anyone can help me guys?
blob
Moisés Man
@moigithub
Nov 24 2016 03:21
@enniorlando u dnt need a loop at all
cuz the function already know which album gonna modify/delete.. cuz params passed
Gerard
@gmoneymaster24
Nov 24 2016 03:22
hmmm no that didn't pass in freecode although it worked on my console
Johnny Vineyard
@javineya
Nov 24 2016 03:22

function repeatStringNumTimes(str, num) {
if (num < 0) {
return '';
}
return str.repeat(num);
}
repeatStringNumTimes("abc", -4);

Is this one really that easy? I mean, it worked...

Moisés Man
@moigithub
Nov 24 2016 03:22
global variable should be declared outside the function @chrisvillaba
as isntruction says :)
Johnny Vineyard
@javineya
Nov 24 2016 03:23
But after the pain of all the other algorithms up to that point, it feels...wrong.
Christopher Villaba
@chrisvillaba
Nov 24 2016 03:23
ok i will try it @moigithub Thank You
CamperBot
@camperbot
Nov 24 2016 03:23
chrisvillaba sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 2233 | @moigithub |http://www.freecodecamp.com/moigithub
Johnny Vineyard
@javineya
Nov 24 2016 03:26
How do I paste my code in a picture here?
function repeatStringNumTimes(str, num) { if (num < 0) { return ''; } return str.repeat(num); } repeatStringNumTimes("abc", 4);
Hal
@icedAmericano
Nov 24 2016 03:28

I'm having a real hard time with the stand in line lesson in javascript... the instructions are Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.

function nextInLine(arr, item) {
// Your code here
item +
return item; // Change this line
}

// Test Setup
var testArr = [1,2,3,4,5];
that's the code...
what am I missing here?

ignore "item +"...
Johnny Vineyard
@javineya
Nov 24 2016 03:29
@ShirtoffShawty Look into .push(), .pop(), .shift(), and .unshift()
Michael Albonetti
@MikeAlbo
Nov 24 2016 03:30
@maxroar Hey! Sorry, had to leave Starbucks, they were closing. I think your right, I will try fixing this tomorrow. Thanks!
CamperBot
@camperbot
Nov 24 2016 03:30
mikealbo sends brownie points to @maxroar :sparkles: :thumbsup: :sparkles:
:cookie: 252 | @maxroar |http://www.freecodecamp.com/maxroar
Johnny Vineyard
@javineya
Nov 24 2016 03:31
@ShirtoffShawty You'll need .push() and .shift() for that particular problem. At least that's what I used.
Hal
@icedAmericano
Nov 24 2016 03:32
thank you. I will study those again
Johnny Vineyard
@javineya
Nov 24 2016 03:33
@ShirtoffShawty You want to .push() the 'item' onto the 'arr', and then return the .shift() to solve the question. I'm gonna take a page from the guy who helps me the most and not just give you the direct answer.
David Sroka
@donswavey
Nov 24 2016 03:33

hey i do not understand how get any solution.
right now i have

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


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

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

thank you.

wait a sec i mispelled...
Johnny Vineyard
@javineya
Nov 24 2016 03:34
@donswavey Check the spelling of 'fahrenheit' in every location.
Margaret
@Margaret2
Nov 24 2016 03:34
@donswavey formula should be celsius * 9/5 + 32
Johnny Vineyard
@javineya
Nov 24 2016 03:35
@donswavey Yeah, you also need to check your math. Right now you're just dividing 9 by 5 and adding 35. Don't forget to put your 'celsius' value in there, too.
David Sroka
@donswavey
Nov 24 2016 03:36
k 1 sec
thank you @javineya
thank you @Margaret2
CamperBot
@camperbot
Nov 24 2016 03:36
donswavey sends brownie points to @javineya and @margaret2 :sparkles: :thumbsup: :sparkles:
:cookie: 253 | @javineya |http://www.freecodecamp.com/javineya
:cookie: 502 | @margaret2 |http://www.freecodecamp.com/margaret2
Dominic Muttel
@domuttel
Nov 24 2016 03:37
Hi!
Gerard
@gmoneymaster24
Nov 24 2016 03:37

@enniorlando

//If prop isn't "tracks" and value isn't empty (""), update or set the value for that record album's property.

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

//If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.

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

//If prop is "tracks" and value isn't empty (""), push the value onto the end of the album's existing tracks array.

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

//If value is empty (""), delete the given prop property from the album.

if(value === ""){
delete collection[id][prop];
}
return collection;

}

Dominic Muttel
@domuttel
Nov 24 2016 03:37
I am looking for some help with Record Collection
Johnny Vineyard
@javineya
Nov 24 2016 03:40
@domuttel Paste your code so we can help.
stevebarakat
@stevebarakat
Nov 24 2016 03:43
Hello! I'm having a bit of trouble getting my "Profile Lookup" to work. Does anyone have a clue what I'm doing wrong? Here's my code:

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


function lookUpProfile(firstName, prop){
// Only change code below this line 
  var response = "";
  for(var i = 0; i < contacts.length ; i++){
    if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){
      response = contacts[i][prop];
    }

    if(contacts[i].firstName !== firstName){
      response = "No such contact";
    }

    if(contacts[i][prop] === undefined){
      response = "No such property";
    }
  }
  return response;
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Sherlock", "likes");
ericlok
@ericlok
Nov 24 2016 03:48
how do i send a block of code like that? ^
````
test

function switchOfStuff(val) {
  var answer = "";
  // Only change code below this line
  switch(val) {
    case 1:
      answer = "apple";
      break;
    case 2:
      answer = "bird";
      break;
    case 3:
      answer = "cat";
      break;

    default:
      return "stuff";

  }


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

// Change this value to test
switchOfStuff(1);
i’m having trouble understanding why this doesn’t pass all the tests
Dominic Muttel
@domuttel
Nov 24 2016 03:50
I figured it out! @gmoneymaster24 I took a little peak of yours and had till my comment TILL HERE our
function updateRecords(id, prop, value) {
  if(!collection[id].hasOwnProperty("artist") && collection){
    collection[id].artist = value;
  }
  if ( !collection[id].hasOwnProperty("tracks") && collection[id].tracks !== ""){
    collection[id].tracks = []; 
  } 
  collection[id].tracks.push(value);
  // TILL HERE
  if( value === "" ){ 
    delete collection[id][prop]; 
  }
  return collection; 
}
David Sroka
@donswavey
Nov 24 2016 03:51
what is wrong with my code?

var myStr "I am a\ "double quoted\" string inside "double quotes\".";// Change this line
Dominic Muttel
@domuttel
Nov 24 2016 03:51
function updateRecords(id, prop, value) {
  if( !collection[id].hasOwnProperty("artist") ){
    collection[id].artist = value;
  }
  if ( !collection[id].hasOwnProperty("tracks") && collection[id].tracks !== "" ){
    collection[id].tracks = []; 
  } 
  collection[id].tracks.push(value);
  // TILL HERE
  if( value === "" ){ 
    delete collection[id][prop]; 
  }
  return collection; 
}
Better
ericlok
@ericlok
Nov 24 2016 03:51
nvm i figured it out :)
David Sroka
@donswavey
Nov 24 2016 03:52
nvm i didnt put a = sign
but its still not working
Johnny Vineyard
@javineya
Nov 24 2016 03:53
@donswavey Check to make sure you put all your
\ in the right place.
David Sroka
@donswavey
Nov 24 2016 03:54
ohhh thanks
Dominic Muttel
@domuttel
Nov 24 2016 03:57
@gmoneymaster24 I really like your comments I need to do that more often to help e to solve problems
props
Johnny Vineyard
@javineya
Nov 24 2016 04:14
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket".
I passed all the tests in this algorithm except the two involving '.length' added to the 'str' parameter in the test case. What happens when you add '.length' into the test case?
Dang it, I didn't read it clearly enough until it was all on one line. I get it now.
sparklie3
@sparklie3
Nov 24 2016 04:15
i have a question a question on closures
i was wondering if someone could point me in the right direciton
i have this code
function makeFunc(name) {
  function displayName() {
    alert(name);
  }
  return displayName;
}

var myFunc = makeFunc("Mozilla");
myFunc();
I've looked around the web and I'm wondering how I might be able to define functions within my makeFunc
so I could do something like myFunc.subFunc() and myFunc.subFunc2()
iceveda06
@iceveda06
Nov 24 2016 04:22
hello there..workig on 'Roman Numberal Converter"...for some reason i dont get any output on my console commands to see where its messing up...any ideas

function convertToRoman(num) {
 var lookup = [
  [1000, 'M'],
  [900, 'CM'],
  [500, 'D'],
  [400, 'CD'],
  [100, 'C'],
  [90, 'XC'],
  [50, 'L'],
  [40, 'XL'],
  [10, 'X'],
  [9, 'IX'],
  [5, 'V'],
  [4, 'IV'],
  [1, 'I']
 ];

console.log(num + " before loop");
  console.log(lookup[0][0], " testing");
  var total =[];
  var result = num;
  var i = 0;


   while (result >= lookup[i][0]) {
     if (result > lookup[i][0])  {
      total.push(lookup[i][1]);
      result = result - lookup[i][0];
      console.log(result + " result");
      console.log(total + " total number");
     }i++;


     }
    } 




convertToRoman(2);
sparklie3
@sparklie3
Nov 24 2016 04:25
@iceveda06 you have an extra closure '}' i believe
gabi
@gikwu1
Nov 24 2016 04:25
hi everyone
Johnny Vineyard
@javineya
Nov 24 2016 04:25
@gikwu1 Hello!
iceveda06
@iceveda06
Nov 24 2016 04:25
where?
sparklie3
@sparklie3
Nov 24 2016 04:25
no, i was wrong
iceveda06
@iceveda06
Nov 24 2016 04:25
loooks fine to me
sparklie3
@sparklie3
Nov 24 2016 04:26
it works in my console
gabi
@gikwu1
Nov 24 2016 04:26
please what did i do wrong here?

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

  switch (val) {
    case 1:
      answer = "apple";
      break;
    case 2:
      answer = "bird";
      break;
    case 3:
      answer = "cat";
      break;

    default:
      return "stuff";
  }

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

// Change this value to test
switchOfStuff(1);
iceveda06
@iceveda06
Nov 24 2016 04:26
you get result?
sparklie3
@sparklie3
Nov 24 2016 04:26
yeah, i see it logging
iceveda06
@iceveda06
Nov 24 2016 04:26
weird
sparklie3
@sparklie3
Nov 24 2016 04:26
i just ran it in jsfiddle
you can try it if you want
but it's just your full code
iceveda06
@iceveda06
Nov 24 2016 04:27
i ran it, i dont see any thing logging
should i see it next to javascript window, under CSS?
gabi
@gikwu1
Nov 24 2016 04:28
@ericlok how did u resolve it?
sparklie3
@sparklie3
Nov 24 2016 04:28
no, to see console.log
you have to open your console
David Sroka
@donswavey
Nov 24 2016 04:28
u have to run it
iceveda06
@iceveda06
Nov 24 2016 04:29
i click on run in fiddle
nothin happens
sparklie3
@sparklie3
Nov 24 2016 04:29
you have to open your console in your browser
David Sroka
@donswavey
Nov 24 2016 04:29
o:
sparklie3
@sparklie3
Nov 24 2016 04:29
i.e., go into developer tools
look at the console
Johnny Vineyard
@javineya
Nov 24 2016 04:29
@gikwu1 You're supposed to use the alphabet, not numbers, to define your cases. So 'case "a"', for example.
sparklie3
@sparklie3
Nov 24 2016 04:29
brb
iceveda06
@iceveda06
Nov 24 2016 04:30
hmm i see it...says undefined
weird
Johnny Vineyard
@javineya
Nov 24 2016 04:31
@gikwu1 Make sure you pay close attention to the tasks. You can get some hints from the test cases they'll run to test your code.
iceveda06
@iceveda06
Nov 24 2016 04:31
i wuld've assume it would've output "I" worst case scenario
is my logic wrong?
Johnny Vineyard
@javineya
Nov 24 2016 04:32
@gikwu1 For example, it says switchOfStuff("a") should have a value of "apple" which lets you know that they will be testing for case "a".
David Sroka
@donswavey
Nov 24 2016 04:34

myStr should have encoded text with the proper escape sequences and no spacing.
i thought i did it right,
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine

this is the sequenced written out

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

var myStr = "FirstLine\n\SecondLine\rThirdLine";// Change this line
c0d0er
@c0d0er
Nov 24 2016 04:37
on the edge of the 4 color parts, there are some light green, yellow, red and blue lines, why cause this? any way to fix this? http://codepen.io/c0d0er/pen/ENWyyp?editors=1100
David Sroka
@donswavey
Nov 24 2016 04:37
nvm i fixed it
Johnny Vineyard
@javineya
Nov 24 2016 04:41
What's the difference between a 'new line' and a 'carriage return'?
sparklie3
@sparklie3
Nov 24 2016 04:43
@iceveda06 did you figure it out
sorry, had to finish laundry
David Sroka
@donswavey
Nov 24 2016 04:45
@javineya idk but its apart of the common escape sequences
Johnny Vineyard
@javineya
Nov 24 2016 04:45
@donswavey I just read that
I hit 'enter' on accident all the time now. Coding has changed my typing habits too much. :(
Anyway, I read that a 'carriage return', in old computing, actually brought the cursor back to the beginning of a line without removing the code. In other words, you could 'type' over something you had already typed before. It isn't really used anymore that way, though. What I read said you'll really only ever need \n for a newline.
lalith77
@lalith77
Nov 24 2016 04:48

``` var temp=[];
var j=0;
function steamrollArray(arr) {
// I'm a steamroller, baby

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

  if(Array.isArray(arr[i]))
    {
      steamrollArray(arr[i]);
    }
  else
    {
      temp[j]=arr[i];
      j++;
    }

}

//return Array.isArray(arr[2]);
//return arr2[0][0];

return temp;
}

steamrollArray([[["a"]], [["b"]]]); ```

anyone know why this code doesnt work for the steam roller challenge?
I get the correct output but i cant pass the test
@c0d0er try using the equals method to compare array objects
ashkrish07
@ashkrish07
Nov 24 2016 04:52

var count=0;

function cc(card) {
// Only change code below this line
if(card==2||card==3||card==4||card==5||card==6)
++count;
else if(card==10||card=='J'||card=='Q'||card=='K'||card=='A')
--count;
if(count>0)
return count;
else
return count;

}
// 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');

can anyone help
David Sroka
@donswavey
Nov 24 2016 04:55

Pikachu chooses you!
The Kool-Aid Man says, Oh Yeah!
Ken Haduch
@khaduch
Nov 24 2016 05:00
@ashkrish07 - I think that you are supposed to return the "Bet" and "Hold" status along with the count? I haven't looked at that challenge in a while, but they give a table of values and when you should return the additional information count + " Bet"; for example?
Elton
@emwale
Nov 24 2016 05:05
Hey all, I had a question about the Record Collection challenge
Are we supposed to assume that the collection has the album id we're given?
Ken Haduch
@khaduch
Nov 24 2016 05:07
@emwale - if you look at the test data, they only give the albums that are in the collection. So you can assume that (in this case). Of course, if you want to check for it, it should still pass the tests because you should never detect a missing album.
Elton
@emwale
Nov 24 2016 05:09
I forgot you can look at the test data when you run it
Joseph
@revisualize
Nov 24 2016 05:11
@donswavey You're not escaping backslashes correctly.
Johnny Vineyard
@javineya
Nov 24 2016 05:13

function chunkArrayInGroups(arr, size) { arr = arr.slice(); var newArray = []; for (var i = 0, len = arr.length; i < len; i+=size) { newArray.push(arr.slice(0, size)); arr = arr.slice(size); } return newArray; } chunkArrayInGroups(["a", "b", "c", "d"], 2);

I had to break down and look for help with this one. However, the only difference between this code and mine was:
for (var i = 0; i < arr.length; i++)
Why is i+=size used? And what's the difference between len = arr.length; i < len and simply using i < arr.length?

function chunkArrayInGroups(arr, size) { arr = arr.slice(); var newArray = []; for (var i = 0, len = arr.length; i < len; i+=size) { newArray.push(arr.slice(0, size)); arr = arr.slice(size); } return newArray; } chunkArrayInGroups(["a", "b", "c", "d"], 2);
One last time!
function chunkArrayInGroups(arr, size) { 
  arr = arr.slice(); 
  var newArray = []; 
  for (var i = 0, len = arr.length; i < len; i+=size) { 
    newArray.push(arr.slice(0, size)); 
    arr = arr.slice(size); 
  } 
return newArray; 
} 
chunkArrayInGroups(["a", "b", "c", "d"], 2);
Why isi+=size? And what's the difference between len = arr.length; i < len and simply using i < arr.length?
gabi
@gikwu1
Nov 24 2016 05:18
can anyone tell me what i did wrong here?

function chainToSwitch(val) {
  var answer = "";
  // Only change code below this line
  switch (val) {
    case 1:
  answer = "Marley";
      break;
    case 2:
      answer = "The Answer";
      break;
    case 3:
      answer = "There is no #1";
      break;
    case 4:
      answer = "Missed me by this much!";
      break;
    case 5:
      answer = "Ate Nine";

  }




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

// Change this value to test
chainToSwitch("bob");
Johnny Vineyard
@javineya
Nov 24 2016 05:19
@gikwu1 Same as last time. You're using numbers for your cases when you need to use the information in the explanation. For example, they're looking for case "bob", but you only have numbered cases.

@gikwu1 So it should look like this:

switch (val) {
  case "bob":
    answer = "Marley";

and so on.

gabi
@gikwu1
Nov 24 2016 05:21
@javineya i used it this way but something didnt work. will try it again
Johnny Vineyard
@javineya
Nov 24 2016 05:21
@gikwu1 What's the name of that challenge?
gabi
@gikwu1
Nov 24 2016 05:22
Replacing If Else Chains with Switch
got it
thanks @javineya
CamperBot
@camperbot
Nov 24 2016 05:22
gikwu1 sends brownie points to @javineya :sparkles: :thumbsup: :sparkles:
:cookie: 255 | @javineya |http://www.freecodecamp.com/javineya
Johnny Vineyard
@javineya
Nov 24 2016 05:23
@gikwu1 No problem.
@gikwu1 When it's a case with a name, like case "bob", you need the " ", but with numbers you don't. So case 42: is okay.
gabi
@gikwu1
Nov 24 2016 05:26
ok
JackVizl
@JackVizl
Nov 24 2016 05:35
function getData(){


  $.getJSON('https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json', function(data){

  })
  .done(function(){
    alert("done");
  })
  .fail(function(){
    alert("fail");
  });

}
Can someone please tell me why this wont work?
Karthik
@karthikm0
Nov 24 2016 05:36
Hey guys I need some help troubleshooting the code for Caesars Cipher?
I get a red dot when I test my result, and no real feedback
JackVizl
@JackVizl
Nov 24 2016 05:39
@karthikm0 post ur code
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 05:40
@JackVizl try to put alert inside the callback function...
Karthik
@karthikm0
Nov 24 2016 05:41

function rot13(str) { // LBH QVQ VG!
  newArr = [];
  for (var i = 0; i < str.length; i++) {
    if (str[i].match(/[A-Z]/i) === true) {
      newArr.pop(str.charCodeAt(i) - 13);
    }
    else {
      newArr.pop(str.charCodeAt(i));
    }
  }
  return String.fromCharCode(newArr);
}
JackVizl
@JackVizl
Nov 24 2016 05:41
@jenkynolasco11 didnt change anything
Johnny Vineyard
@javineya
Nov 24 2016 05:41
Why is len = arr.length; i < len not the same as i < arr.length? I'm so confused.
Karthik
@karthikm0
Nov 24 2016 05:42
@javineya It would be the same as long as you don't modify the array during the operation
JackVizl
@JackVizl
Nov 24 2016 05:42
@karthikm0 ur only going backward
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 05:42
You have a done + a callback
First, check in your console if you're not getting any errors
JackVizl
@JackVizl
Nov 24 2016 05:43
@karthikm0 need a case for +13 and a case for -13
@jenkynolasco11 ok
Karthik
@karthikm0
Nov 24 2016 05:43
@JackVizl question only asks for decoding?
JackVizl
@JackVizl
Nov 24 2016 05:43
@karthikm0 yeah but if you take 13 of
Johnny Vineyard
@javineya
Nov 24 2016 05:44
@karthikm0 Thank you! I've been staring at this line for 20 minutes trying to figure out why it was different. Makes perfect sense now.
CamperBot
@camperbot
Nov 24 2016 05:44
javineya sends brownie points to @karthikm0 :sparkles: :thumbsup: :sparkles:
:cookie: 2 | @karthikm0 |http://www.freecodecamp.com/karthikm0
JackVizl
@JackVizl
Nov 24 2016 05:44
what about when you need to turn back an A
its 65
so the code becomes 52
alphabet is 26 long
going back 13 and forward 13 is same
Karthik
@karthikm0
Nov 24 2016 05:44
riiight
that makes sense
JackVizl
@JackVizl
Nov 24 2016 05:44
@karthikm0 ayy took me a while too
Karthik
@karthikm0
Nov 24 2016 05:45
@JackVizl Thanks! But I still have a red dot instead of error messages which is a bit strange. I'll see!
CamperBot
@camperbot
Nov 24 2016 05:45
karthikm0 sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:cookie: 332 | @jackvizl |http://www.freecodecamp.com/jackvizl
JackVizl
@JackVizl
Nov 24 2016 05:45
@karthikm0 just gotta tweak it so it knows when to + or - 13
Phillip Kelley-Dotson
@pkdotson
Nov 24 2016 05:47

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function forbid(){
var a = [false, null, 0, "", undefined, NaN];
a.includes();
});
}

bouncer([7, "ate", "", false, 9]);

kinda lost here on how to return array wihtout the falsy's.
Happy holidays to everyone!
Isaac Weber
@ikey2244
Nov 24 2016 05:49

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

return item; // Change this line
}

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

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

having trouble with this do i arr.push()?
JackVizl
@JackVizl
Nov 24 2016 05:49
@jenkynolasco11

Regex

Hide network messages
All
Errors
Warnings
Info
Logs
Debug
Handled

index.html:1 XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

Isaac Weber
@ikey2244
Nov 24 2016 05:50

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

return item; // Change this line
}

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

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

JackVizl
@JackVizl
Nov 24 2016 05:50
@ikey use a newline at top bruh
Isaac Weber
@ikey2244
Nov 24 2016 05:51
@JackVizl im used to slack what is the keyword to make it code snippet?
JackVizl
@JackVizl
Nov 24 2016 05:51
/```
Chance Vodnoy
@esgameco
Nov 24 2016 05:51

use ```
Jenky W. Nolasco
@jenkynolasco11
Nov 24 2016 05:51
@JackVizl first, either use jsonp for the request or http://crossorigin.me for it, and second, having a callback and done is ambiguous, you either use one, not both lol
Isaac Weber
@ikey2244
Nov 24 2016 05:51

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

return item; // Change this line
}

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

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

JackVizl
@JackVizl
Nov 24 2016 05:51
but a newline after the ```
Isaac Weber
@ikey2244
Nov 24 2016 05:52
/```
Chance Vodnoy
@esgameco
Nov 24 2016 05:52
no /
just ``` then shift+enter
Isaac Weber
@ikey2244
Nov 24 2016 05:53
whats the command for new line? lol mb coming back to gitter is hard
Chance Vodnoy
@esgameco
Nov 24 2016 05:53
shift+enter
Isaac Weber
@ikey2244
Nov 24 2016 05:53
function nextInLine(arr, item) {
  // Your code here

  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
thanks
Chance Vodnoy
@esgameco
Nov 24 2016 05:53
no problem
Darth Skywalker
@adityaparab
Nov 24 2016 05:54
@ikey2244 : First push item in arr and then return the value returned by arr.shift
Karthik
@karthikm0
Nov 24 2016 05:54
Hey @JackVizl I now check for +13/-13 but I still have a red dot on the console when I run the test.
function rot13(str) { // LBH QVQ VG!
  newArr = [];
  for (var i = 0; i < str.length; i++) {
    if (str[i].match(/[A-Z]/i) === true) {
      value = str.charCodeAt(i);
      if (value < 78) {
        value = value + 13;
      }
      else {
        value = value - 13;
      }
      newArr.pop(value);
    }
    else {
      newArr.pop(str.charCodeAt(i));
    }
  }
  return String.fromCharCode(newArr);
}
Isaac Weber
@ikey2244
Nov 24 2016 05:56
@adityaparab thanks!
CamperBot
@camperbot
Nov 24 2016 05:56
ikey2244 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:cookie: 726 | @adityaparab |http://www.freecodecamp.com/adityaparab
JackVizl
@JackVizl
Nov 24 2016 05:57
@esgameco

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

  result = 'the ' + myAdjective + " " + myNoun+" " + myVerb + ' ' + myAdverb + '.';

  // Your code above this line
  return result;
}

// Change the words here to test your function
wordBlanks("cat", "small", "walked", "slowly");
Chance Vodnoy
@esgameco
Nov 24 2016 05:58
@JackVizl Thank you
CamperBot
@camperbot
Nov 24 2016 05:58
esgameco sends brownie points to @jackvizl :sparkles: :thumbsup: :sparkles:
:cookie: 333 | @jackvizl |http://www.freecodecamp.com/jackvizl
JackVizl
@JackVizl
Nov 24 2016 05:58
@karthikm0 start with just one character
@karthikm0 then build the loop for the whole thing, trust me makes it 100X simpler
Isaac Weber
@ikey2244
Nov 24 2016 05:58
@esgameco you had a coma in there where you dont need one
Ogundele Olumide
@Lumexralph
Nov 24 2016 05:59
@karthikm0 hey, pasting your code will make it easier for people to help
hongwutian
@hongwutian
Nov 24 2016 06:00
blob
anyone know why prop is not defined?
JackVizl
@JackVizl
Nov 24 2016 06:01
hey can someone help me udnerstand what to do about this error please?
XMLHttpRequest cannot load https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.
for this code
function getData(){


  $.getJSON('https://en.wikipedia.org/w/api.php?action=query&titles=Main%20Page&prop=revisions&rvprop=content&format=json', function(data){
    alert("dd");
  })

  .fail(function(){
    alert("fail");
  });

}
@hongwutian bro just copy paste your code
use /```
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:02
@karthikm0 click on the M icon right side of your typing space, you'll see how to format your code
@hongwutian do you know how to paste your code?
hongwutian
@hongwutian
Nov 24 2016 06:02

/'''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);
}

return collection;
}

CamperBot
@camperbot
Nov 24 2016 06:02
:bulb: to format code use backticks! ``` more info
JackVizl
@JackVizl
Nov 24 2016 06:03
@hongwutian take out the /
and use /``` then enter, then your code
hongwutian
@hongwutian
Nov 24 2016 06:03

''' 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);
}

return collection;
}

CamperBot
@camperbot
Nov 24 2016 06:03
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:03
@hongwutian you need to access your prop from the collection
JackVizl
@JackVizl
Nov 24 2016 06:03
at the end too @hongwutian

/```
code

/```

hongwutian
@hongwutian
Nov 24 2016 06:04

/''' 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);
}

return collection;
}

CamperBot
@camperbot
Nov 24 2016 06:04
:bulb: to format code use backticks! ``` more info
hongwutian
@hongwutian
Nov 24 2016 06:04

/''' 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);
}

return collection;
}/'''

CamperBot
@camperbot
Nov 24 2016 06:04
:bulb: to format code use backticks! ``` more info
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:04
@hongwutian remember collection is an object with nested objects
hongwutian
@hongwutian
Nov 24 2016 06:05
I used collection[id][prop].push(value)
then they want me to define prop
define push
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:05
@hongwutian you have to find a way of accessing prop from your condition, the branch, if statement
Ezeboy
@Ezeboy
Nov 24 2016 06:05
c should not contain undefined and should have a value of "I am a String!"
how can i do this?

// Initialize these three variables
var a = 5;
var b = 10;
var c = ;

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

Ogundele Olumide
@Lumexralph
Nov 24 2016 06:06
@hongwutian that's why the engine is shouting prop not defined
Greg Duncan
@GregatGit
Nov 24 2016 06:07
@hongwutian you also need to make sure that collection[id][prop] is an array before you can push to it
Chance Vodnoy
@esgameco
Nov 24 2016 06:07
@Ezeboy Set c to "I am a "
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:07
@Ezeboy c should contain a string I am a before concating it
Göktan Ehrlich
@goktanehrlich
Nov 24 2016 06:07
Guys I am stuck at Escape Sequences in Strings, I have no idea what to do
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:07
with String
Chance Vodnoy
@esgameco
Nov 24 2016 06:08
@goktanehrlich You backspace the " or ' so that they don't stop the " or ' already being used, like "Bob was saying \"Hey Boy\""
hongwutian
@hongwutian
Nov 24 2016 06:08
i thought access property with variable we have to use bracket
Chance Vodnoy
@esgameco
Nov 24 2016 06:08
Escape*
Otherwise, "Bob was saying "Hey Boy"" would stop at the ["Bob was saying "]Hey Boy""
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:10
@hongwutian yes, you have to use []
hongwutian
@hongwutian
Nov 24 2016 06:10
@esgameco "Bob was saying \"Hey Boy"\"
that way you can escape
Greg Duncan
@GregatGit
Nov 24 2016 06:10
@hongwutian push() is a function that it part of an array obj - so when you create an arr like var myArr = [] you can now push to it
Chance Vodnoy
@esgameco
Nov 24 2016 06:11
@hongwutian That would show Bob was saying "Hey Boy
and the \" wouldn't be part of the string
hongwutian
@hongwutian
Nov 24 2016 06:12
Sorry typed wrong
Chance Vodnoy
@esgameco
Nov 24 2016 06:12
@hongwutian It's alright
Matt
@airborneprayer
Nov 24 2016 06:12

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

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

// Change the inputs below to test your code
celcius = -30;

Please help me!
hongwutian
@hongwutian
Nov 24 2016 06:12
"Bob was saying \"Hey Boy\""
Chance Vodnoy
@esgameco
Nov 24 2016 06:12
@hongwutian Yeah, that's right
Greg Duncan
@GregatGit
Nov 24 2016 06:13
@airborneprayer you wouldn't write var celcius;
Matt
@airborneprayer
Nov 24 2016 06:13
Thank you.
Göktan Ehrlich
@goktanehrlich
Nov 24 2016 06:14
@esgameco Thanks
CamperBot
@camperbot
Nov 24 2016 06:14
goktanehrlich sends brownie points to @esgameco :sparkles: :thumbsup: :sparkles:
:cookie: 160 | @esgameco |http://www.freecodecamp.com/esgameco
Chance Vodnoy
@esgameco
Nov 24 2016 06:14
@goktanehrlich You're welcome
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:14
@airborneprayer you don't need to declare var celsius in the function again
Chance Vodnoy
@esgameco
Nov 24 2016 06:14
@airborneprayer Use convertToF(-30);
instead of celcius = -30;
Ezeboy
@Ezeboy
Nov 24 2016 06:15
studlyCapVar should use camelCase in both declaration and assignment sections.
properCamelCase should use camelCase in both declaration and assignment sections.
titleCaseOver should use camelCase in both declaration and assignment sections. .
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:15
@airborneprayer remember that celsius as a parameter to your function is already a variable holding values of the arguments when the function was called
Ezeboy
@Ezeboy
Nov 24 2016 06:16
4.studlyCapVar should use camelCase in both declaration and assignment sections.
5.properCamelCase should use camelCase in both declaration and assignment sections.
6.titleCaseOver should use camelCase in both declaration and assignment sections
how can i solve this
?
James
@jbonds08
Nov 24 2016 06:16
Hello, can I private chat someone to help me out with one of the challenges. I really don't understand
Chance Vodnoy
@esgameco
Nov 24 2016 06:16
@Ezeboy What's the problem
James
@jbonds08
Nov 24 2016 06:16
???
Ezeboy
@Ezeboy
Nov 24 2016 06:17
Understanding Case Sensitivity in Variables. .how can solve that?
Chance Vodnoy
@esgameco
Nov 24 2016 06:17
@jbonds08 Use "One to One Conversations at the left
Ezeboy
@Ezeboy
Nov 24 2016 06:17

// Declarations
var studlyCapVar= 10;
var properCamelCase= "A String";
var titleCaseOver= 9000;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

Ogundele Olumide
@Lumexralph
Nov 24 2016 06:17
@jbonds08 highlight the avatar of the person from the chats options including private message will be included
Chance Vodnoy
@esgameco
Nov 24 2016 06:18
@Ezeboy Change everything to camel case
Ezeboy
@Ezeboy
Nov 24 2016 06:18
what is camel case?
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:19
@airborneprayer be careful with the way you're doing your calculations cos of float values
Matt
@airborneprayer
Nov 24 2016 06:19
How so sir?
Chance Vodnoy
@esgameco
Nov 24 2016 06:19
Camel case is blahBlahBlahBlah
Ezeboy
@Ezeboy
Nov 24 2016 06:19
?
Chance Vodnoy
@esgameco
Nov 24 2016 06:20
@Ezeboy So the first letter is lower all others are upper
first letter of word*
For example: dogsCatsLobsters
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:20
@Ezeboy it's a style in js for naming variables, functions, the first letter of the word in lower case but the next word'd first letter in capital e.g ballGame
Ezeboy
@Ezeboy
Nov 24 2016 06:21
ahh. .ok tnx i'll try
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:21
@airborneprayer 9/5.....would give you a float
Matt
@airborneprayer
Nov 24 2016 06:22
Yes because otherwise it would be 1
But how so?
Ezeboy
@Ezeboy
Nov 24 2016 06:22
tnx for your help . .igot it :smile:
tommy
@tommygebru
Nov 24 2016 06:23
HAPPY TURKEY DAY everyone :chicken: :football: :smile:
Markus Kiili
@Masd925
Nov 24 2016 06:23
@airborneprayer JS has no integer type. All numbers are floats.
Phillip Kelley-Dotson
@pkdotson
Nov 24 2016 06:23

function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(function forbid(){
var a = [false, null, 0, "", undefined, NaN];
a.includes();
});
}

bouncer([7, "ate", "", false, 9]);

Matt
@airborneprayer
Nov 24 2016 06:24
ok
Phillip Kelley-Dotson
@pkdotson
Nov 24 2016 06:24
tryng to figure out how to edit out the falsy's
Markus Kiili
@Masd925
Nov 24 2016 06:24
@pkdotson NaN is not equal to any value.
Matt
@airborneprayer
Nov 24 2016 06:24
Thank you but I'm still lost in the sauce.
Markus Kiili
@Masd925
Nov 24 2016 06:24
Therefore finding it with methods tends to fail.
Ogundele Olumide
@Lumexralph
Nov 24 2016 06:25
@airborneprayer what's still the confusion?
Markus Kiili
@Masd925
Nov 24 2016 06:25
@pkdotson You need a separate test for NaN.
Matt
@airborneprayer
Nov 24 2016 06:25
I don't know what I'm suppose to do.
Phillip Kelley-Dotson
@pkdotson
Nov 24 2016 06:26
ahh ok thank you @Masd925
CamperBot
@camperbot
Nov 24 2016 06:26
pkdotson sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2993 | @masd925 |http://www.freecodecamp.com/masd925
Ayush Bahuguna
@relentless-coder
Nov 24 2016 06:26
I am adding <li> elements dynamically using jQuery, and I have an image as body background. But when the li gets appended, they have a white background how do I deal with this?
Esterling Accime
@accimeesterlin
Nov 24 2016 06:26
%90 to be done with my portfolio. Any suggestions. http://accimeesterlin.com/
95mainer
@95mainer
Nov 24 2016 06:44
yo guys
Farooq
@farooqzafar
Nov 24 2016 06:44
I got stuck at Profile Lookup Challenge.
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


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

  }
  //fName = contacts.firstName[firstName];

// Only change code above this line
}

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

The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

If both are true, then return the "value" of that property.

If firstName does not correspond to any contacts then return "No such contact"

If prop does not correspond to any valid properties then return "No such property". What am I missing?

Isaac Weber
@ikey2244
Nov 24 2016 06:47

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (par -1) {
    return "Birdie";
  } else if (par) {
    return "Par";
  } else if (par + 1) {
    return "Bogey";
  } else if (par + 2) {
    return "Double Bogey";
  } else if (strokes >= par +3) {
    return "Go Home!";
  } 


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

// Change these values to test
golfScore(5, 4);
code is not running after birdie
Ayush Bahuguna
@relentless-coder
Nov 24 2016 06:48
@ikey2244 look at your return statement.
@farooqzafar what is the error that you are getting?
Isaac Weber
@ikey2244
Nov 24 2016 06:49
@relentless-coder im still not seeing whats wrong
Ezeboy
@Ezeboy
Nov 24 2016 06:50
The variable quotient should equal 2.2? . what is the answer for this?
Farooq
@farooqzafar
Nov 24 2016 06:50
Its actually printing "No such property" while i am expecting it should return the value of the property.
Ayush Bahuguna
@relentless-coder
Nov 24 2016 06:50
@ikey2244 the final return statement, you need to get rid of it.
Farooq
@farooqzafar
Nov 24 2016 06:51
@relentless-coder Its actually printing "No such property" while i am expecting it should return the value of the property. I believe its not iterating the loop correctly.
Isaac Weber
@ikey2244
Nov 24 2016 06:52
```

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (par -1) {
    return "Birdie";
  } else if (par) {
    return "Par";
  } else if (par + 1) {
    return "Bogey";
  } else if (par + 2) {
    return "Double Bogey";
  } else if (strokes >= par +3) {
    return "Go Home!";
  } 

  // Only change code above this line
}

// Change these values to test
golfScore(5, 4);
like so?
Ayush Bahuguna
@relentless-coder
Nov 24 2016 06:53
also, you are missing "strokes" in few of your else if statements. @ikey2244
@farooqzafar you are looping it just once. Your code needs to look up every property.
Farooq
@farooqzafar
Nov 24 2016 06:56
@relentless-coder I think i placed else statement pretty early in the code. I am moving it out of the for loop.
Isaac Weber
@ikey2244
Nov 24 2016 06:58
function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (par -1) {
    return "Birdie";
  } else if (strokes === par) {
    return "Par";
  } else if (par + 1) {
    return "Bogey";
  } else if (par + 2) {
    return "Double Bogey";
  } else if (strokes >= par +3) {
    return "Go Home!";
  } 


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

// Change these values to test
golfScore(5, 4);
why wouldnt this work to at least get par right
Ayush Bahuguna
@relentless-coder
Nov 24 2016 06:59
@farooqzafar also, I am hoping that this is not the complete code, I mean there are other conditions too.
@ikey2244 because your conditions for few else if statements are invalid. par -1 means nothing, you need compare it with something.
@farooqzafar you are supposed to return the value of the prop only if an object has the firstname as the firstname, and it ha the property prop, then only you are supposed to return the value of prop
MoNag1
@MoNag1
Nov 24 2016 07:02
@ikey2244 exactly, you need to relates strokes to par in each of you conditions, all the ones with strokes are correct, apply the same logic to the conditions where you omitted srokes
Farooq
@farooqzafar
Nov 24 2016 07:02
@relentless-coder you are right, i almost got it now. Just adding code for "No such property".
TBreezy1997
@TBreezy1997
Nov 24 2016 07:04
Hey guys
I just wrote the reverseString function and I was wondering if someone could give me some feedback on the design of my code
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:05
@TBreezy1997 hi. Yeah sure, post the code here. :)
TBreezy1997
@TBreezy1997
Nov 24 2016 07:06

function reverseString(str) {
var array = new Array(str.length);
var temp;
for (i = 0; i < str.length; i++) {
temp = str[i];
array[str.length - 1 - i] = temp;
}

return array.join('');
}

Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:07
@TBreezy1997 okay, how about you first split the string, then reverse it, and then join the string?
Isaac Weber
@ikey2244
Nov 24 2016 07:08

function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes === 1) {
    return "Hole-in-one!";
  } else if (strokes <= par - 2) {
    return "Eagle";
  } else if (strokes < par) {
    return "Birdie";
  } else if (strokes === par) {
    return "Par";
  } else if (strokes + 2) {
    return "Bogey";
  } else if (strokes + 2) {
    return "Double Bogey";
  } else if (strokes >= par +3) {
    return "Go Home!";
  } 


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

// Change these values to test
golfScore(5, 4);
Markus Kiili
@Masd925
Nov 24 2016 07:08
@TBreezy1997 You should avoid new Array(). Just var array = [];
Isaac Weber
@ikey2244
Nov 24 2016 07:08
any closer?
@relentless-coder
MoNag1
@MoNag1
Nov 24 2016 07:08
@TBreezy1997 that is an interesting way to do it lol
TBreezy1997
@TBreezy1997
Nov 24 2016 07:09
I wanted to try it without looking at the links. After looking at it I realize you can do it super easily @MoNag1
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:09
@ikey2244 if you have used the correct conditions then you should be all right. let me just check, what the conditions were.
Markus Kiili
@Masd925
Nov 24 2016 07:10
@TBreezy1997 The only reason to use a loop would be the efficiency, so you should use string operations instead of arrays if you use a loop. If you use arrays, do it with methods as @relentless-coder said.
TBreezy1997
@TBreezy1997
Nov 24 2016 07:11
Gotcha
MoNag1
@MoNag1
Nov 24 2016 07:11
@TBreezy1997 yeah it's always good to find your own unique way of doing it, but I guess theres a limit to that. You don't want to go to far so that your code is inefficient. Not that yours is necessarily tho
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:11
@ikey2244 you haven't got some of the conditions correct.
kirbyedy
@kirbyedy
Nov 24 2016 07:12

@ikey2244

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

you sure about this ?

Isaac Weber
@ikey2244
Nov 24 2016 07:12
@kirbyedy it worked idk lol
i know that a birdy is only 1 less than par
birdie
kirbyedy
@kirbyedy
Nov 24 2016 07:13
well its not quite correct :)
check the instructions btw
for birdie
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:13
@Masd925 Hi, I need help. I am creating <li> elements using jQuery, and the problem is that I have an image as body background, but when those <li> elements get appended they have their own white background. Can you help me with this?
TBreezy1997
@TBreezy1997
Nov 24 2016 07:13
Had I read the links provided I probably would've done it the simpler way. I guess I just dove into it without thinking first
MoNag1
@MoNag1
Nov 24 2016 07:14
@ikey2244 your problem is in conditions 5 and 6
k.vincent
@bobKasbi
Nov 24 2016 07:14
@relentless-coder Post your code Pl.
Markus Kiili
@Masd925
Nov 24 2016 07:15
@relentless-coder Have you tried setting the transparency of the background color of the table?
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:16
@Masd925 let me try that.
c0d0er
@c0d0er
Nov 24 2016 07:20
@walidashri thanks
CamperBot
@camperbot
Nov 24 2016 07:20
c0d0er sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 679 | @walidashri |http://www.freecodecamp.com/walidashri
Ayush Bahuguna
@relentless-coder
Nov 24 2016 07:21
@Masd925 I got it. I forgot that I had placed the ul element inside an div, and it had a background property. Didn't have to deal with opacity.
Bogdan Paliy
@bpalij
Nov 24 2016 07:44
Something wrong with 'Local Scope and Functions' lesson. Refresh of the page didnt help
function myLocalScope() {
  'use strict';
  var myVar = "1";

  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
kirbyedy
@kirbyedy
Nov 24 2016 07:48
@bpalij did you remove the console.log ?
Bogdan Paliy
@bpalij
Nov 24 2016 07:50
@kirbyedy no, this is the code i ran
kirbyedy
@kirbyedy
Nov 24 2016 07:50
but the instruction says you have to remove the console.log
the bottom one, not the first one
William Maes
@maeswilliam
Nov 24 2016 07:51
About the read-search-ask. I started basic alg. It seems you very rarely stumble on documentation without the answer of the FCC challenge. Even on the wikipedia page of factorialize they give an alg formula in javascript..am i doing this wrong or what? @Masd925
CamperBot
@camperbot
Nov 24 2016 07:51
:star2: 2993 | @masd925 |http://www.freecodecamp.com/masd925
kirbyedy
@kirbyedy
Nov 24 2016 07:51
it says right there @bpalij
// Now remove the console log line to pass the test
Bogdan Paliy
@bpalij
Nov 24 2016 07:51
@kirbyedy understand, i thougt there is 'dont delet'
Markus Kiili
@Masd925
Nov 24 2016 07:54
@maeswilliam Can't really grasp what you are asking. Maybe it is my English or early morning. Try to rephrase your question.
Chris Cullen
@123xylem
Nov 24 2016 07:54
Hi, QUESTION:
I have a list of image filoes here on github that I want in my codepen project. How do i effiecently up;oad/use them in the Javascript Frogger game project? https://github.com/udacity/frontend-nanodegree-arcade-game/commit/69992cf9a5b1c7aab5296e43a6467d2f9bfa8114#diff-3f9bb3c20b8f88e1ba0c3e4c4e94e833
Ayodele Mudavanhu
@Ayoalex
Nov 24 2016 07:55
i am not sure what i am getting wrong here
function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch(val){
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
default:
console.log("nothing");
break;
}
William Maes
@maeswilliam
Nov 24 2016 07:55
@Masd925 its 9 am bro :P - I guess it's my english
Markus Kiili
@Masd925
Nov 24 2016 07:55
@maeswilliam I meant it is morning here ;)
William Maes
@maeswilliam
Nov 24 2016 07:57
@Masd925 I just started algorithms. When you're stuck, you should apply the read-search-ask. I'm saying it's very hard to find proper documentation without getting answers to the FCC challenges.
Walid Ashri
@walidashri
Nov 24 2016 07:58
why this is not returning two lines :(
`Try Again\n ${num1} + ${num2}`;
Markus Kiili
@Masd925
Nov 24 2016 07:58
@maeswilliam Do you mean documentation on the JS methods?
Or better explanation on the challenge description?
William Maes
@maeswilliam
Nov 24 2016 07:59
@Masd925 documentation/information (theory) to help you solve the algorithm
James
@jbonds08
Nov 24 2016 07:59

// 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"){
  collection[id][prop] = value;
  }
  else if (prop === "tracks"){
    collection[id][prop].push(value);
  }
  if (value ===[]){
    delete collection.prop;
  }

  return collection;

}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
I need help trying to figure out the last few parts of the "Record Collection" challenge
Markus Kiili
@Masd925
Nov 24 2016 08:00
@maeswilliam MDN is the best source for specific JS information.
Emerson
@DikoFaji
Nov 24 2016 08:00
@Masd925 hi markus. i just want to ask how to get the arguments in this ARGUMENTS OPTIONAL Challenge?
function addTogether() {

  return arguments;
}
addTogether(2)([3]);
William Maes
@maeswilliam
Nov 24 2016 08:00
@Masd925 i couldn't find anything on factorialize tough
Ivan Solonovich
@ivan-solonovich
Nov 24 2016 08:01
Hello everyone
Markus Kiili
@Masd925
Nov 24 2016 08:01
@maeswilliam You can also ask here and say that you don't wan't the answer (most people know that already).
@maeswilliam On factorialization they give you the formula and you have to implement it. More to do with basics of programming.
William Maes
@maeswilliam
Nov 24 2016 08:02
i c
Markus Kiili
@Masd925
Nov 24 2016 08:02
@DikoFaji addTogether(2) returns a function and ([3]) calls it.
Ivan Solonovich
@ivan-solonovich
Nov 24 2016 08:02

Please, help me. I don't understand Why to solve this Instructions
Assign the following three lines of text into the single variable myStr using escape sequences.

FirstLine
\SecondLine\
ThirdLine
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 spaces between escape sequences or words.

I have problem with \

James
@jbonds08
Nov 24 2016 08:03
can someone help me. I am trying to figure out, 'if the value is ("") , delete the given prop from the given area
Markus Kiili
@Masd925
Nov 24 2016 08:03
@DikoFaji addTogether function only expects one or two numbers passed into it.
Emerson
@DikoFaji
Nov 24 2016 08:04
@Masd925 ohh ok thanks ill try it
CamperBot
@camperbot
Nov 24 2016 08:04
dikofaji sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2994 | @masd925 |http://www.freecodecamp.com/masd925
kirbyedy
@kirbyedy
Nov 24 2016 08:07
@ivan-solonovich remember how to escape the \
\\
Ivan Solonovich
@ivan-solonovich
Nov 24 2016 08:10
@kirbyedy '\
Chris Cullen
@123xylem
Nov 24 2016 08:11
QUESTION:
Ivan Solonovich
@ivan-solonovich
Nov 24 2016 08:11
@kirbyedy "\"

@kirbyedy @kirbyedy

\\

kirbyedy
@kirbyedy
Nov 24 2016 08:11
yes
Chris Cullen
@123xylem
Nov 24 2016 08:12
QUESTION: My resources is images hosted on github that I link to my codepen project.. on js line 64 they are giving me resources undefined errors though. How do I fix this?
http://codepen.io/123xylem/pen/vyNyqr?editors=1010
Thanks!!
William Maes
@maeswilliam
Nov 24 2016 08:15
@Masd925
function factorialize(num) {
if (num === 0 || num === 1) {
return 1;
}
else {
num = num * (num - 1);
return num;
}
}
@Masd925 So even with proper documentation, i can't seem to make it work
kirbyedy
@kirbyedy
Nov 24 2016 08:17
@maeswilliam just a quick question. why are you using the if else here ? shouldn`t you just loop through all the numbers and multiply them ?
William Maes
@maeswilliam
Nov 24 2016 08:17
@kirbyedy yeah what i just thought
ifeyi
@ifeyi
Nov 24 2016 08:22
Hi, I have a problem with the profile lookup challenge
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];

function lookUpProfile(firstName, prop){
// Only change code below this line

  var retourne = [], i;

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

      if(contacts[i].firstName === firstName && contacts[i].hasOwnProperty(prop)){

        retourne = contacts[i][prop];  

      } else if(!contacts[i].hasOwnProperty(prop)){

        retourne = "No such property";

      } else if(contacts[i].firstName !== firstName){

        retourne = "No such contact";

      }

  }

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


// Change these values to test your function
lookUpProfile("Akira", "likes");
Daria Doronina
@Skidle
Nov 24 2016 08:26
@sjames1958gm I did got help but I still don't understand how to do it and it still doesn't work
can anyone just show me their code on "Seek and Destroy" challenge? I've been stuck for 2 days and I absolutely hate this challenge I just want to pass it
masterkoda
@masterkoda
Nov 24 2016 08:28
got some problem with this code

function caseInSwitch(val) {
var answer = val;
switch(answer){
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");

}
// Only change code below this line

// Only change code above this line
return
}

// Change this value to test
caseInSwitch(1);

how to return the value??
Daria Doronina
@Skidle
Nov 24 2016 08:28
@ifeyi you need to return not to retourne
oh you return retourne then, sorrry
masterkoda
@masterkoda
Nov 24 2016 08:30
hiii can anybody help me
Daria Doronina
@Skidle
Nov 24 2016 08:30

@ifeyi this

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

needs to be false

masterkoda
@masterkoda
Nov 24 2016 08:30
@Skidle can you help me with this
Daria Doronina
@Skidle
Nov 24 2016 08:31
@masterkoda put your code inside ` (3 on the each side)
masterkoda
@masterkoda
Nov 24 2016 08:31

@Skidle function caseInSwitch(val) {
var answer = val;
switch(answer){
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");

}
// Only change code below this line

// Only change code above this line
return
}

// Change this value to test
caseInSwitch(1);

DC
@vuvu10
Nov 24 2016 08:32

Is there anyone that can help me with this: // Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

var entreeValue = ["an entree"]; // Change this line
var drinkValue = ["the drink"]; // Change this line

Daria Doronina
@Skidle
Nov 24 2016 08:32
@masterkoda you need to return something not to console.log(); it
@masterkoda you have declared var answer before the switch statement, you can return this variable
masterkoda
@masterkoda
Nov 24 2016 08:33
@Skidle if i return answer it just gives the value 1?
Chris Cullen
@123xylem
Nov 24 2016 08:34
http://codepen.io/123xylem/pen/vyNyqr?editors=1010
Why is my resources undefined? LINE 64 of javascript???
Resources here is just links to image URLs.
ITS ONLY THE TOP 3rd of the JAVASCRIPT Dont worry ! :)
masterkoda
@masterkoda
Nov 24 2016 08:35
@Skidle it does not run the statements inside the case
Daria Doronina
@Skidle
Nov 24 2016 08:35
@masterkoda did you set your variable answer to equal 'alpha' or other values in the task?
masterkoda
@masterkoda
Nov 24 2016 08:35
@Skidle no sir

@Skidle function caseInSwitch(val) {
var answer = val;
switch(answer){
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");

}

return answer;
}

caseInSwitch(1);

Daria Doronina
@Skidle
Nov 24 2016 08:36
@masterkoda you need to delete your console.log everywhere and instead write answer = "alpha"
masterkoda
@masterkoda
Nov 24 2016 08:38
@Skidle sir that will definetly work..but why console.log() is not working??
Daria Doronina
@Skidle
Nov 24 2016 08:38
@123xylem it's only a suggestion, maybe it need to be declared like this? var Resources = []; ?
fijeko
@fijeko
Nov 24 2016 08:38
@123xylem you miss semicolon on lines 22, 24 and 49in jour js
Daria Doronina
@Skidle
Nov 24 2016 08:39
@masterkoda don't call me sir :D because console.log() sends everything to console in devtools in your browser
@123xylem @fijeko have you passed "Seek and Destroy" challenge? It's in the end of basic algorithms.
fijeko
@fijeko
Nov 24 2016 08:40
@Skidle yes i did what is problem
Chris Cullen
@123xylem
Nov 24 2016 08:40
@Skidle yep tried that.. now it says .load on resources is invalid function
ifeyi
@ifeyi
Nov 24 2016 08:40

@ifeyi this ```else if(!contacts[i].hasOwnProperty(prop)){

    retourne = "No such property";``` needs to be false

@Skidle hi, that's not the problem...

when I pass Sherlock and likes in arguments to my function lookUpProfile it shhould return ["Intriguing Cases", "Violin"]... but it's not workin... actually the function returned 'intriguing cases' and 'violin' when i tested my code, but damn... I can't pass the test and I don't know why... I'm missing something

masterkoda
@masterkoda
Nov 24 2016 08:40
@Skidle thank you so much
CamperBot
@camperbot
Nov 24 2016 08:40
masterkoda sends brownie points to @skidle :sparkles: :thumbsup: :sparkles:
:cookie: 263 | @skidle |http://www.freecodecamp.com/skidle
Daria Doronina
@Skidle
Nov 24 2016 08:41
@fijeko nothing seems to work and I alreedy got help with this yesterday but it still doesn't work :(
@fijeko and I just would really like to see your code and try to understand
Chris Cullen
@123xylem
Nov 24 2016 08:41
@Skidle yes
fijeko
@fijeko
Nov 24 2016 08:41
@123xylem Resource.load(...) is function that you never defined
Daria Doronina
@Skidle
Nov 24 2016 08:41
@123xylem @fijeko here's my code
function destroyer(arr) {
  // Remove all the value
  var el = arr.slice.call(arguments, 1);
  var filtered = arguments[0].filter(function () {
   return (arguments[0] !== el);
 });
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
fijeko
@fijeko
Nov 24 2016 08:45
@Skidle try call(arguments)
hongwutian
@hongwutian
Nov 24 2016 08:45

```function updateRecords(id, prop, value) {

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

}
else if (prop === "tracks" && value !== "") {
if(Array.isArray(collection[id][prop]) === true){
collection[id][prop].push(value);
}
else {
collection[id][prop] = value;
}
}
else if (value === ""){
delete collection[id][prop];
}
return collection;
}```

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element
but i can't fulfill the task in the line above
Daria Doronina
@Skidle
Nov 24 2016 08:46
@fijeko where? change this line return (arguments[0] !== el);?
@ifeyi maybe try pasting your code here and see where is the problem exactly http://pythontutor.com/live.html#mode=edit
ifeyi
@ifeyi
Nov 24 2016 08:47
@fijeko where? change this line return (arguments[0] !== el);? Ok thanks :)
CamperBot
@camperbot
Nov 24 2016 08:47
ifeyi sends brownie points to @fijeko :sparkles: :thumbsup: :sparkles:
:cookie: 328 | @fijeko |http://www.freecodecamp.com/fijeko
fijeko
@fijeko
Nov 24 2016 08:48
@Skidle sorry wrong answer, but you need one more loop around .filter() function that goinig through el array
Daria Doronina
@Skidle
Nov 24 2016 08:51
@fijeko like this?

function destroyer(arr) {
  // Remove all the value
  for (var i = 0; i < arr.length; i++) {
  var el = arr.slice.call(arguments, 1);
  var filtered = arguments[0].filter(function () {
   return (arguments[0] !== el);
 });
  }
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@fijeko then it gives me a warning "Don't put function inside a loop"
Nina
@Ninavdk
Nov 24 2016 08:51
Hi, can anyone help? I'm doing the "Stand in Line" exercise and I'm totally lost
function nextInLine(arr, item) {
  // Your code here

  return arr.queue + item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
Daria Doronina
@Skidle
Nov 24 2016 08:52

@fijeko user @Bauelf gave me this advice yesterday

You use filter with an inner function. The inner function has its own arguments, which shadows the outer one. Put that slice call in the outer function, and assign it to a variable. And use el inside the callback function

but I really don't know how he wanted me to use el inside my callback function

Nina
@Ninavdk
Nov 24 2016 08:52
Am I supposed to be referencing "queue" or is that just theoretical information?
Daria Doronina
@Skidle
Nov 24 2016 08:54
@Ninavdk I think no you don't need to use it and you didn't define it in your function
fijeko
@fijeko
Nov 24 2016 08:54
@Skidle after slice el = [2,3] , you have to test arguments[0] against el[0] and el [1] . You cannot put function in loop, but you can write separate function and call it from loop
Nina
@Ninavdk
Nov 24 2016 08:55
@Skidle do I need to define something in this function before trying to return something?
Daria Doronina
@Skidle
Nov 24 2016 08:55
@Ninavdk you need to push and item to the array
Larisa Escobar
@larisaescobar
Nov 24 2016 08:56
Hello
Daria Doronina
@Skidle
Nov 24 2016 08:56
@fijeko so my for loop should look like this?
for (var i = 0; i < arr.length; i++) {
call(functionname)
};
Larisa Escobar
@larisaescobar
Nov 24 2016 08:57
Can anyone help me with String Immutability?
Stefaan Walleghem
@lawfets
Nov 24 2016 08:57
@larisaescobar what's your problem
Larisa Escobar
@larisaescobar
Nov 24 2016 08:57
I'm trying to correct the assignment to a variable but it won't work
Let me show you
Daria Doronina
@Skidle
Nov 24 2016 08:58
@larisaescobar oh Prague here :)
Larisa Escobar
@larisaescobar
Nov 24 2016 08:58
@Skidle Hiii!!! :D

@lawfets var myStr = "Jello World";

// Only change code below this line
myStr = "Hello World";
myStr[0] = "H"; // Fix Me

fijeko
@fijeko
Nov 24 2016 08:58
@Skidle like this function x () {}; for( var i=0; i < el.length; i++) { filtered = x() }
tanglongyang
@tanglongyang
Nov 24 2016 08:58
what's the meaning?
Use the playerNumber variable to lookup player 16 in testObj using bracket notation.
You should be using the variable playerNumber in your bracket notation

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = 8; // Change this Line
var player = testObj[16]; // Change this Line

hongwutian
@hongwutian
Nov 24 2016 08:59
@larisaescobar myStr = "Hello World"
Stefaan Walleghem
@lawfets
Nov 24 2016 08:59
so you have to change yello world into hello world
Larisa Escobar
@larisaescobar
Nov 24 2016 08:59
Yes
hongwutian
@hongwutian
Nov 24 2016 08:59
Oh man My brain tells me i'm tired that's why i can't code
night all
Larisa Escobar
@larisaescobar
Nov 24 2016 09:00
@hongwutian Yeah, that's what I did but it won't work
Stefaan Walleghem
@lawfets
Nov 24 2016 09:00
make an array of the string, then change the j in to h and make a string out of the array
what challenge is that? so I can check
Larisa Escobar
@larisaescobar
Nov 24 2016 09:01
@lawfets Understand String Immutability
Stefaan Walleghem
@lawfets
Nov 24 2016 09:01
@larisaescobar ok sec, let me have a check
tanglongyang
@tanglongyang
Nov 24 2016 09:01
var code = "formatted";
Larisa Escobar
@larisaescobar
Nov 24 2016 09:01
@lawfets Awesome, thanks!
CamperBot
@camperbot
Nov 24 2016 09:01
larisaescobar sends brownie points to @lawfets :sparkles: :thumbsup: :sparkles:
:cookie: 282 | @lawfets |http://www.freecodecamp.com/lawfets
fijeko
@fijeko
Nov 24 2016 09:02
@Skidle your .filter function is wront it should be like .filter(arg){ return arg == el ) }
Daria Doronina
@Skidle
Nov 24 2016 09:03
@fijeko thank you! and arg is arguments[0] ?
CamperBot
@camperbot
Nov 24 2016 09:03
skidle sends brownie points to @fijeko :sparkles: :thumbsup: :sparkles:
:cookie: 329 | @fijeko |http://www.freecodecamp.com/fijeko
tanglongyang
@tanglongyang
Nov 24 2016 09:04
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber = ;       // Change this Line
var player = testObj[16];   // Change this Line
What's meaning of this sentenceYou should be using the variable playerNumber in your bracket notation
Stefaan Walleghem
@lawfets
Nov 24 2016 09:06
@larisaescobar normally you just have to remove myStr[0] = "H"; // Fix Me and it should be alright
Larisa Escobar
@larisaescobar
Nov 24 2016 09:06
@lawfets okay, let me try it!
Daria Doronina
@Skidle
Nov 24 2016 09:06

@fijeko so I tried to fix it as you suggested

function destroyer(arr) {
  // Remove all the value
  var arg = arguments[0];
  function x () {}
  for (var i = 0; i < arg.length; i++) {
  var el = arr.slice.call(arguments, 1);
  var filtered = arguments[0].filter(arg); 
   return (arg == el);
 }
  return filtered;
}

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

now I got "[object Array] is not a function"

Laszlo Roovers
@LaszloRoovers
Nov 24 2016 09:06
Could anyobd help me with Stand in Line (JavaScript)?
Stefaan Walleghem
@lawfets
Nov 24 2016 09:07
@larisaescobar because strings are immutable you have to give the variable a new string
Laszlo Roovers
@LaszloRoovers
Nov 24 2016 09:07
anybody*
Larisa Escobar
@larisaescobar
Nov 24 2016 09:08
@lawfets It worked, thank you so much!!! :)
CamperBot
@camperbot
Nov 24 2016 09:08
larisaescobar sends brownie points to @lawfets :sparkles: :thumbsup: :sparkles:
:warning: larisaescobar already gave lawfets points
Stefaan Walleghem
@lawfets
Nov 24 2016 09:08
@larisaescobar you're welcome
Nina
@Ninavdk
Nov 24 2016 09:08
@Skidle so confused, do I need to define the testArr in the function?
function nextInLine(arr, item) {
  // Your code here
  arr = [4,5,6,7];
  item = 1;
  return (arr.push(item));  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
fijeko
@fijeko
Nov 24 2016 09:09
@Skidle after you slice arguments you have two array arguments[0] = [1,2,3,1,2,3] and el = [2,3] . You must check if all member form err are not equal to all elements from arguments[0] and if not push it into filtered array. You need two nested loops one for arguments[0] and one for el . your founction x need some code in it
Nina
@Ninavdk
Nov 24 2016 09:09
@LaszloRoovers if it helps I am completely stuck on it too..
Daria Doronina
@Skidle
Nov 24 2016 09:09
@Ninavdk no because it's defined in global scope you don't need to define it in function
gina
@nagi26
Nov 24 2016 09:09
how to do this? myName should be set to a string at least 3 characters long
Stefaan Walleghem
@lawfets
Nov 24 2016 09:09
okay, going to start basic algorithm "Title Case a sentence", so no more chat for now
gina
@nagi26
Nov 24 2016 09:10
Use two + operators to build myStr with myName inside it
Nina
@Ninavdk
Nov 24 2016 09:10
Ok - should I be trying to push() in the return, or before @Skidle?
Daria Doronina
@Skidle
Nov 24 2016 09:10
@fijeko ok thanks! I'll try now
CamperBot
@camperbot
Nov 24 2016 09:10
skidle sends brownie points to @fijeko :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave fijeko points
Daria Doronina
@Skidle
Nov 24 2016 09:11
@Ninavdk push before return and then shift in return
Nina
@Ninavdk
Nov 24 2016 09:12
ok thanks @Skidle I'll give that a try :)
CamperBot
@camperbot
Nov 24 2016 09:12
ninavdk sends brownie points to @skidle :sparkles: :thumbsup: :sparkles:
:cookie: 264 | @skidle |http://www.freecodecamp.com/skidle
Dan Couper
@DanCouper
Nov 24 2016 09:12
@Ninavdk you don't specify arr or item inside the function - that's the point of functions. Arr and item are whatever you give the function when you call it - nextInLine([4,5,6,7],1) - arr is 4,5,6,7, item is 1. Arr is any array, item is any item
Tim Stawowski
@officer-sexy
Nov 24 2016 09:13

hey Guys, could smbdy tell me why I dont get pass through this challenge?! I have to upperCase every first letter of a word - it functions on all examples
function titleCase(str) {
var array = [];
var str2 = "";
var word = "";
var letter = "";

array = str.split(" ");

for (var i = 0; i < array.length; i++) {
word = array[i].toLowerCase();

if((/[a-z]/.test(word))) {
  letter = word.substring(0,1).toUpperCase();
  word = letter + word.substring(1,word.length);
}
str2 += word + " ";

}// end of for

return str2;
}// end of titleCase

titleCase("sHoRt AnD sToUt");

Walid Ashri
@walidashri
Nov 24 2016 09:15
@officer-sexy because of the un necessary space at the end of the string
Tim Stawowski
@officer-sexy
Nov 24 2016 09:16
@walidashri thanks!
CamperBot
@camperbot
Nov 24 2016 09:16
officer-sexy sends brownie points to @walidashri :sparkles: :thumbsup: :sparkles:
:cookie: 682 | @walidashri |http://www.freecodecamp.com/walidashri
Walid Ashri
@walidashri
Nov 24 2016 09:17
@officer-sexy u can pass it with return str2.trim()
Dan Couper
@DanCouper
Nov 24 2016 09:19
@officer-sexy It is easier if: you split on spaces, as you're doing, and iterating through the array of words title casing, as you're doing. But instead of trying to glue the words back together one by one, leave them as an array, then use array.join(' '). It means you don't need the extra str2 variable
It just does the whole thing at once, turning the array into a string, putting spaces between your words
Tim Stawowski
@officer-sexy
Nov 24 2016 09:20
thanks for the help guys
Nina
@Ninavdk
Nov 24 2016 09:22
Still confused. I'm gonna sleep on it and try again tomorrow. Cheers for the info @DanCouper and thanks for direction so far @Skidle - I'm atleast now knowing I need to be referencing the data manipulation exercises push/shift etc so that's a start :)
CamperBot
@camperbot
Nov 24 2016 09:22
ninavdk sends brownie points to @dancouper and @skidle :sparkles: :thumbsup: :sparkles:
:cookie: 364 | @dancouper |http://www.freecodecamp.com/dancouper
:warning: ninavdk already gave skidle points
Daria Doronina
@Skidle
Nov 24 2016 09:23
@Ninavdk best of luck to you!
Nina
@Ninavdk
Nov 24 2016 09:23
Thanks @Skidle :smile:
CamperBot
@camperbot
Nov 24 2016 09:23
ninavdk sends brownie points to @skidle :sparkles: :thumbsup: :sparkles:
:warning: ninavdk already gave skidle points
Dan Couper
@DanCouper
Nov 24 2016 09:24
Look at what push and shift return - at the minute, with the code you have there, it will return the number 5 every time
Good luck! You'll be able to get a lot of help here when you're stuck tho. 😊
Duwayne16
@Duwayne16
Nov 24 2016 09:28
can anyone help me
Stanley Su
@cuddlycuddles
Nov 24 2016 09:28
Need help on the titleCase challenge
Duwayne16
@Duwayne16
Nov 24 2016 09:28

function convertToF(celsius) {
var fahrenheit = 9/5 +32;
// Only change code below this line
var fahrenheit = -30 9/5 + 32;
return fahrenheit;
var fahrenheit = -10
9/5 + 32;
var fahrenheit = 0 9/5 + 32;
var fahrenheit = 20
9/5 + 32;
var fahrenheit = 30 * 9/5 + 32;
// Only change code above this line
return fahrenheit;
}

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

Stanley Su
@cuddlycuddles
Nov 24 2016 09:29
@Duwayne16 Are you altering your code to suit the requirements? That isn't a good idea, make it an actual function that works with any value.
Duwayne16
@Duwayne16
Nov 24 2016 09:30
so the var should be function
@cuddlycuddles
Stanley Su
@cuddlycuddles
Nov 24 2016 09:31
@Duwayne16 Could you send me your code? Use ``` before and after your code by the way, to make it formatted.
davood rafiee
@davoodfox
Nov 24 2016 09:33
hey first time here! can you help me with this?
whats wrong with my code?
record collection
  if (collection[id[prop]] !== "tracks" && collection[id[prop[value]]] !== ""){
    collection[id[prop]] = prop;
    collection[id[prop[value]]] = value;
  }
Aditi Roy
@AlluringAditi
Nov 24 2016 09:34
@davoodfox Hey!! Even I'm stuck here!!

@davoodfox This is what I did:
function updateRecords(id, prop, value) {

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

Stanley Su
@cuddlycuddles
Nov 24 2016 09:34
@davoodfox In your if statement, it should be collection[id][prop].
@DevD01 When the value is undefined, you shouldn't pop it, you should use the delete method.
Aditi Roy
@AlluringAditi
Nov 24 2016 09:35
@cuddlycuddles oohh okay! Correcting it now
Philipp Scholz
@philipp32
Nov 24 2016 09:38
Good morning :)
Aditi Roy
@AlluringAditi
Nov 24 2016 09:38
@cuddlycuddles Still not working:
else if(value === "")
{
delete.collection[id].prop;
}
Philipp Scholz
@philipp32
Nov 24 2016 09:38
I am working on the Chunky Monkey Challenge and this is my code thus far.
function chunkArrayInGroups(arr, size) {
 var string = [];
 for (var i=0; i<arr.length; i++){
   string = arr.slice(i, i+size).push();
 }
 return string;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
It doesn't work and I want to know why. :)
Stanley Su
@cuddlycuddles
Nov 24 2016 09:38
@DevD01 it's better to use bracket notation for prop rather than dot notation
Aditi Roy
@AlluringAditi
Nov 24 2016 09:39
@cuddlycuddles delete.collection[id[prop]];
@cuddlycuddles Now it says that I'm missing an identifier
I don't Understand
Stanley Su
@cuddlycuddles
Nov 24 2016 09:41
@DevD01 I told you before, it should be collection[id][prop].
Also, when you use delete, you don't need the full stop. It should be:
delete collection[id][prop];
Aditi Roy
@AlluringAditi
Nov 24 2016 09:41
@cuddlycuddles aahhh!! Okay okay!! sorry about that!
Philipp Scholz
@philipp32
Nov 24 2016 09:42
Does anyone have any ideas about my code. :)
Vladislav Polak
@tahoerock
Nov 24 2016 09:42

Hi there, I need the help please. I started to learn JS and are stuck in this: function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

darkflikk
@darkflikk
Nov 24 2016 09:43
@tahoerock what is the problem?
@tahoerock All you need to know is written on the left. What don't you understand?
@philipp32 what is your push for?
Philipp Scholz
@philipp32
Nov 24 2016 09:46

Got a new code:

unction chunkArrayInGroups(arr, size) {
  var newarray = [];
  for (var i=0; i<size; i++) {
    var string = arr.slice(i,i+size);
    newarray.push(string);
  }
   return newarray;
}

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

It should produce [["a","b"],["c","d"]] but it produces [["a","b"],["b","c"]].

@darkflikk
darkflikk
@darkflikk
Nov 24 2016 09:46
oh, suddenly it changed and has no more push :D
Vladislav Polak
@tahoerock
Nov 24 2016 09:47
@darkflikk Im lost what is wanted from me
Philipp Scholz
@philipp32
Nov 24 2016 09:47
@darkflikk well, i looked up the function and realized I was wrong
How do I get the i to count one more and return the d and not the c
darkflikk
@darkflikk
Nov 24 2016 09:47
@tahoerock i want you to read the text of the challenge and tell me what you don't understand
@philipp32 use arr.length in your loop
Stanley Su
@cuddlycuddles
Nov 24 2016 09:50
@tahoerock It wants you to make a function that converts celcius to fahrenheit. So just use the formula they give you
Philipp Scholz
@philipp32
Nov 24 2016 09:50
@darkflikk that returns a,b b,c c,d d
Vladislav Polak
@tahoerock
Nov 24 2016 09:50
@darkflikk Im reading it and do not know how to start.
__mifflin__
@cdrainxv
Nov 24 2016 09:50
@philipp32:
for (var i = 0; i < arr.length; i += size)
Daria Doronina
@Skidle
Nov 24 2016 09:51
@tahoerock you fahrenheit should equal their formula
darkflikk
@darkflikk
Nov 24 2016 09:51
@philipp32 you're using a string instead of an array
Daria Doronina
@Skidle
Nov 24 2016 09:51
@tahoerock ahoj :)
Philipp Scholz
@philipp32
Nov 24 2016 09:52
@cdrainxv thank you. Can you explain to me why this works?
CamperBot
@camperbot
Nov 24 2016 09:52
philipp32 sends brownie points to @cdrainxv :sparkles: :thumbsup: :sparkles:
:star2: 1094 | @cdrainxv |http://www.freecodecamp.com/cdrainxv
Daria Doronina
@Skidle
Nov 24 2016 09:53
guys I'm still on this "Seek and Destroy" challenge. Multiple people already tried to help me and now I'm really confused
darkflikk
@darkflikk
Nov 24 2016 09:53
@Skidle what is it?
Vladislav Polak
@tahoerock
Nov 24 2016 09:53
@Skidle Ahoj
Philipp Scholz
@philipp32
Nov 24 2016 09:53
@cdrainxv why do you use i+=size?
Daria Doronina
@Skidle
Nov 24 2016 09:54
@darkflikk here's my code
function destroyer(arr) {
  // Remove all the value
  var x = arguments;
  var arg = arguments[0];
  var filtered;
  for (var i = 1; i < x.length; i++) {
  filtered = arg.filter(function wtf (el) {return (x[i] != el);});
  }
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Philipp Scholz
@philipp32
Nov 24 2016 09:54
oh, understood it. :)
__mifflin__
@cdrainxv
Nov 24 2016 09:54
@philipp32: :smile: … I figured you would. :+1:
Daria Doronina
@Skidle
Nov 24 2016 09:54
@darkflikk "Remove all elements from the initial array that are of the same value as these arguments."
darkflikk
@darkflikk
Nov 24 2016 09:54
let's see
Daria Doronina
@Skidle
Nov 24 2016 09:55
@darkflikk for now it only works partially for second element in array, but not both 2, 3
davood rafiee
@davoodfox
Nov 24 2016 09:55
if (collection[id][prop] !== "tracks" && collection[id][prop][value] !== ""){
    collection[id][prop] = prop;
    collection[id][prop][value] = value;
  }
cannot read property of 'ABBA' of undefined error
Chris Cullen
@123xylem
Nov 24 2016 09:55
http://codepen.io/123xylem/pen/vyNyqr?editors=1010
aught ReferenceError: Resources is not defined
at pen.js:164:4
QUESTION:
It refers to the top 3rd of ONLY my JS part...
How do I define resources?> Isnt it a built in JQUERY function/ variable?
Daria Doronina
@Skidle
Nov 24 2016 09:56
@darkflikk or actually it only works for the first element in the array that needs to be removed :worried:
darkflikk
@darkflikk
Nov 24 2016 09:56
@Skidle first of all, do you know what arr is inside the function?
Daria Doronina
@Skidle
Nov 24 2016 09:57
@darkflikk yes arr is [1, 2, 3, 1, 2, 3], 2, 3 this
Vladislav Polak
@tahoerock
Nov 24 2016 09:57
@Skidle Ahoj tu jsi z Prahy?
Daria Doronina
@Skidle
Nov 24 2016 09:58
@tahoerock ano ale původně jsem z Ruska :)
darkflikk
@darkflikk
Nov 24 2016 09:58
@Skidle no, then you wouldn't have to work with arguments ;)
Johnny
@JohnnyBizzel
Nov 24 2016 09:59
@davoodfox collection[id][prop] = value; should be the way to set the value
@123xylem Add resources using the cog on codepen
Daria Doronina
@Skidle
Nov 24 2016 09:59
@darkflikk oh mind blown, arr is just the first array element
darkflikk
@darkflikk
Nov 24 2016 10:00
@Skidle first of all i recommend using better variable names. that will help a lot
Daria Doronina
@Skidle
Nov 24 2016 10:00
@darkflikk but I don't understand how is it possible that arr is only the first element, how the function knows about the two other elements
darkflikk
@darkflikk
Nov 24 2016 10:01
@Skidle it knows through the arguments object
Daria Doronina
@Skidle
Nov 24 2016 10:02
@darkflikk alright, I changed variables' names
function destroyer(arr) {
  // Remove all the value
  var allElements = arguments;
  var firstArray = arguments[0];
  var filtered;
  for (var i = 1; i < allElements.length; i++) {
  filtered = firstArray.filter(function filtering (el) {return (allElements[i] != el);});
  }
  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@JohnnyBizzel thanks for the link I already read it but still don't understand :(
CamperBot
@camperbot
Nov 24 2016 10:03
:cookie: 855 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
skidle sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
darkflikk
@darkflikk
Nov 24 2016 10:04

@Skidle

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

With this, inside the function you will have the following array:

arguments[0] = [1, 2, 3, 1, 2, 3];
arguments[1] = 2;
arguments[2] = 3;
Daria Doronina
@Skidle
Nov 24 2016 10:04
@darkflikk yes
darkflikk
@darkflikk
Nov 24 2016 10:05
@Skidle so the array to modify is at index 0, that much i see you allready got
now look at your loop, what are you doing there?
Johnny
@JohnnyBizzel
Nov 24 2016 10:06
@Skidle Understand now?
darkflikk
@darkflikk
Nov 24 2016 10:06
And think about if firstArray changes or not
Daria Doronina
@Skidle
Nov 24 2016 10:06
@JohnnyBizzel well yes I understand why we use arguments here :)
Johnny
@JohnnyBizzel
Nov 24 2016 10:07
@Skidle This is an important feature of functions :+1:
Vladislav Polak
@tahoerock
Nov 24 2016 10:07
@Skidle Začal jsem s JS a stojim tady nad prvnim problemem. Celsius to Fahrenheit
Daria Doronina
@Skidle
Nov 24 2016 10:07
@darkflikk in my loop I iterate through second and third elements and firstArray should change, I think
crazycoder775
@crazycoder775
Nov 24 2016 10:08
Hi, can someone help me with a D3 chart ? I developed a simple D3 bar chart. I want to export the same to Excel and PDF (both chart and data). What are the possible options to do the same ? I did Google but didn't seem to fine a suitable answer.
darkflikk
@darkflikk
Nov 24 2016 10:08
@Skidle what will happen in the last loop pass?
Daria Doronina
@Skidle
Nov 24 2016 10:08
@darkflikk also thank you very much for being patient with me, I really appreciate it!
CamperBot
@camperbot
Nov 24 2016 10:08
skidle sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
:cookie: 150 | @darkflikk |http://www.freecodecamp.com/darkflikk
Johnny
@JohnnyBizzel
Nov 24 2016 10:08

@Skidle Note arguments is not an array:

The arguments object is not an Array. It is similar to an Array, but does not have any Array properties except length. For example, it does not have the pop method. However it can be converted to a real Array:

darkflikk
@darkflikk
Nov 24 2016 10:09
what is the value of firstArray in the last loop pass?
Daria Doronina
@Skidle
Nov 24 2016 10:09
@darkflikk i will be equal to allElements.length and loop will stop?
@darkflikk should be [1,1] ?
darkflikk
@darkflikk
Nov 24 2016 10:09
@Skidle no, why should it change?
Daria Doronina
@Skidle
Nov 24 2016 10:10
@tahoerock fahrenheit se musí rovnat celsius krát něco a myslím plus něco (z toho vzorce z úlohy) A pak už tam myslím mají return fahrenheit
@darkflikk because it will be filtered?
darkflikk
@darkflikk
Nov 24 2016 10:11
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
Daria Doronina
@Skidle
Nov 24 2016 10:11
@darkflikk oh that's why
darkflikk
@darkflikk
Nov 24 2016 10:11

Return value

A new array with the elements that pass the test.

Daria Doronina
@Skidle
Nov 24 2016 10:12
@darkflikk so firstArray doesn't change but some elements that pass the filter just are "copied" from it to my variable filtered ?
Johnny
@JohnnyBizzel
Nov 24 2016 10:12
@crazycoder775 I used PdfSharp and MigraDoc to create PDFs but that was in my C# days!
darkflikk
@darkflikk
Nov 24 2016 10:13
@Skidle yes
Johnny
@JohnnyBizzel
Nov 24 2016 10:13
@Skidle sounds correct to me
darkflikk
@darkflikk
Nov 24 2016 10:13
@Skidle so only the last element should be filtered
Daria Doronina
@Skidle
Nov 24 2016 10:14
@darkflikk so I need to change something inside .filter() function right?
Vladislav Polak
@tahoerock
Nov 24 2016 10:14
@Skidle Jak sem vlozim CODE, aby to bylo spravne?
darkflikk
@darkflikk
Nov 24 2016 10:14
@Skidle no, you have to return the result of the filter method to another variable then "filtered"
Daria Doronina
@Skidle
Nov 24 2016 10:15
@tahoerock na anglické klávesnici vlevo od 1 je tlačítko `. musíš mít 3krát ho z obou stran kodu
Johnny
@JohnnyBizzel
Nov 24 2016 10:16
'''
CamperBot
@camperbot
Nov 24 2016 10:16
:bulb: to format code use backticks! ``` more info
Vladislav Polak
@tahoerock
Nov 24 2016 10:17
@Skidle dekuju test code
darkflikk
@darkflikk
Nov 24 2016 10:17
@Skidle got it?
Daria Doronina
@Skidle
Nov 24 2016 10:17
@darkflikk no :( why do I need to do it?
Johnny
@JohnnyBizzel
Nov 24 2016 10:17
Anyone recommend a good Twitch TV channel?
Daria Doronina
@Skidle
Nov 24 2016 10:18
@darkflikk like this?
function destroyer(arr) {
  // Remove all the value
  var allElements = arguments;
  var firstArray = arguments[0];
  var filteredFirst;
  var filteredSecond;
  for (var i = 1; i < allElements.length; i++) {
  filteredFirst = firstArray.filter(function filtering () {return (allElements[i] != el);});
    filteredSecond = filteredFirst;
  }
  return filteredSecond;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
darkflikk
@darkflikk
Nov 24 2016 10:18
nope :D
Vladislav Polak
@tahoerock
Nov 24 2016 10:18
@Skidle how did you do black background?
Daria Doronina
@Skidle
Nov 24 2016 10:19
@tahoerock it happens automatically when you put three ` on the both sides of code
darkflikk
@darkflikk
Nov 24 2016 10:19
@tahoerock like this:
```
your code goes here
```
'''
CamperBot
@camperbot
Nov 24 2016 10:19
:bulb: to format code use backticks! ``` more info
Daria Doronina
@Skidle
Nov 24 2016 10:19
@darkflikk :smile: i'm pathetic
darkflikk
@darkflikk
Nov 24 2016 10:20
@Skidle you got it?
Daria Doronina
@Skidle
Nov 24 2016 10:20
@darkflikk no :D
@darkflikk maybe I need to change something here .filter(function filtering () {return (allElements[i] != el);});
darkflikk
@darkflikk
Nov 24 2016 10:20
So, did you figure out that "firstArray" is the same in every loop iteration?
Daria Doronina
@Skidle
Nov 24 2016 10:20
@darkflikk yes
tanglongyang
@tanglongyang
Nov 24 2016 10:21
function checkObj(checkProp) {
  // Your Code Here
  if (myObj.hasOwnProperty("checkProp") === true)
    {
       return myObj[checkProp];
    }
     return "Not Found";
}
darkflikk
@darkflikk
Nov 24 2016 10:21
so what do you have to do to change it @Skidle ?
Vladislav Polak
@tahoerock
Nov 24 2016 10:21
@Skidle Thanks a lot
CamperBot
@camperbot
Nov 24 2016 10:21
tahoerock sends brownie points to @skidle :sparkles: :thumbsup: :sparkles:
:cookie: 265 | @skidle |http://www.freecodecamp.com/skidle
tanglongyang
@tanglongyang
Nov 24 2016 10:21
what's the problem about this 206
Daria Doronina
@Skidle
Nov 24 2016 10:22
@darkflikk I guess I need to put this inside .filter() {return (firstArray != allArguments[i]);});
Johnny
@JohnnyBizzel
Nov 24 2016 10:22
@Skidle Maybe if you see how someone else did it, it would help.
Here is my solution: http://coding.citytravelling.me.uk/Seek-Destroy.html
crazycoder775
@crazycoder775
Nov 24 2016 10:22
@crazycoder775 I used PdfSharp and MigraDoc to create PDFs but that was in my C# days! Thank you will check it for PDF exports. Did you get a chance to throw your hands on Excel export formats using D3JS ?
CamperBot
@camperbot
Nov 24 2016 10:22
sorry crazycoder775, you can't send brownie points to yourself! :sparkles: :sparkles:
Daria Doronina
@Skidle
Nov 24 2016 10:22
@JohnnyBizzel thank you I'll check it out
CamperBot
@camperbot
Nov 24 2016 10:22
skidle sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave johnnybizzel points
crazycoder775
@crazycoder775
Nov 24 2016 10:24
@JohnnyBizzel : Thank you will check it for PDF exports. Did you get a chance to throw your hands on Excel export formats using D3JS ?
CamperBot
@camperbot
Nov 24 2016 10:24
:cookie: 856 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
crazycoder775 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
Johnny
@JohnnyBizzel
Nov 24 2016 10:24
@crazycoder775 I've never used D3. There are probably separate tools you can use.
darkflikk
@darkflikk
Nov 24 2016 10:24
@JohnnyBizzel not a good solution :)
crazycoder775
@crazycoder775
Nov 24 2016 10:24
@JohnnyBizzel : Can you suggest any alternatives ? I see chartjs but not sure about the export formats
darkflikk
@darkflikk
Nov 24 2016 10:24
@tahoerock
Vladislav Polak
@tahoerock
Nov 24 2016 10:26

@Skidle I do not know What should I write between those lines'''
function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

CamperBot
@camperbot
Nov 24 2016 10:26
:bulb: to format code use backticks! ``` more info
darkflikk
@darkflikk
Nov 24 2016 10:27
@Skidle you want the solution?
Daria Doronina
@Skidle
Nov 24 2016 10:27
@darkflikk yes :(
crazycoder775
@crazycoder775
Nov 24 2016 10:27
@JohnnyBizzel : Thank you, will check out :)
CamperBot
@camperbot
Nov 24 2016 10:27
crazycoder775 sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: crazycoder775 already gave johnnybizzel points
Johnny
@JohnnyBizzel
Nov 24 2016 10:28
@crazycoder775 Good luck :+1:
Daria Doronina
@Skidle
Nov 24 2016 10:28
@JohnnyBizzel why did you use val != this ?
darkflikk
@darkflikk
Nov 24 2016 10:28
@Skidle using your code:
function destroyer(arr) {
  // Remove all the value
  var filterValues = Array.prototype.slice.call(arguments, 1);
  var array = arguments[0];

  for (var i = 0; i < filterValues.length; i++) {
     array = array.filter(function filtering (el) {return (filterValues[i] != el);}); // assign the return to 'array' instead of a different variable
  }

  return array;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Daria Doronina
@Skidle
Nov 24 2016 10:28
@tahoerock it's not ' it's ` (next to 1 key)
darkflikk
@darkflikk
Nov 24 2016 10:28
@Skidle but you should not declare functions in a loop like that
Johnny
@JohnnyBizzel
Nov 24 2016 10:28
@tahoerock The challenge gives you the formula.
Markus Kiili
@Masd925
Nov 24 2016 10:29
@Skidle Loop or iterate inside the filter callback.
Vladislav Polak
@tahoerock
Nov 24 2016 10:29

@Skidle : To test your learning, you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit.

Note
Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned
```function convertToF(celsius) {
var fahrenheit;
// Only change code below this line

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

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

darkflikk
@darkflikk
Nov 24 2016 10:30
@Skidle got it?
Daria Doronina
@Skidle
Nov 24 2016 10:30
@darkflikk yes it gives me warning for declaring functions inside loops. Thank you a lot! Can I ask why we use el ? it doesn't mean anything right?
CamperBot
@camperbot
Nov 24 2016 10:30
skidle sends brownie points to @darkflikk :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave darkflikk points
Daria Doronina
@Skidle
Nov 24 2016 10:31
@tahoerock you need to put ` on a different line
Johnny
@JohnnyBizzel
Nov 24 2016 10:31
@Skidle el = short for "element", just a name. We describe it as elements of an array.
darkflikk
@darkflikk
Nov 24 2016 10:32
@Skidle it does, you should change it
Daria Doronina
@Skidle
Nov 24 2016 10:32

@tahoerock

```function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
// Only change code above this line
return fahrenheit;
}
// Change the inputs below to test your code
convertToF(20);

put fahrenheit = celsius * něco ze vzorce + něco between those lines
// Only change code below this line
here you put your code
// Only change code above this line

@darkflikk @JohnnyBizzel thank you, so I don't need to declare el outside a function?
CamperBot
@camperbot
Nov 24 2016 10:33
skidle sends brownie points to @darkflikk and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:warning: skidle already gave darkflikk points
:warning: skidle already gave johnnybizzel points
Johnny
@JohnnyBizzel
Nov 24 2016 10:33
@tahoerock Details about code formatting: https://forum.freecodecamp.com/t/forum-code-formatting/25574
With animations
Lucas Mendes Gabriel
@lucasemg
Nov 24 2016 10:34
hey guys, so
I'm TOTALLY stucked in the MadLibs challange
darkflikk
@darkflikk
Nov 24 2016 10:34
@Skidle
function destroyer(arr) {
  // Remove all the value
  var filterValues = Array.prototype.slice.call(arguments, 1);
  var array = arguments[0];

  array = array.filter( function (el) { return filterValues.indexOf(el) == -1;});


  return array;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
ashkrish07
@ashkrish07
Nov 24 2016 10:34
Hello guys i need a help..... (TypeError : Cannot read property 'prop' of undefined ) why this error occurs..?
Johnny
@JohnnyBizzel
Nov 24 2016 10:34

@Skidle

@darkflikk @JohnnyBizzel thank you, so I don't need to declare el outside a function?

No

CamperBot
@camperbot
Nov 24 2016 10:34
johnnybizzel sends brownie points to @skidle and @darkflikk :sparkles: :thumbsup: :sparkles:
:cookie: 151 | @darkflikk |http://www.freecodecamp.com/darkflikk
:cookie: 266 | @skidle |http://www.freecodecamp.com/skidle
J Player
@Heyjp
Nov 24 2016 10:35
@ashkrish07 post your code instead of just the error
ashkrish07
@ashkrish07
Nov 24 2016 10:35

// 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(collection.id.prop==="tracks"&&collection.id.prop!==" ")
collection.id.prop=value;
else if(value===" ")
delete collection.id.prop;
else
collection.id.prop.push(value);

return collection;
}

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

darkflikk
@darkflikk
Nov 24 2016 10:35
@Skidle
function destroyer(arr) {
  var targets=Array.prototype.slice.call(arguments,1);
  return arr.filter(e=>targets.every(t=>e!==t));
}
Johnny
@JohnnyBizzel