These are chat archives for FreeCodeCamp/HelpJavaScript

4th
Jul 2016
clintonjohn
@clintonjohn
Jul 04 2016 00:01
@moigithub thanks. That sets the previous value to the index 0, not the number zero, correct?
CamperBot
@camperbot
Jul 04 2016 00:01
clintonjohn sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1627 | @moigithub |http://www.freecodecamp.com/moigithub
Moisés Man
@moigithub
Jul 04 2016 00:01
@clintonjohn number 0
clintonjohn
@clintonjohn
Jul 04 2016 00:02
Ok. Reading the MDN guide, it also seems to insure the first
Moisés Man
@moigithub
Jul 04 2016 00:03
[1,2,3].reduce((a,b)=>{ return a + b} ); <-- without the optional argument...
on first iteration... a will be 1, b will be 2
on next iteration.. a will be that returned value, b will be 3
@clintonjohn
clintonjohn
@clintonjohn
Jul 04 2016 00:03
@moigithub MDN: Note: If initialValue isn't provided, reduce will execute the callback function starting at index 1, skipping the first index. If it is provided, ti will start at index 0.
so the index and the number?
Moisés Man
@moigithub
Jul 04 2016 00:04
[1,2,3].reduce((a,b)=>{ return a + b} , 66); <-- WITH the optional argument...
on first iteration... a will be 66, b will be 1
on next iteration.. a will be that returned value, b will be 2
... and so on
@clintonjohn
This message was deleted
clintonjohn
@clintonjohn
Jul 04 2016 00:10
@moigithub thanks that is really cool!
CamperBot
@camperbot
Jul 04 2016 00:10
clintonjohn sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:warning: clintonjohn already gave moigithub points
Sam
@alakasam
Jul 04 2016 00:12
Why isn't my function defined, when i pass it through another function's argument?
Brendan Kinahan
@BKinahan
Jul 04 2016 00:16
that's the kind of question that needs some code to make sense.
Sam
@alakasam
Jul 04 2016 00:19

ok. so i'm working on the "get weather" challenge , and I'm trying to pass on the valuables of longitude and latitude, into another function.
so what my code is supposed to do is: when the document is ready, run function getPos () to get the coordinates, and then run getTemp() to get the JSON from a weather site using the values from getPos()

However, I can't seem to invoke the getPos() function. my dev console returns getPos() is not defined

https://codepen.io/alakasam/pen/QEgyzR?editors=0011

Aakash Gupta
@aakash916
Jul 04 2016 00:22
Hey guys.
I'm trying to initialize an array within a JS object.
Parameters to the functions are (id,prop,value) and this is my code
if (prop === "tracks") {
collection[id].tracks = [];
collection[id].tracks.push(value);
ANy idea what's wrong here?
latifawudu
@latifawudu
Jul 04 2016 00:23
Hello people
how do you do?
Moisés Man
@moigithub
Jul 04 2016 00:23
@alakasam probably is defined on anther scope.... different than the scope u calling it
latifawudu
@latifawudu
Jul 04 2016 00:24
I am stuck with Arithmetic operations Increment with ++
Moisés Man
@moigithub
Jul 04 2016 00:24
@alakasam ok.. its cuz u using the same variable/argument name as ur function
function getTemp(getPos){ <<<---
getPos();
latifawudu
@latifawudu
Jul 04 2016 00:24

```var myVar = 87;

// Only change code below this line
MyVar= 87++;```

There seems to be a problem with the above
Aakash Gupta
@aakash916
Jul 04 2016 00:25
@latifawudu
you call is incorrect.
it is initialized as myVar but you're trying to change MyVar
You should also try and use just
myVar++ instead of the assignment (=) operator
latifawudu
@latifawudu
Jul 04 2016 00:26
can someone help me to identify
so what am I suppose to do?
OK Thank you @aakash916
CamperBot
@camperbot
Jul 04 2016 00:27
latifawudu sends brownie points to @aakash916 :sparkles: :thumbsup: :sparkles:
:cookie: 212 | @aakash916 |http://www.freecodecamp.com/aakash916
Sam
@alakasam
Jul 04 2016 00:28

@moigithub Isn't that how I invoke the arument in the 2nd line, if I don't pass it on as an argument?

function getTemp(getPos){ getPos();<<<--

ALLY
@ally0426
Jul 04 2016 00:28
hi, can someone explain why this starts with var results = [];?

function largestOfFour(arr) {
var results = [];
for (var n = 0; n < arr.length; n++) {
var largestNumber = 0;
for (var sb = 0; sb < arr[n].length; sb++) {
if (arr[n][sb] > largestNumber) {
largestNumber = arr[n][sb];
}
}

results[n] = largestNumber;

}

return results;
}

llamatarianism
@llamatarianism
Jul 04 2016 00:29
because otherwise results would be undefined
and you wouldn't be able to add items to it or return it
Moisés Man
@moigithub
Jul 04 2016 00:29
@alakasam to invoke a FUNCTIon yes.. u write the name followed by ()
but getPos is undefined....
u not passing any function value when u calling getTemp
$(function () {
getTemp();
});
... if u wanna use the GLOBAL function declared above that code.. u should NOT use the same name on ur argument/variable
ALLY
@ally0426
Jul 04 2016 00:30
ok, and var largestNum ber = o; should be between the two for loops?
Hassaan Hafeez
@HassHz
Jul 04 2016 00:31
yea
ALLY
@ally0426
Jul 04 2016 00:31
how about putting it before the first for loop?
Hassaan Hafeez
@HassHz
Jul 04 2016 00:32
No, that way it will store the largest number from the previous sub-arrays as well
This message was deleted
Moisés Man
@moigithub
Jul 04 2016 00:32
@alakasam also not all browsers have built-in support for geolocation.. so u need to check it first..
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation
and.... watchPosition, getCurrentPosition methods are ASYNChronous... soo the way u have ur code.. wont work
Hassaan Hafeez
@HassHz
Jul 04 2016 00:32
Oh wait the code is right
Sam
@alakasam
Jul 04 2016 00:34
hmmm okay let me process these haha @moigithub
Moisés Man
@moigithub
Jul 04 2016 00:34
@alakasam u should do something similar to this code https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation#Getting_the_current_position
do_something should be ur getTemp..with 2 arguments...
Jonathan Doliver
@porygonj
Jul 04 2016 00:35
I foolishly added //noprotect before an infinite loop, and now I'm unable to edit the code to remove it. What can I do?
llamatarianism
@llamatarianism
Jul 04 2016 00:37
help autorun
CamperBot
@camperbot
Jul 04 2016 00:37

:point_right: freecodecamp disable code autorun [wiki]

Disable Code Auto Run on Free Code Camp

By default, the Free Code Camp site automatically loads and runs your last recorded solution. If you have accidentally created an infinite loop or other irrecoverable error or simply don't trust the code, you can disable code auto-run by putting the following in your URL: run=disabled

:pencil: read more about freecodecamp disable code autorun on the FCC Wiki

ALLY
@ally0426
Jul 04 2016 00:42
got it thanks!
96street
@96street
Jul 04 2016 00:49
Any idea why pageimage isn't working here? http://codepen.io/kingdezz/pen/VjbWRK?editors=0110
(wiki challenge)
CamperBot
@camperbot
Jul 04 2016 00:49

:point_right: challenge access array data with indexes [wiki]

Challenge Access Array Data with Indexes

We can access the data inside arrays using indexes.

Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array.

For example:

var array = [1,2,3];
array[0]; //equals 1
var data = array[1];

:pencil: read more about challenge access array data with indexes on the FCC Wiki

Jonathan Doliver
@porygonj
Jul 04 2016 00:52
@llamatarianism Thanks!
CamperBot
@camperbot
Jul 04 2016 00:52
porygonj sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 887 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
shivam kumar
@shivamgpt38
Jul 04 2016 00:58

challenge - return largest num array
function largestNum(arrNum){
var largestNum=0;
for(x=o;x<arrNum.length;x++){ if(arrNum[x] > largestNum){
largestNum=arrNum[x];
}
}
return largestNum;
}

function largestOfFour(arr) {
// You can do this!
var largestNumArr=[];

for(i=0;i<arr.length;i++){ var arri=arr[i]; for(j=0;j>arri.length;j++){
var funArr=arri[j];
var num=largestNum(funArr);
largestNumArr.push(num);
}
}
return largestNumArr;
}

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

why largestNumArr have nothing inside after program execution?

llamatarianism
@llamatarianism
Jul 04 2016 01:02
because it's a local variable that only exists inside that function
oh wait I get what you mean
sorry I misunderstood
j=0;j>arri.length;j++
this is your problem
it should be j < arr[i].length
not j > arri.length
shivam kumar
@shivamgpt38
Jul 04 2016 01:04
okay @llamatarianism
i changed the code

function largestNum(arrNum){
var largestNum=0;
for(var x=o;x<arrNum.length;x++){ if(arrNum[x] > largestNum){
largestNum=arrNum[x];
}
}
return largestNum;
}

function largestOfFour(arr) {
// You can do this!
var largestNumArr=[];

for(var i=0;i<arr.length;i++){
var arri=arr[i];
var num = largestNum(arri);
largestNumArr.push(num);
}
return largestNumArr;
}

llamatarianism
@llamatarianism
Jul 04 2016 01:05
var x=o
o is undefined
I think you want the number 0
shivam kumar
@shivamgpt38
Jul 04 2016 01:05
yes
how can i do that?
llamatarianism
@llamatarianism
Jul 04 2016 01:06
just change it?
var x = 0
shivam kumar
@shivamgpt38
Jul 04 2016 01:06
lol :smile:
i get it
i am so dumb :shipit:
thanks @llamatarianism
CamperBot
@camperbot
Jul 04 2016 01:07
shivamgpt38 sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:cookie: 888 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
Galen Crofut
@Owl-Exterminator
Jul 04 2016 01:17
Hello, all! I'm doing a challenge, and finished writing my code in an online code visualizer and everything checks out. However, I get an error when I run it on fCC. What is the problem here?
Also, should I just paste the link to the challenge or is there another way to share it?
Dylan
@dhcodes
Jul 04 2016 01:18
@Owl-Exterminator just give the name of the challenge and then post your code between two sets of ```
that's three backticks
Galen Crofut
@Owl-Exterminator
Jul 04 2016 01:19
Smallest common multiple
function smallestCommons(arr) {
  var min = Math.min(arr[0], arr[1]);
  var max = Math.max(arr[0], arr[1]);
  var numRange = [];
  for (var i = min; i <= max; i++) {numRange.push(i);}
  numRange = numRange.reverse();


  var quot = 0;
  var loop = 1;
  var n;

  do {
    quot = numRange[0] * loop * numRange[1];
    for (n = 2; n < numRange.length; n++) {
      if (quot % numRange[n] !== 0) {
        break;
      }
    }

    loop++;
  } while (n !== numRange.length);

  return quot;
}


smallestCommons([1,5]);
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 01:21

On "Map the Debris"... I am pretty confused as to what formula I am supposed to use.

I am given everything to find the period except the semi-major axis. I am instead given an average and radius of the Earth. From this I can say that the Earth's radius would be a minimum for the semi-minor axis (which would actually end up in a collision so I assume this isn't correct). If I assume it reaches the minimum and it is an elliptical orbit than the max would be 2x the distance from minimum to average. This supposedly would give me a maximum to use as the semi-major axis distance.

Long story short, this doesn't give the answer it's expecting and I don't see anything indicating how to get from the information I am given to what is needed (including the wiki article). Short of cheating and just giving the answers it is looking for for the given input... can someone point me in the right direction?

ALLY
@ally0426
Jul 04 2016 01:22
another question: why this should be -target.length instead of -str.length below?

function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str.substr(-target.length) === target;
}

confirmEnding("Bastian", "n");

llamatarianism
@llamatarianism
Jul 04 2016 01:25
because -str.length would be the entire string
you only want the end of the string
ALLY
@ally0426
Jul 04 2016 01:27
target doesn't mean "n" the second attribute?
and "Bastian" is str?
Moisés Man
@moigithub
Jul 04 2016 01:31
"bastian".length is 7
"n".length is 1
how many characters u need to pick.. from "Bastian" to compare vs "n" ?
ALLY
@ally0426
Jul 04 2016 01:33
got it thanks all~~
Sorry, but how can I send brownie points?
I'm very new btw :)
Dylan
@dhcodes
Jul 04 2016 01:37
@ally0426 you say "thanks" and then mention someone with "@"
minus all the quotes
ex. thanks @ally0426
CamperBot
@camperbot
Jul 04 2016 01:37
dhcodes sends brownie points to @ally0426 :sparkles: :thumbsup: :sparkles:
:cookie: 288 | @ally0426 |http://www.freecodecamp.com/ally0426
ALLY
@ally0426
Jul 04 2016 01:37
ok, thanks @dhcodes
CamperBot
@camperbot
Jul 04 2016 01:37
ally0426 sends brownie points to @dhcodes :sparkles: :thumbsup: :sparkles:
:star2: 1160 | @dhcodes |http://www.freecodecamp.com/dhcodes
Dylan
@dhcodes
Jul 04 2016 01:39
bingo
96street
@96street
Jul 04 2016 01:39
Need help with wikipedia viewer http://codepen.io/kingdezz/pen/VjbWRK?editors=0110 pageimage isn't working
Phillip
@phillipjg
Jul 04 2016 01:45
I'm working on the factorialize a number algorithm. Is there a more elegant solution for the factorial of 0 being 1, than to say if num is 0, the factorial is 1?
Heather Kusmierz
@HKuz
Jul 04 2016 01:47
@phillipjg I don't think so - that's just a convention anyway, so it's okay to have that explicitly written out in your code
Phillip
@phillipjg
Jul 04 2016 01:47
@HKuz okay, thanks. That's reassuring.
CamperBot
@camperbot
Jul 04 2016 01:47
phillipjg sends brownie points to @hkuz :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @hkuz |http://www.freecodecamp.com/hkuz
Heather Kusmierz
@HKuz
Jul 04 2016 01:48
@phillipjg no problem, cheers
Brooke Ann S.
@tinyinkling
Jul 04 2016 01:49
I can't figure out what the matter is with this code:

var answer = prompt("What is the best programming language?");

if (answer === 'JavaScript'); {
alert("You are correct");
}
else {
alert("JavaScript is the best language!");
}

Greg Duncan
@GregatGit
Jul 04 2016 01:49
@96street you need to figure out how to link the image url
shivam kumar
@shivamgpt38
Jul 04 2016 01:51
hey guys how to print the output without using return() so the program do not stop?
Heather Kusmierz
@HKuz
Jul 04 2016 01:51
@tinyinkling looks like you've got an extra semi colon after the if ()
Kranthi2100
@Kranthi2100
Jul 04 2016 01:51
@tinyinkling 3 line if (answer === 'JavaScript'){---}
Brooke Ann S.
@tinyinkling
Jul 04 2016 01:51
aha! Thanks @HKuz!
96street
@96street
Jul 04 2016 01:52
@GregatGit the object (pageimage) only takes one argument which is the URL
oh wait youre right
Heather Kusmierz
@HKuz
Jul 04 2016 01:52
@tinyinkling No problem!
Greg Duncan
@GregatGit
Jul 04 2016 01:53
@96street open up your console debugger and I can show you where to find the image
@96street shft control i
96street
@96street
Jul 04 2016 01:54
yep im on console now
isnt it just: https://commons.wikimedia.org/wiki/File: + pageimage
?
Samuel Fitzsimmons
@samfitz1
Jul 04 2016 01:54

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

  switch (val) {
    case 1:
      return "alpha";
      break;

    case 2:
     return "beta";
      break;

    case 3:
     return "gamma";
      break;

    case 4:
     return "delta";
      break;
  }

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

// Change this value to test
caseInSwitch(1);
hey guys, I'm not sure what to do instead of return here
Greg Duncan
@GregatGit
Jul 04 2016 01:55
@96street I'll check
Samuel Fitzsimmons
@samfitz1
Jul 04 2016 01:55
it says its right, but I get an error message
I know return automatically jumps out of the function
Diego Mayer
@Chrono79
Jul 04 2016 01:56
@samfitz1 change answer value inside your switch instead of using return
Samuel Fitzsimmons
@samfitz1
Jul 04 2016 01:56
how would that look in code?
Diego Mayer
@Chrono79
Jul 04 2016 01:56
answer = "alpha"; and so on
Samuel Fitzsimmons
@samfitz1
Jul 04 2016 01:56
ahhhhh
thanks!
Greg Duncan
@GregatGit
Jul 04 2016 02:00
@96street i think that is a url for the image's page - not the actual image
Dylan
@dhcodes
Jul 04 2016 02:01
@96street i've been messing with it and haven't found the right url yet
still looking
@96street found it
well one way
96street
@96street
Jul 04 2016 02:04
Where did you find it?
Dylan
@dhcodes
Jul 04 2016 02:04
change your img src line to: "<img src='" + pages[page].thumbnail.source + "'";
well, and close it
lol
whoops
96street
@96street
Jul 04 2016 02:05
Nah that's thumbnail
Dylan
@dhcodes
Jul 04 2016 02:05
yeah, but i think that might be the best you can get
96street
@96street
Jul 04 2016 02:06
Maybe so
The thumbnail is tiny though so it's really blurry when stretched
Dylan
@dhcodes
Jul 04 2016 02:07
@96street i'll keep messing a bit
96street
@96street
Jul 04 2016 02:08
Should be fine i'll just make the img smaller
Dylan
@dhcodes
Jul 04 2016 02:11
@96street according to one stack post I found, to get the full image, you'd need a separate call to: https://en.wikipedia.org/w/api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 02:11
Any thoughts on the "Map the debris" challenge I asked about earlier?
Dylan
@dhcodes
Jul 04 2016 02:11
or maybe make that your main call
idk
Greg Duncan
@GregatGit
Jul 04 2016 02:18
@96street
if(pages[page].pageimage) {
        var myUrl = pages[page].thumbnail.source;
        myUrl = myUrl.replace("50", "300");
        pic = "<img src='" + myUrl + "'>";
JJ
@MissJJAus
Jul 04 2016 02:19

Hey Can anybody tell me why this function doesn't return "pony"?// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
if (myObj.hasOwnProperty(checkProp)) {
return myObj.checkProp;
}
return "Not Found";
}

// Test your code by modifying these values
checkObj("gift");

I dont know how to share my screen like other do...
Greg Duncan
@GregatGit
Jul 04 2016 02:20
@96street the thumbnail url just has to be altered by replacing 50 with 300
0-3-7
@0-3-7
Jul 04 2016 02:20

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

var fahrenheit = celsuis*9/5+32;
// Only change code above this line
return fahrenheit;
}

// Change the inputs below to test your code
convertToF(0);
How to I add/divide/multiply/etc. to the input of the function?

Dylan
@dhcodes
Jul 04 2016 02:21
@GregatGit for the win
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 02:21
@jj you should use bracket notation to return the property
Dylan
@dhcodes
Jul 04 2016 02:22
@0-3-7 remove var from your equation
they already define var
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 02:22
it is returning undefined because myObject.checkProp is undefined
Dylan
@dhcodes
Jul 04 2016 02:22
@0-3-7 and you spelled celsius wrong
JJ
@MissJJAus
Jul 04 2016 02:22
@Goblinlordx Thanks man!!
CamperBot
@camperbot
Jul 04 2016 02:22
missjjaus sends brownie points to @goblinlordx :sparkles: :thumbsup: :sparkles:
:cookie: 173 | @goblinlordx |http://www.freecodecamp.com/goblinlordx
Greg Duncan
@GregatGit
Jul 04 2016 02:22
@96street In fact you can replace it with any amount
96street
@96street
Jul 04 2016 02:23
@GregatGit ahh yep i'll change that now
much better, thanks @GregatGit
CamperBot
@camperbot
Jul 04 2016 02:25
96street sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 650 | @gregatgit |http://www.freecodecamp.com/gregatgit
Greg Duncan
@GregatGit
Jul 04 2016 02:26
@96street :+1:
96street
@96street
Jul 04 2016 02:27
when my title (h2) is short, <p> moves to the same line and screws up the format, any idea why?
Wali Gauvin
@Docwali777
Jul 04 2016 02:43
NEED Help....... I do not understand the instructions for FCC- stand in Line

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

jbeaumont1010
@jbeaumont1010
Jul 04 2016 02:47
Hey, Team, having trouble with the Using Objects for Lookups problem. Could someone guide me towards the light?

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

// Only change code below this line

result = {

"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"

};

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

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

ryt11
@ryt11
Jul 04 2016 02:49
@Wali They want you to make use of the .push, and .shift functions. .push will add an item to the end of an array and .shift removes the first element of an array.
Wali Gauvin
@Docwali777
Jul 04 2016 02:52
@96street
Pavan Kulkarni
@pavankrcr
Jul 04 2016 02:53
var sum=0;
// console.log(process.argv.length);
var num=(process.argv[process.argv.length-1].split(","));
// console.log(num[0]);
// console.log(num.length);
for (var i=0;i<num.length;i++) {
     sum=sum+Number(num[i]);
   //  console.log(num[i]);
}
 console.log(sum);
please help learnyounode rejecting my code
ryt11
@ryt11
Jul 04 2016 02:54
@jbeaumont1010 Look at what you're returning, and pay attention to the arguments your function takes. You need to return the value that is passed to the function as it is associated with your Object. Remember you can do that like this Object[value].
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 03:02
Still looking for help with "Map the Debris" challenge if anyone is around that can help
Joseph
@revisualize
Jul 04 2016 03:15
Hello.
@jbeaumont1010 Look at the instructions. The object is supposed to be called lookup
@Docwali777 What do the instructions state?
@Docwali777
// Write a function nextInLine which takes 
// an array (arr) and a number (item) as arguments.
function nextInLine(arr, item) {
    // 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.
    return item; // Change this line
}
@Docwali777 How do you add a "number" (item) to the end of an array (arr)?
@Docwali777 How do you remove the first element from an array (arr)?
Om Carrasquillo
@oc2215
Jul 04 2016 03:19
Is it a bug? Or is it my syntax? Can anyone help?

function trueOrFalse(wasThatTrue) {

// Only change code below this line.
if (wasThatTrue) {
return "yes, that was true";
}
return "No, that was false";

// Only change code above this line.

}

// Change this value to test
trueOrFalse(true);

jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:20
I feel like I;m really close
var lookup = {
val:result = "Adams",
val:result = "Boston",
val:result = "Chicago",
val:result = "Denver",
val:result = "Easy",
val:result = "Frank"
};
I know the keys need to be unique...
But I don't know how to make them as such.
jeanelleyy
@jeanelleyy
Jul 04 2016 03:21
@oc2215 maybe you have to set the if condition to 'wasThatTrue === true '
@jbeaumont1010 what happened to the alpha, beta, gamma keys?
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:24
Is that in another exercise?
I'm coming back after a bit of a break, hence the cannot figure this out part.
jeanelleyy
@jeanelleyy
Jul 04 2016 03:25

```function phoneticLookup(val) {
var result = "";

// Only change code below this line

result = {

"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"

};

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

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

@jbeaumont1010 was this your old code?
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:30
var lookup = {
"alpha":result = "Adams",
"bravo":result = "Boston",
"charlie":result = "Chicago",
"delta":result = "Denver",
"echo":result = "Easy",
"foxtrot":result = "Frank"
};
But now I don't have val being passed in lol
jeanelleyy
@jeanelleyy
Jul 04 2016 03:32
```
"alpha":"Adams",
"bravo":"Boston",
"charlie":"Chicago",
"delta":"Denver",
"echo":"Easy",
"foxtrot":"Frank"
@jbeaumont1010 that should be in your lookup variable
then you set result as what you get what you put val as a key in your lookup table. so you need to put 'result=lookup[val];' under your lookup variable
CruftMaster
@CruftMaster
Jul 04 2016 03:34
can sum1 help me with an algorithm? its the "wherefore art thou" one in the javascript section. im having trouble accessing the value of source

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
var num = 0;
var source_arr = Object.keys(source);
// Only change code below this line
for(i=0;i<collection.length;i++){
for(j=0;j<source_arr.length;j++){
if(collection[i].hasOwnProperty(source_arr[j])){

 arr.push(collection[i]);
  }
}

}
var array = arr.filter(function(element,index,array){
return(element = source);

});
// Only change code above this line
return array;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null}, { first: "Tybalt", last: "Capulet" }], { last:"Montague"});

ryt11
@ryt11
Jul 04 2016 03:35
@jbeaumont1010 lookup is your object which contains the properties/values, for instance "alpha", alpha's key is "Adams". In the exercise they want you to return the key of whatever value/property (val) is passed to the function. As @jeanelley had posted this is done by either assigning lookup[val] to a variable or just returning lookup[val]. That way everytime the function is passed a value it will look in the "lookup" object and find the value it was passed, and then return the key of that value.
bitgrower
@bitgrower
Jul 04 2016 03:36
@CruftMaster can you please post your code with formatting ? thanks! (Makes it MUCH easier for us to help you) ...
CamperBot
@camperbot
Jul 04 2016 03:36
bitgrower sends brownie points to @cruftmaster :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for cruftmaster
bitgrower
@bitgrower
Jul 04 2016 03:36
help format
CamperBot
@camperbot
Jul 04 2016 03:36

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:37
@jeanelleyy Thank you very much. I feel like this one is sligtly misleading because it says not to modify code below that comment and you need to modify result for that to happen
CamperBot
@camperbot
Jul 04 2016 03:37
jbeaumont1010 sends brownie points to @jeanelleyy :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @jeanelleyy |http://www.freecodecamp.com/jeanelleyy
jeanelleyy
@jeanelleyy
Jul 04 2016 03:37
@ryt11 thanks. that's a better way of explaining it lol
CamperBot
@camperbot
Jul 04 2016 03:37
jeanelleyy sends brownie points to @ryt11 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ryt11
jeanelleyy
@jeanelleyy
Jul 04 2016 03:38
@jbeaumont1010 yeah i was confused on that one too. glad it worked out for you
bitgrower
@bitgrower
Jul 04 2016 03:39
@jbeaumont1010 it may have a different name for the function in my solution, but you can find my solution which doesn't require changing any parts outside of the area which they say to change ... just go here freecodecamp.com/bitgrower ... look up the problem and click on "view solution" ...
CruftMaster
@CruftMaster
Jul 04 2016 03:40
This message was deleted
CamperBot
@camperbot
Jul 04 2016 03:40
:bulb: to format code use backticks! ``` more info
bitgrower
@bitgrower
Jul 04 2016 03:41
note that this works for most campers' solutions -- if they have one, and have not intentionally blocked them from view (which few do) ... you can see a particular camper's solution for a particular challenge (if they've solved it)
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:41
Ahh! Thanks @bitgrower I tend to not want to take extra steps, which is what they seemed to want me to do for educational purposes.
CamperBot
@camperbot
Jul 04 2016 03:41
jbeaumont1010 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1128 | @bitgrower |http://www.freecodecamp.com/bitgrower
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:41
Thanks again all
@ryt11 Thanks as well for BP
CamperBot
@camperbot
Jul 04 2016 03:41
jbeaumont1010 sends brownie points to @ryt11 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ryt11
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:42
Do Brownie Points mean anything? lol
bitgrower
@bitgrower
Jul 04 2016 03:42
well -- I don't recall all the steps needed, but I'm sure that any steps designed for you to go thru in the challenge are intended for educational purposes ...
ryt11
@ryt11
Jul 04 2016 03:42
not much..1 brownie point = 10 british pounds
bitgrower
@bitgrower
Jul 04 2016 03:42
LOL @ryt11
do warm fuzzies 'mean' anything .. ?
Wali Gauvin
@Docwali777
Jul 04 2016 03:43
FCC- stand in line - need help....

function nextInLine(arr, item) {
arr.push(item); // Your code here
item = testArr.shift();
return arr.shift(); // Change this line
}

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

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

bitgrower
@bitgrower
Jul 04 2016 03:44
@Docwali777 -- if you have not reviewed the preceding 4 challenges covering the array functions push, pop, shift & unshift, do so ... you only need 2 of them to solve stand in line ...
Wali Gauvin
@Docwali777
Jul 04 2016 03:44
@bitgrower i did.... My brain is not gras[ing the concepts for this code...
bitgrower
@bitgrower
Jul 04 2016 03:45
how long have you been working on it ?
ryt11
@ryt11
Jul 04 2016 03:45
if the bottom block of code is confusing you, ignore that.. that won't have anything to do with your solution
96street
@96street
Jul 04 2016 03:46
think i'm finished with wiki viewer http://codepen.io/kingdezz/full/VjbWRK/
bitgrower
@bitgrower
Jul 04 2016 03:46
good point, @ryt11 -- @Docwali777 it can be done, no fancy tricks, in 3 simple lines of code. with a very slight optimization, it can be done in 2
whoohoo, @ @96street
96street
@96street
Jul 04 2016 03:46
:)
Sam
@alakasam
Jul 04 2016 03:47
Hi, for the code below, why was counter included after the names array? I've never seen a variable have two values
function(console) {
    var names = ["Ben", "Jafar", "Matt", "Priya", "Brian"],
        counter;

    for(counter = 0; counter < names.length; counter++) {
        console.log(names[counter]);
    }
}
Wali Gauvin
@Docwali777
Jul 04 2016 03:49
@bitgrower i have been on this code and the previous 5-10 codes for the past 40 minutes..
jbeaumont1010
@jbeaumont1010
Jul 04 2016 03:49
"Like JavaScript Objects, JSON is flexible because it is heterogeneous, meaning it permits Data Structures with arbitrary combinations of strings, booleans, numbers, arrays, and objects."
So homogeneous, can only have a certain type within it? like string
Wali Gauvin
@Docwali777
Jul 04 2016 03:50
@96street - working on this code stand in line for thecpast 40min
@ryt11 - are you working on - Stand in
bitgrower
@bitgrower
Jul 04 2016 03:50
@alakasam they are not giving the value counter 2 values ...
96street
@96street
Jul 04 2016 03:51
you're doing viewer aswell? @Docwali777
Sam
@alakasam
Jul 04 2016 03:51
wow misread the code my bad @bitgrower
bitgrower
@bitgrower
Jul 04 2016 03:52
happens, @alakasam -- not infrequently ... re-reading is a necessary part of the job ... whether reading code, the instructions, what's wanted, etc ...
Luis Felipe López G.
@luishendrix92
Jul 04 2016 03:52
@alakasam Declaring a counter variable outside the loop isn't probabl the most useful thing ever, I've seen people declare the length of the array inside the first statement group of a for loop but that's about it.
Actually, what that code snippet proposes is what happens "behind the scenes" after hoisting takes effect.
Wali Gauvin
@Docwali777
Jul 04 2016 03:53
@96street ??viewer?
Luis Felipe López G.
@luishendrix92
Jul 04 2016 03:53
Whenever you declare a variable, the declaration is hoisted to the top of the nearest scope and the assignment takes place where you declared it.
ryt11
@ryt11
Jul 04 2016 03:56
@Wali No, but I can help you.
They are asking you to add to your "arr" argument of your function which is an array, whatever the value for "item" is that was passed to your function.
remember you can use .push() to do this
so to do something like it would look like arr.push(item);
Wali Gauvin
@Docwali777
Jul 04 2016 03:59
@ryt11 - i have stuck on this code -stand in line for the padt hour.....
ryt11
@ryt11
Jul 04 2016 03:59
I will show you my solution although it's probably not the most elegant, and explain what it is doing.
Wali Gauvin
@Docwali777
Jul 04 2016 04:01
@ryt11 that would be great....
ryt11
@ryt11
Jul 04 2016 04:02

function nextInLine(arr, item) {
arr.push(item);
var eleRemoved = arr0;
arr.shift();
// Your code here

return eleRemoved; // 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));

Don't know how to format it correctly but
so first line is arr.push(item); this is taking the item argument and pushing it (adding it) to our arr argument which would be an array.
this adds item to the end of array
so if our array was [1,2,3,4,5] initially and we pushed the value of 6 our new array would be [1,2,3,4,5,6]
Next thing I did was set a variable = to the 0th element of the array which would be the 1st item because we know when you use the .shift() function it removes the first element in the array.
so if we had an array that was ourArr = [1,2,3,4,5] and we set a variable to ourArr[0] it would equal 1, or the first element of the array
Last part which I already mentioned we are calling shift on the array which will remove the first element of the array, and then at the bottom we are returning eleRemoved which is the variable that held the value of our 0th element before we used .shift to remove it.
Wali Gauvin
@Docwali777
Jul 04 2016 04:08
@ryt11 i am reading your explanation thanks for your insight...
CamperBot
@camperbot
Jul 04 2016 04:08
docwali777 sends brownie points to @ryt11 :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for ryt11
ryt11
@ryt11
Jul 04 2016 04:09
For some reason it did not format the 3rd line correctly it should be "var eleRemoved = arr[0];"
runningCoder81
@runningCoder81
Jul 04 2016 04:11
Hey guys, I'm a bit stuck.
kuldeep
@gurukd
Jul 04 2016 04:11
@Docwali777 it may help you.
runningCoder81
@runningCoder81
Jul 04 2016 04:11
Working on the Record Collection problem.
kuldeep
@gurukd
Jul 04 2016 04:11

function nextInLine(arr, item) {
// Your code here
arr.push(item);
var removeVal = arr.shift();
return removeVal; // 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));

Wali Gauvin
@Docwali777
Jul 04 2016 04:12
@ryt11 -- i do not know how i got this but....
Greg Duncan
@GregatGit
Jul 04 2016 04:12
@Docwali777 @ryt11 var eleRemoved = arr.shift(); you can remove and assign on the same line
Wali Gauvin
@Docwali777
Jul 04 2016 04:13
@ryt11 ------- function nextInLine(arr, item) {
arr.push(item);
return arr.shift(); // Change this line
ryt11
@ryt11
Jul 04 2016 04:14
Thanks @GregatGit that's a much better way of doing it.
CamperBot
@camperbot
Jul 04 2016 04:14
ryt11 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 651 | @gregatgit |http://www.freecodecamp.com/gregatgit
ryt11
@ryt11
Jul 04 2016 04:15
@Wali that is a correct solution as well, we don't even have to assign arr.shift(); to a new variable you can just return the value of it as well
RAJESH KUMAR
@raz281389
Jul 04 2016 04:15

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

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

Wali Gauvin
@Docwali777
Jul 04 2016 04:15
@GregatGit --- this one perplexed.... I think my brain needs to rest.... @ryt11
Greg Duncan
@GregatGit
Jul 04 2016 04:16
@Docwali777 :+1:
RAJESH KUMAR
@raz281389
Jul 04 2016 04:17
var Car = function(wheels,seats,engines) {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var testCar = new Car (3, 1, 2);
kuldeep
@gurukd
Jul 04 2016 04:17
This message was deleted
Greg Duncan
@GregatGit
Jul 04 2016 04:19
@gurukd you need to format it correctly ``` on a seperate line both before and after your code to make it easy to read
kuldeep
@gurukd
Jul 04 2016 04:23
@GregatGit I'll do that. Can you help me the code, the way it is now is not appropriate. As i want to iterate the keys but i want all keys in one cabin so that when i compare with given object array, it will show that keys which are in Object array.
Greg Duncan
@GregatGit
Jul 04 2016 04:24
@gurukd I'll look - but first hit the edit and format the code so its easy to read
@raz281389 this.wheels = wheels;
RAJESH KUMAR
@raz281389
Jul 04 2016 04:28
THANKS @GregatGit
CamperBot
@camperbot
Jul 04 2016 04:28
raz281389 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
:cookie: 652 | @gregatgit |http://www.freecodecamp.com/gregatgit
kuldeep
@gurukd
Jul 04 2016 04:28

@GregatGit Is it alright now?

function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];

// Only change code below this line

var keys = Object.keys(source);

console.log(keys.length);

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

if(keys.length<=1){

 if(collection[i].hasOwnProperty(keys) && collection[i][keys]=== source[keys]){
   arr.push(collection[i]);
}

}
if(keys.length>1){
if(collection[i].hasOwnProperty(keys[0]&&keys[1])){
arr.push(collection[i]);
}
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Benjamin Baldivia
@Goblinlordx
Jul 04 2016 04:29
Still looking for help with "Map the Debris" challenge if anyone is around that can help
:point_up: July 4, 2016 10:21 AM
Greg Duncan
@GregatGit
Jul 04 2016 04:29
@gurukd no - still bad
@gurukd
// What's in a name?
var arr = [];
// Only change code below this line
var keys = Object.keys(source);
console.log(keys.length);
for(var i=0; i<collection.length; i++){
if(keys.length<=1){
 if(collection[i].hasOwnProperty(keys) && collection[i][keys]=== source[keys]){
   arr.push(collection[i]);
}
}
if(keys.length>1){
  if(collection[i].hasOwnProperty(keys[0]&&keys[1]  )){
arr.push(collection[i]);
}
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Bryan Raynor
@bryanraynor
Jul 04 2016 04:32
Has anyone recently done the Caesars Cipher challenge recently? Out of curiosity, how long did it take to solve?
Luis Felipe López G.
@luishendrix92
Jul 04 2016 04:34
@bryanraynor Not much, the hardest part was looking at the ascii code table to figure out if I needed to substract or add 13.
About 1 hr
CamperBot
@camperbot
Jul 04 2016 04:34
you need to ask about @someone!
Luis Felipe López G.
@luishendrix92
Jul 04 2016 04:34
With pauses and distractions
Bryan Raynor
@bryanraynor
Jul 04 2016 04:35
cool, thanks for the info. I didn't even think about the adding/subtracting part.
Chipi
@Chipsta
Jul 04 2016 04:52
hey guys im having trouble getting started on the record collection challenge

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

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

return collection;
}

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

im not sure where to start

Write a function which takes an id, a property (prop), and a value.

For the given id in collection:

If prop does not contain the key "tracks", then update or set the value for that incomplete prop.

If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.

If prop does contain the key "tracks" and its value is non-blank, then push the value onto the end of its existing tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

runningCoder81
@runningCoder81
Jul 04 2016 04:54
@Chipsta I am in the same spot, having a hard time starting.
Chipi
@Chipsta
Jul 04 2016 04:55
not sure if i quite understand the directions either
runningCoder81
@runningCoder81
Jul 04 2016 04:55
Yes, I've been trying different things out for awhile.
Chipi
@Chipsta
Jul 04 2016 04:56
kinda confusing to say the least and im not quite sure i can relate what this challenge is asking to the waypoints that i went over so far
Jaenu1
@Jaenu1
Jul 04 2016 04:56
Does any one how can i transfer a file using ajax
Markus Kiili
@Masd925
Jul 04 2016 04:58
@Chipsta There is an error on one direction.
Bryan Raynor
@bryanraynor
Jul 04 2016 04:59
which direction?
runningCoder81
@runningCoder81
Jul 04 2016 04:59
@Masd925 What is this error you speak of?
@Masd925 I am on the same problem.
Markus Kiili
@Masd925
Jul 04 2016 05:00
@runningCoder81 If prop does not contain the key "tracks", then update or set the value for that incomplete prop. It should talk about record having key "tracks".
Maybe not an error but confusing at least.
runningCoder81
@runningCoder81
Jul 04 2016 05:01
@Masd925 So confusing, I am having trouble getting started.
Bryan Raynor
@bryanraynor
Jul 04 2016 05:01
it is confusing. It is worth noting that the directions right under it tell you how, in gobblygook.
Chipi
@Chipsta
Jul 04 2016 05:01
lol
Bryan Raynor
@bryanraynor
Jul 04 2016 05:01
@runningCoder81 start with the simplest one, if the value is blank, delete it.
Markus Kiili
@Masd925
Jul 04 2016 05:01
@runningCoder81 Test user input value and prop and then access collection on if blocks.
Joseph
@revisualize
Jul 04 2016 05:01

Record Collection

You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.

Write a function which takes an album's id (like 2548), a property prop (like "artist" or "tracks"), and a value (like "Addicted to Love") to modify the data in this collection.

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

Your function must always return the entire collection object.

There are several rules for handling incomplete data:

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 is "tracks" and value isn't blank, push the value onto the end of the album's existing tracks array.

If value is blank, delete that property from the album.

runningCoder81
@runningCoder81
Jul 04 2016 05:02
@bryanraynor OK
Joseph
@revisualize
Jul 04 2016 05:02
Whoever is working on record collection should use that text for the instructions.
@Chipsta @GregatGit @gurukd
@runningCoder81 Are you working on RC as well?
Bryan Raynor
@bryanraynor
Jul 04 2016 05:03
those were the directions I used and they helped quite a bit. Thanks for putting them there @revisualize
CamperBot
@camperbot
Jul 04 2016 05:03
bryanraynor sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1368 | @revisualize |http://www.freecodecamp.com/revisualize
runningCoder81
@runningCoder81
Jul 04 2016 05:03
@revisualize yes
Joseph
@revisualize
Jul 04 2016 05:04
@runningCoder81 Those instructions above will help remove some of the ambiguity in the current instructions.
It is also good to know that Record Collection is a checkpoint that takes all the previous object lessons and tries to distill them down to one lesson.
Jake
@jnelson180
Jul 04 2016 05:08
I remember major headacheage when I started Record Collection. It'll be a great feeling when you beat the challenge though!
Anyone done "Validate US Telephone Numbers" yet?
Bryan Raynor
@bryanraynor
Jul 04 2016 05:09
I'll pass on one last tip I got from another camper last name. There is a way to use .hasOwnProperty() in this challenge.
runningCoder81
@runningCoder81
Jul 04 2016 05:09
@bryanraynor Got that one!! woo hoo
Bryan Raynor
@bryanraynor
Jul 04 2016 05:09
@jnelson180 I've done validation of US numbers in C#, haven't reached that in JavaScript yet.
runningCoder81
@runningCoder81
Jul 04 2016 05:10
@bryanraynor yes I've been using .hasOwnProperty() so many ways with no luck. but just did the delete one.
Bryan Raynor
@bryanraynor
Jul 04 2016 05:10
@runningCoder81 there you go. Thats one requirement met.
I recommend when you complete this challenge, that you write down your final code. Take the time to look back at it periodically and you will retain it better.
btw, I just got done with Caesars Cipher. It's time for a drink then bed.
runningCoder81
@runningCoder81
Jul 04 2016 05:12
@bryanraynor @revisualize Thanks!!
CamperBot
@camperbot
Jul 04 2016 05:12
runningcoder81 sends brownie points to @bryanraynor and @revisualize :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @bryanraynor |http://www.freecodecamp.com/bryanraynor
:star2: 1369 | @revisualize |http://www.freecodecamp.com/revisualize
runningCoder81
@runningCoder81
Jul 04 2016 05:13
@bryanraynor Thanks!!
CamperBot
@camperbot
Jul 04 2016 05:13
:warning: runningcoder81 already gave bryanraynor points
runningcoder81 sends brownie points to @bryanraynor :sparkles: :thumbsup: :sparkles:
Indhu
@Indhusethu
Jul 04 2016 05:15
can anyone help me with objects for lookups lesson?

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

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

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

Markus Kiili
@Masd925
Jul 04 2016 05:18
@Indhusethu Use syntax obj[key] to access object property, and assign it to result. What is the object and where lurks the key?
So one line of code is enough.
Indhu
@Indhusethu
Jul 04 2016 05:19
ok!! @Masd925
result["bravo"];
result["delta"];
var value="bravo";
result[value];
am i right now? @Masd925
Markus Kiili
@Masd925
Jul 04 2016 05:21
@Indhusethu No. You should access lookup object with key stored in parameter val.
Magnus Holm
@mghlm
Jul 04 2016 05:21
var names = ["Magnus", "Grethe", "Jens", "Julie", "Henning"];

for (var i=0; i < names.length; i++) {
    console.log("I know someone called " names[i] );
}
Why does it say “missing ) after argument list” ??
Markus Kiili
@Masd925
Jul 04 2016 05:21
val holds the key passed into the function.
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 05:21
Still looking for help with "Map the Debris" challenge if anyone is around that can help
:point_up: July 4, 2016 10:21 AM
Shubham Negi
@shubham-negi
Jul 04 2016 05:22
you can use either square brackets and dot operator, dot operators will not work when you have number as property.
Indhu
@Indhusethu
Jul 04 2016 05:22
ohh :worried: @Masd925
kuldeep
@gurukd
Jul 04 2016 05:23
@Indhusethu do this.
var result = val;
and return lookup object by passing the result in to using bracket notation.
Indhu
@Indhusethu
Jul 04 2016 05:24
ok @gurukd
first i need to create lookup object..isn't it?
V Arun Kumar
@arunvkumr
Jul 04 2016 05:26
@m4gnusholm in console.log you are not conatenating so thats why the error.. add + between string and names array
kuldeep
@gurukd
Jul 04 2016 05:26
@Indhusethu yes and make sure its in double quotes.
Magnus Holm
@mghlm
Jul 04 2016 05:26
@arunkumrv ohh, yes that worked. thank you
CamperBot
@camperbot
Jul 04 2016 05:26
m4gnusholm sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 569 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
Indhu
@Indhusethu
Jul 04 2016 05:27
ok @gurukd
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:29
anyone done with escape sequences in strings? need some help
V Arun Kumar
@arunvkumr
Jul 04 2016 05:30
@rohogaka share your code.. let's have a look what you have got.
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:30
blob
trying to escape a backslash and new line and tab tab @arunkumrv
V Arun Kumar
@arunvkumr
Jul 04 2016 05:34
@rohogaka remove spaces before \n and after \t. that should work
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:34
no luck
V Arun Kumar
@arunvkumr
Jul 04 2016 05:34
@rohogaka post the code again with chages you did.. use formatting to post.
wiki format
CamperBot
@camperbot
Jul 04 2016 05:35

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Rohit Gaikwad
@rohogaka
Jul 04 2016 05:36
This message was deleted
V Arun Kumar
@arunvkumr
Jul 04 2016 05:42
@rohogaka
press "```js" then press [shift+enter] then post your code and at the end if you don't see "```" then add that in new line.
it would be like..
Like this
```js
//code
```(in new line)
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:42
js var myStr; // Change this line
myStr = "Here is a backslash: \\.\n\t\tHere is a new line with the two tabs";
V Arun Kumar
@arunvkumr
Jul 04 2016 05:44
@rohogaka remove the in with (the) two tabs. and you are missing (.)dot at the end of the sentence.
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:46
@arunkumrv how would that make a difference, it did work but I didnt get the logic of that
because the console log op still shows the same thing more or less
blob
V Arun Kumar
@arunvkumr
Jul 04 2016 05:50

@rohogaka fcc wants the sentence like..

Here is a backslash: \.
(\n+\t+\t)Here is a new line with the two tabs.

and in your code you had extra spaces which were like..

Here is a backslash: \.
(space+\n+\t+\t+space)Here is a new line with the two tabs.

so it was not accepting the solution. you were printing 2 spaces extra. and missing a dot at end.

@rohogaka check this image you will see the difference..
blob @rohogaka
Rohit Gaikwad
@rohogaka
Jul 04 2016 05:55
so even if it would have rendered the same op, it dint go through cuz fcc wants it in a certain way to check all the tasks in the challenge? is that right?
V Arun Kumar
@arunvkumr
Jul 04 2016 05:57
@rohogaka no it doesn't render the same op, you can see the difference in two outputs right.. open the image i sent :point_up_2: and notice the diference at the end of the sentences, the second one ends early because it doesn't have the extra 2 spaces.
Indhu
@Indhusethu
Jul 04 2016 06:01

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){
myObj.hasOwnProperty("gift");
myObj.hasOwnProperty("bed");
return "Not Found";
}
checkObj("gift");

what mistake i've done here?/
Rohit Gaikwad
@rohogaka
Jul 04 2016 06:02
the outputs are exactly the same in the image but yes the 'console.log' line is shorter in the second one @arunkumrv
console.log
Juan Moraza
@Morazajuan
Jul 04 2016 06:03
why this isnt adding?
for(var i=0; i<arr.length; i++){
      for(var j=0; j<arr.length; j++){

       product += arr[i][j];

      }
  }
Greg Duncan
@GregatGit
Jul 04 2016 06:03
@Indhusethu myObj.hasOwnProperty(checkProp);
Markus Kiili
@Masd925
Jul 04 2016 06:04
@Indhusethu Use checkProp as the key in .hasOwnProperty() check. Not any hardcoded key string.
shweta rajput
@ShwetaRajput
Jul 04 2016 06:04
can someone help me with Title case a sentence
Markus Kiili
@Masd925
Jul 04 2016 06:04
@Indhusethu checkProp is the function parameter, so it holds the key that is passed into the function on function call.
Juan Moraza
@Morazajuan
Jul 04 2016 06:05
nvm Got it!
shweta rajput
@ShwetaRajput
Jul 04 2016 06:05
@Morazajuan return product outside for loop
V Arun Kumar
@arunvkumr
Jul 04 2016 06:05
@rohogaka take a look at this image.
blob
Rohit Gaikwad
@rohogaka
Jul 04 2016 06:06
@arunkumrv @arunkumrv yup got it, sorry im a js noob, thanks!
CamperBot
@camperbot
Jul 04 2016 06:06
rohogaka sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:cookie: 570 | @arunkumrv |http://www.freecodecamp.com/arunkumrv
shweta rajput
@ShwetaRajput
Jul 04 2016 06:06
@Morazajuan i guess this challenge is to multiply product with every elemeet of array then why are you adding it?
@Masd925 can you help me with title case a sentence?
Markus Kiili
@Masd925
Jul 04 2016 06:07
@ShwetaRajput Sure.
shweta rajput
@ShwetaRajput
Jul 04 2016 06:08
can you explain what exactly the steps i have to follow?
V Arun Kumar
@arunvkumr
Jul 04 2016 06:08
@rohogaka spaces before \n doesn't reflect in the output because \n breaks the line. but spaces after the \n which means in newline spaces does matter.
keep coding, you will get better :smile: .
Juan Moraza
@Morazajuan
Jul 04 2016 06:08
@ShwetaRajput i was just checking something. I figuered if i knew how to add,it would be easier to multiply but got it thanks!
CamperBot
@camperbot
Jul 04 2016 06:08
morazajuan sends brownie points to @shwetarajput :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for shwetarajput
Markus Kiili
@Masd925
Jul 04 2016 06:09
@ShwetaRajput One way is this. Split the string into an array of words. Loop or iterate the array. Take one word and make a new titlecased word and assign it back to the array. Join the array back to a string and return it.
You can use for loop or .map() to iterate the array.
shweta rajput
@ShwetaRajput
Jul 04 2016 06:10
@Masd925 but not entire word is to be titled how will i apply that to only first letter of a word?
Markus Kiili
@Masd925
Jul 04 2016 06:11
@ShwetaRajput You generate a new titlecased string with string operations. Use .charAt(), .slice(), .substring(), +, .toUpperCase() etc
shweta rajput
@ShwetaRajput
Jul 04 2016 06:12
@Masd925 thanks. i will try
CamperBot
@camperbot
Jul 04 2016 06:12
shwetarajput sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2027 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jul 04 2016 06:13
@ShwetaRajput Because strings are immutable, you always generate new strings from old ones.
Indhu
@Indhusethu
Jul 04 2016 06:13
thank you @Masd925
CamperBot
@camperbot
Jul 04 2016 06:13
indhusethu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2028 | @masd925 |http://www.freecodecamp.com/masd925
Indhu
@Indhusethu
Jul 04 2016 06:13
but still i'm getting an issue @Indhusethu

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){
myObj.hasOwnProperty(checkProp);
myObj.hasOwnProperty(checkProp);
return "Not Found";
}
checkObj("gift");

@Masd925
Markus Kiili
@Masd925
Jul 04 2016 06:14
@Indhusethu myObj.hasOwnProperty(checkProp) returns a boolean indicating whether the key is found in myObj. Test it with if.
Then act according to task.
Indhu
@Indhusethu
Jul 04 2016 06:15
so here i need to create a if statement within this function right??
Markus Kiili
@Masd925
Jul 04 2016 06:15
@Indhusethu Yes.
Indhu
@Indhusethu
Jul 04 2016 06:15
ok thanks @Masd925
CamperBot
@camperbot
Jul 04 2016 06:15
indhusethu sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: indhusethu already gave masd925 points
Jake
@jnelson180
Jul 04 2016 06:18
@bryanraynor Finished the Validating Telephone Numbers challenge, but man my code is long
Magnus Holm
@mghlm
Jul 04 2016 06:19
can someone help me with this please:
var text = "Magnus is coding. Magnus thinks it's hard, but also fun, so it's OK to be Magnus";
var myName = "Magnus";
var hits = [];

for (var a=0; o < text.length ; a++) {
    if (text[a] === myName[0]) {
        for (var b = a; b < a+myName.length; b++) {
            hits.push(text[b]);
        }
    }
}
I want to push the letters of my name to hits
Indhu
@Indhusethu
Jul 04 2016 06:20
function checkObj(checkProp){
myObj.hasOwnProperty(checkProp);
myObj.hasOwnProperty(checkProp);
if(checkObj=="gift"){
return "pony";
}
return "Not Found";
}
checkObj("gift");
@Masd925
This message was deleted
CamperBot
@camperbot
Jul 04 2016 06:20
no wiki entry for: me1
Magnus Holm
@mghlm
Jul 04 2016 06:20
this assignment is so hard :(
Markus Kiili
@Masd925
Jul 04 2016 06:20
@Indhusethu if(myObj.hasOwnProperty(checkProp)){...}
Indhu
@Indhusethu
Jul 04 2016 06:21
oh kk @Masd925
DJ
@qualitymanifest
Jul 04 2016 06:21
@jnelson180 no worries, at least you did it. it can be done in one line - here's the pseudocode i put above mine to explain it : "Allow a 1 and a space, then area code with BOTH parens or NO parens, then allow a space/dash, three more numbers, allow another space/dash, then the last four numbers. Nothing before or after"
Markus Kiili
@Masd925
Jul 04 2016 06:22
@m4gnusholm o < text.length what is o here?
shweta rajput
@ShwetaRajput
Jul 04 2016 06:22
@Masd925 ```
Magnus Holm
@mghlm
Jul 04 2016 06:22
@Masd925 shit, that’s supposed to be an a
@Masd925 embarrasing, thank you!
CamperBot
@camperbot
Jul 04 2016 06:22
m4gnusholm sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2029 | @masd925 |http://www.freecodecamp.com/masd925
Jake
@jnelson180
Jul 04 2016 06:22
@qualitymanifest I guess mine would be a bit shorter anyway if I took out all the console.logs
shweta rajput
@ShwetaRajput
Jul 04 2016 06:23

function titleCase(str) {
var a=str.split(" ");
  var b=a.map(function(val){
  return val.replace(val.charAt(0),val.charAt(0).toUpperCase());

              });

  }

titleCase("I'm a little tea pot");
@Masd925 this is my code
not working.
Indhu
@Indhusethu
Jul 04 2016 06:23
This message was deleted

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){
myObj.hasOwnProperty(checkProp);
myObj.hasOwnProperty(checkProp);
if(myObj.hasOwnProperty(checkProp)){
return "Found";
}
return "Not Found";
}
checkObj("gift");

Markus Kiili
@Masd925
Jul 04 2016 06:24
@ShwetaRajput Don't use .replace(). Better to just do: return val.charAt(0).toUpperCase()+... <- rest of val here lowercased.
michael dorsey
@mikedorsey1021
Jul 04 2016 06:24
hello to all. so I kind of have a problem. somehow I got this challenge right but what i like to do is look at all the test points to see if my code actually produced what is was supposed to to make sure that I grasp a better understanding of the code. as I was looking through, it does not look like my code does what its supposed to do but I still passed. can somebody else take a look at this and tell me what you think. I would greatly appreciate it.
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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


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

  }

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
this is the record collection challenge
Markus Kiili
@Masd925
Jul 04 2016 06:26
@mikedorsey1021 It is fine, except that if (collection[id][prop]){ is not a proper way to test property existence. Use .hasOwnProperty() instead.
DJ
@qualitymanifest
Jul 04 2016 06:27
@jnelson180 yeah, this one can be done with just regex - it's a great opportunity to work on regex.
michael dorsey
@mikedorsey1021
Jul 04 2016 06:27
@Masd925 ok let me check this out.
Sean DiSanti
@badc0ded
Jul 04 2016 06:27
@mikedorsey1021 to elaborate a little further, if collection[id][prop] contains a falsy value, the condition would return false even though the value was there
Jake
@jnelson180
Jul 04 2016 06:27
@qualitymanifest I'll certainly have to brush up my regex skills a bit more :D
michael dorsey
@mikedorsey1021
Jul 04 2016 06:28
@badc0ded got it
DJ
@qualitymanifest
Jul 04 2016 06:28
@jnelson180 if you haven't done any regex tutorials, regexone.com is a decent starter. from there, a lot of reading docs and maybe some googling
Indhu
@Indhusethu
Jul 04 2016 06:28

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){
myObj.hasOwnProperty(checkProp);
if(myObj.hasOwnProperty(checkProp)){
return "pony";
}
return "Not Found";
}
checkObj("gift");

Sean DiSanti
@badc0ded
Jul 04 2016 06:28
that's why hasOwnProperty is the best way to check, and if you're just checking that a variable has been initialized, checking that typeof variableName != 'undefined' is more reliable also
Indhu
@Indhusethu
Jul 04 2016 06:29
where did go wrong?? @Masd925
tkruger3902
@tkruger3902
Jul 04 2016 06:29

Can someone please tell me why this doesn't work for the "Golf Code" challenge? It also says "<=" is an unexpected token, but the instructions say to use it... Thanks in advance! function golfScore(par, strokes) {
// Only change code below this line
if (par = 1) {
return "Hole-in-One!";
} else if (<=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 (>=par + 3) {
return "Go Home!";
}

return "Change Me";

Norvin Burrus
@ndburrus
Jul 04 2016 06:29
@Indhusethu Which lesson/exercise (name) is this?
Indhu
@Indhusethu
Jul 04 2016 06:29
it's testing objects for properties
Norvin Burrus
@ndburrus
Jul 04 2016 06:30
@tkruger3902 what are you comparing in the if statement? use the strokes/return chart/table
Indhu
@Indhusethu
Jul 04 2016 06:31
@ndburrus
Norvin Burrus
@ndburrus
Jul 04 2016 06:31
@Indhusethu what is this myObj.hasOwnProperty(checkProp); statement doing? also, in the if statement, you only want the pony value returned? if so, why do you need a conditional? shouldn't the evaluation be made using the prop (which is input for the test function), and if the prop exists, the fetch the corresponding value from the object?
Indhu
@Indhusethu
Jul 04 2016 06:32
i removed it now
tkruger3902
@tkruger3902
Jul 04 2016 06:32
What might an example "if" statement look like? Because in my head, that if statement says "If par = 1, return "Hole in one""
Indhu
@Indhusethu
Jul 04 2016 06:33
@ndburrus
tkruger3902
@tkruger3902
Jul 04 2016 06:33
@ndburrus
NatashaBloong
@NatashaBloong
Jul 04 2016 06:33
var myStr = "Here is a backslash: \. \n \t \t Here is a new line with two tabs."; // Change this line
what am I doing wrong? it is supposed to start a new line and then tab twice
tkruger3902
@tkruger3902
Jul 04 2016 06:35
@NatashaBloong Challenge title?
Indhu
@Indhusethu
Jul 04 2016 06:35
add another backslash after :\
@NatashaBloong
Krishna Sai Gullapalli
@Krish2704
Jul 04 2016 06:35
@NatashaBloong i think you should give '\' for backslash instead of '\'
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 06:36
Still looking for help with "Map the Debris" challenge if anyone is around that can help
:point_up: July 4, 2016 10:21 AM
Norvin Burrus
@ndburrus
Jul 04 2016 06:36
@tkruger3902 well, the chart/table shows that the strokes value has an equivlent par value. that par value determines what the result is. so why not evaluate based on what strokes is?
Krishna Sai Gullapalli
@Krish2704
Jul 04 2016 06:36
@Goblinlordx hey, what's up?
Indhu
@Indhusethu
Jul 04 2016 06:36
are you getting it? @NatashaBloong
NatashaBloong
@NatashaBloong
Jul 04 2016 06:37
no, it did not work
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 06:37
Hello ^^
NatashaBloong
@NatashaBloong
Jul 04 2016 06:37
how to I insert a pic? i will screenshot it
Indhu
@Indhusethu
Jul 04 2016 06:37
let me see the code?
just copy and paste @NatashaBloong
Krishna Sai Gullapalli
@Krish2704
Jul 04 2016 06:37
@NatashaBloong drag and drop
NatashaBloong
@NatashaBloong
Jul 04 2016 06:37
Screenshot (79).png
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 06:37
@Krish2704 You can click on the link to see my description of the problem earlier
Norvin Burrus
@ndburrus
Jul 04 2016 06:38
@NatashaBloong where is the escape for the 1st backslash?
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 06:38
basically, I don't know what the formula I should use
Norvin Burrus
@ndburrus
Jul 04 2016 06:38
help format @NatashaBloong
CamperBot
@camperbot
Jul 04 2016 06:38

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Indhu
@Indhusethu
Jul 04 2016 06:38
why do you leave space between . and \n?
@NatashaBloong
and also \t\t
NatashaBloong
@NatashaBloong
Jul 04 2016 06:39
oh, so i type in the word escape?
Indhu
@Indhusethu
Jul 04 2016 06:39
remove the spaces..
NatashaBloong
@NatashaBloong
Jul 04 2016 06:39
that does not change anything
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 06:39

@Krish2704
On "Map the Debris"... I am pretty confused as to what formula I am supposed to use.

I am given everything to find the period except the semi-major axis. I am instead given an average and radius of the Earth. From this I can say that the Earth's radius would be a minimum for the semi-minor axis (which would actually end up in a collision so I assume this isn't correct). If I assume it reaches the minimum and it is an elliptical orbit than the max would be 2x the distance from minimum to average. This supposedly would give me a maximum to use as the semi-major axis distance.

Long story short, this doesn't give the answer it's expecting and I don't see anything indicating how to get from the information I am given to what is needed (including the wiki article). Short of cheating and just giving the answers it is looking for for the given input... can someone point me in the right direction?

Indhu
@Indhusethu
Jul 04 2016 06:40
just type those words according to the instructions @NatashaBloong
keep trying,i think you will get it

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){

if(myObj.hasOwnProperty(checkProp)){
return "pony";
}
return "Not Found";
}
checkObj("gift");

@ndburrus
Norvin Burrus
@ndburrus
Jul 04 2016 06:40

@tkruger3902 ok, let's examine this more closely. the first line actually says if Strokes = 1 (or par), then the output/result is "Hole-in-one!", doesn't it?

What might an example "if" statement look like? Because in my head, that if statement says "If par = 1, return "Hole in one""

Indhu
@Indhusethu
Jul 04 2016 06:41
can you identify the mistake??
@ndburrus
Markus Kiili
@Masd925
Jul 04 2016 06:41
@Indhusethu On the if block, you should access the property value and return it.
NatashaBloong
@NatashaBloong
Jul 04 2016 06:41
I typed the words and it just includes it in the quotes
Indhu
@Indhusethu
Jul 04 2016 06:42
ok!! @Masd925 like if(myObj.hasOwnProperty("pony"))??
tkruger3902
@tkruger3902
Jul 04 2016 06:42
@ndburrus Thank you
CamperBot
@camperbot
Jul 04 2016 06:42
tkruger3902 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 813 | @ndburrus |http://www.freecodecamp.com/ndburrus
michael dorsey
@mikedorsey1021
Jul 04 2016 06:42
@badc0ded @Masd925 how would i properly iterate .hasOwnProperty
Indhu
@Indhusethu
Jul 04 2016 06:42
now send me your code @NatashaBloong
Sean DiSanti
@badc0ded
Jul 04 2016 06:43
@mikedorsey1021 it returns true or false depending on whether the object has the property
so you would just use it in a condition like...
NatashaBloong
@NatashaBloong
Jul 04 2016 06:43
Screenshot (79).png
There ^^ @Indhusethu
Markus Kiili
@Masd925
Jul 04 2016 06:44
@Indhusethu No. Only use myObj and checkProp inside the function. Don't use any hardcoded strings.
Indhu
@Indhusethu
Jul 04 2016 06:44
yes
@NatashaBloong
Sean DiSanti
@badc0ded
Jul 04 2016 06:44
if (myObj.hasOwnProperty('property') {
  alert('it has it');
} else {
  alert('myObj does not have property');
}
Indhu
@Indhusethu
Jul 04 2016 06:44
ok @Masd925
i can't understand?
@Masd925
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:45
guys why my code isn,t working?
var myStr = '\ \t \t \r \n';
Indhu
@Indhusethu
Jul 04 2016 06:45
you should remove spaces @NatashaBloong
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:45
var myStr = '\\ \t \t \r \n';
Indhu
@Indhusethu
Jul 04 2016 06:45
as i said before
Norvin Burrus
@ndburrus
Jul 04 2016 06:45
@Indhusethu ok, it works like this. checkProp is the left column value (or potential value). the test function supplies that. in this case we'll use gift for checkProp. the function receives gift and evaluates if the object has gift as a value in the left colum. if so, it returns the corresponding key value from the object.
Indhu
@Indhusethu
Jul 04 2016 06:45
"Here is a backslash: \.\n\t\tHere is a new line with two tabs.";// Change this line
NatashaBloong
@NatashaBloong
Jul 04 2016 06:46
it gives me the same errors the spaces do not affect it
Indhu
@Indhusethu
Jul 04 2016 06:46
for gift it is Pony,should i return this property value??
NatashaBloong
@NatashaBloong
Jul 04 2016 06:46
oh!
i did not remove the space between the t and H
Thanks!
Indhu
@Indhusethu
Jul 04 2016 06:47
yes @NatashaBloong
Markus Kiili
@Masd925
Jul 04 2016 06:47
@Indhusethu You access property value with syntax obj[key]. Just use myObj and checkProp there.
Indhu
@Indhusethu
Jul 04 2016 06:47
use the tagname @NatashaBloong when you mention thanks
CamperBot
@camperbot
Jul 04 2016 06:47
indhusethu sends brownie points to @natashabloong :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for natashabloong
Norvin Burrus
@ndburrus
Jul 04 2016 06:48
@NatashaBloong the escape characters do not require spacing. the only spacing to consider is normal sentence spacing needed. make sense?
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:48
var myStr = '\\ \t \t \r \n';
Indhu
@Indhusethu
Jul 04 2016 06:48
give me an example @Masd925
NatashaBloong
@NatashaBloong
Jul 04 2016 06:48
ahh okay, in that case @Jonhnwhantcoding remove the spaces
I was having the same issue
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:49
@NatashaBloong ```
var myStr = '\\t\t\r\n';
like this?
isn,t working
NatashaBloong
@NatashaBloong
Jul 04 2016 06:49
yeah, what are you trying to make it do?
Indhu
@Indhusethu
Jul 04 2016 06:49
remove the quotations @Jonhnwhantcoding
NatashaBloong
@NatashaBloong
Jul 04 2016 06:50
@Jonhnwhantcoding remove the.. Yeah ^^^ otherwise it will not run it, just say what you are typing
Indhu
@Indhusethu
Jul 04 2016 06:50
follow the instruction @Jonhnwhantcoding
NatashaBloong
@NatashaBloong
Jul 04 2016 06:50
@Indhusethu sometimes the instructions need a little tweaking, as they lack clarity
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:50
@NatashaBloong can you gime me example
give
kuldeep
@gurukd
Jul 04 2016 06:52
anyone completed pigLatin challenge?
Indhu
@Indhusethu
Jul 04 2016 06:52
yes!! @NatashaBloong
no @gurukd

var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp){
if(myObj.hasOwnProperty(checkProp)){
return "pony";
}
return "Not Found";
}
checkObj("gift");

NatashaBloong
@NatashaBloong
Jul 04 2016 06:53
var myStr = '\t\t\r\n'; would put out: \t\t\r\n
so get rid of the ' ' if you actually want it to tab and such.
please screenshot what it is asking you to do
Indhu
@Indhusethu
Jul 04 2016 06:53
where i'm making the mistake??
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:53
I,have removed spaces between sequences but my code isn,t working
Indhu
@Indhusethu
Jul 04 2016 06:53
send your code @Jonhnwhantcoding
kuldeep
@gurukd
Jul 04 2016 06:54
@Indhusethu what is challenge name?
Indhu
@Indhusethu
Jul 04 2016 06:54
testing objects for properties @gurukd
Markus Kiili
@Masd925
Jul 04 2016 06:54
@Indhusethu Inside the if block, return obj[key]; <- but use myObj as the object and checkProp as the key.
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:54
var myStr = '\\\t\t\r\n'; // Change this line
NatashaBloong
@NatashaBloong
Jul 04 2016 06:54
@Jonhnwhantcoding what do the instructions say?
Indhu
@Indhusethu
Jul 04 2016 06:55
oh kk @Masd925
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:55

Here is the text with the escape sequences written out.

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

here is issue

Here is the text with the escape sequences written out.

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

myStr should have encoded text with the proper escape sequences and spacing
NatashaBloong
@NatashaBloong
Jul 04 2016 06:55
I think we are working on the same section. give me a min to catch up to where you are
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:56
Escape Sequences in Strings
Indhu
@Indhusethu
Jul 04 2016 06:56
write those lines in quotes
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 06:56
I am on this topic
NatashaBloong
@NatashaBloong
Jul 04 2016 06:56
yes
kuldeep
@gurukd
Jul 04 2016 06:57

@Indhusethu
function checkObj(checkProp) {
// Your Code Here
if( myObj.hasOwnProperty(checkProp)) return myObj[checkProp];

return "Not Found";
}

Indhu
@Indhusethu
Jul 04 2016 06:57
Here is a backslash: backslash.newline tab tab
michael dorsey
@mikedorsey1021
Jul 04 2016 06:57
@badc0ded now I'm pretty sure i broke it. now its just not passing one of them but still not giving the proper result.
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Indhu
@Indhusethu
Jul 04 2016 06:57
thanks @gurukd
CamperBot
@camperbot
Jul 04 2016 06:57
indhusethu sends brownie points to @gurukd :sparkles: :thumbsup: :sparkles:
:cookie: 266 | @gurukd |http://www.freecodecamp.com/gurukd
Justin Woodward
@jwoo92
Jul 04 2016 06:58
@Jonhnwhantcoding are you still stuck?
Sean DiSanti
@badc0ded
Jul 04 2016 06:58
what test is failing?
michael dorsey
@mikedorsey1021
Jul 04 2016 06:58
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.
Sean DiSanti
@badc0ded
Jul 04 2016 06:59
ok, lets step through with those values
Markus Kiili
@Masd925
Jul 04 2016 06:59
@mikedorsey1021 if (collection.hasOwnProperty(prop)) <- where is id?
Sean DiSanti
@badc0ded
Jul 04 2016 06:59
yeah you should be looking at collection[id].hasOwnProperty
makes sense?
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 07:01
Can somebody exaplain to me "Condense arrays with reduce" challenge in simpler terms? I don't get it.
Markus Kiili
@Masd925
Jul 04 2016 07:01
@a-y-u-s-h Sure.
michael dorsey
@mikedorsey1021
Jul 04 2016 07:01
on my mistake accidentally deleted it. but that makes sense. but any idea why the code is still not producing the proper response. its acting like its right code but just not executing the commands. does that make sense or should i explain it better
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 07:02
@Masd925 Please do ._.
Markus Kiili
@Masd925
Jul 04 2016 07:03
@a-y-u-s-h .reduce() method iterates automatically through the array and updates a running value on each element. The callback function you provide for reduce tells it how to get the next running value from the previous running value and the element being iterated.
If you don't provide any initial value for reduce running value, It will take the first array element as the first running value.
michael dorsey
@mikedorsey1021
Jul 04 2016 07:07
collection = 
{
  "1245": {
    "artist": "Robert Palmer",
    "tracks": []
  },
  "2468": {
    "album": "1999",
    "artist": "Prince",
    "tracks": [
      "1999",
      "Little Red Corvette"
    ]
  },
  "2548": {
    "album": "Slippery When Wet",
    "artist": "Bon Jovi",
    "tracks": [
      "Let It Rock",
      "You Give Love a Bad Name"
    ]
  },
  "5439": {
    "album": "ABBA Gold",
    "artist": "ABBA"
  }
}
this is whats being returned and this should be the outcome:
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.
After updateRecords(2548, "tracks", ""), tracks should not be set
@badc0ded
Sean DiSanti
@badc0ded
Jul 04 2016 07:08
i see what the result should be, but not what the results are
or the newest iteration of your code
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:09
@jwoo92 yea
michael dorsey
@mikedorsey1021
Jul 04 2016 07:09
@badc0ded my current code which is passing
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      "tracks": [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
Justin Woodward
@jwoo92
Jul 04 2016 07:09
@Jonhnwhantcoding what is your current issue and what is the name of the challenge you are stuck on?
BuntyBru
@BuntyBru
Jul 04 2016 07:09
How can i remove alphanumeric characters from a string ?
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:10
@jwoo92 I,m stuck on this topic
Escape Sequences in Strings
issues is those
myStr should have encoded text with the proper escape sequences and spacing.
myStr should not have any spaces in between consecutive escape sequences.
var myStr = '\\ \t \t \r \n';
Sean DiSanti
@badc0ded
Jul 04 2016 07:11
ok, so it's passing? What is the question then?
sorry am just popping head in when i get the mention i'm actively working in another window so not keeping up with the back and forth in here
@Jonhnwhantcoding do you see the line about not having spaces?
Markus Kiili
@Masd925
Jul 04 2016 07:12
@a-y-u-s-h Here is an example of concating an array of strings with reduce:
var array = ["He","sings","so","well"];

function adder(acc,curr) {
  return acc+" "+curr;
}

var singleVal = array.reduce(adder); // 'He sings so well'

// No initial value is specified, so reduce takes "He" as the
// first running value and "sings" as the first element. It passes
// then to the callback and takes the return value "He sings" as the 
// next running value. The next elements "so" and "well" will produce
// running values "He sings so" and "He sings so well". The last one is
// returned by reduce.
BuntyBru
@BuntyBru
Jul 04 2016 07:12

@Jonhnwhantcoding
Here is a backslash: \.\n\t\tHere is a new line with two tabs

would pass the assignment i gues

Sean DiSanti
@badc0ded
Jul 04 2016 07:12
no, because \ won't print a backslash
you have to escape it
oh, nevermind, this chat prints a single when you type a double
have to triple for double here \\
my bad
BuntyBru
@BuntyBru
Jul 04 2016 07:14

can anyone tell me

How can i remove alphanumeric characters from a string ?

Markus Kiili
@Masd925
Jul 04 2016 07:14
@BuntyBru You can use .replace() and suitable regexp object.
shweta rajput
@ShwetaRajput
Jul 04 2016 07:14

function largestOfFour(arr) {
  // You can do this
  var greatest=0;
for(var i=0;i<=arr.length;i++){
  for(var j=0;j<=arr[i].length;j++){
    if(arr[i][j]>greatest){
      greatest=arr[i][j];
    }
 }
 return greatest;
}


}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
BuntyBru
@BuntyBru
Jul 04 2016 07:14
@Masd925
could u give an example?
that would be really helpful
shweta rajput
@ShwetaRajput
Jul 04 2016 07:15
can someone help me with this
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 07:15
@Masd925 Something new. Thanks, I get it from that example.
CamperBot
@camperbot
Jul 04 2016 07:15
a-y-u-s-h sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2030 | @masd925 |http://www.freecodecamp.com/masd925
shweta rajput
@ShwetaRajput
Jul 04 2016 07:15
how to access subarray within an array?
Markus Kiili
@Masd925
Jul 04 2016 07:15
@ShwetaRajput Initialize greatest for each subarray (to 0 or -Infinity) and after j loop assign greatest to arr[i]. Return arr at the end.
Justin Woodward
@jwoo92
Jul 04 2016 07:16
@Jonhnwhantcoding okay. what you need to do is create this below. so you start with var myStr ="". you want to create the string inside the pair of '" by using the Escape Sequences as well.
Here is a backslash: \.
        Here is a new line with two tabs.`
Justin Woodward
@jwoo92
Jul 04 2016 07:17
@Jonhnwhantcoding your string will be whitespace sensitive, so be careful.
michael dorsey
@mikedorsey1021
Jul 04 2016 07:17

ok so the code I am using right now is passing. which is :

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

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

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

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


  return collection;
}

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

but when i look at the objectives this is what my code should produce after it executes:
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
After updateRecords(2548, "artist", ""), artist should not be set
After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.
After updateRecords(2548, "tracks", ""), tracks should not be set

but it is just returning the same object back with out executing the code on it first which is:

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

So my question is why is it just returning my object with out first executing the code first or should i even worry about that?
@badc0ded

michael dorsey
@mikedorsey1021
Jul 04 2016 07:17
@ @badc0ded
Markus Kiili
@Masd925
Jul 04 2016 07:18
@BuntyBru Look at \w and \W
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:18
@jwoo92
Sean DiSanti
@badc0ded
Jul 04 2016 07:18
you're seeing the output of the copy of the initial object
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:18
var myStr = '\\ \n \t \t';
Sean DiSanti
@badc0ded
Jul 04 2016 07:18
not the result of each run
ahmed abouhay
@abohay
Jul 04 2016 07:18

var count = 0;

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

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

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

any one can help
counting card challenge
Sean DiSanti
@badc0ded
Jul 04 2016 07:19
you could throw a console.log(collection); in there to see the result at each step
Justin Woodward
@jwoo92
Jul 04 2016 07:19
@Jonhnwhantcoding your variable should return this string:
Here is a backslash: \.
        Here is a new line with two tabs.`
Sean DiSanti
@badc0ded
Jul 04 2016 07:19
or on each run i mean
Benjamin Baldivia
@Goblinlordx
Jul 04 2016 07:19
Still looking for help with "Map the Debris" challenge if anyone is around that can help
:point_up: July 4, 2016 10:21 AM
NatashaBloong
@NatashaBloong
Jul 04 2016 07:20
Screenshot (80).png
what am I supposed to do, to put in those words into the mad lib?
Justin Woodward
@jwoo92
Jul 04 2016 07:20
@Jonhnwhantcoding hint: the challenge already includes all the escape sequences you need. you just need to fill in with the proper text.
BuntyBru
@BuntyBru
Jul 04 2016 07:21

@Masd925
Here is my code and i am not able to pass two tests

function palindrome(str) {
// Good luck
str = str.replace( /[^A-Za-z0-9]/gi,'');
var str1= str.toLowerCase();

var arr= str1.split('');
var newarr= arr.reverse();
var newstr=newarr.reduce(function(previousVal, currentVal){
return previousVal + currentVal;});

if(str == newstr)
return true;
else
{
return false;
}
}

palindrome("eye");

Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:21
@jwoo92 :D
@jwoo92 hate this topic
Indhu
@Indhusethu
Jul 04 2016 07:22
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
"artist": "Mark",
"title": "Piano girl",
"release_year": 1975,
"formats": [
"CS",
"8T",
"LP" ],
"gold":true
];
Markus Kiili
@Masd925
Jul 04 2016 07:22
@BuntyBru Compare str1 and newstr.
Indhu
@Indhusethu
Jul 04 2016 07:22
what mistake i did here?
ahmed abouhay
@abohay
Jul 04 2016 07:23
@NatashaBloong add the parameters in result variable
BuntyBru
@BuntyBru
Jul 04 2016 07:23

thanks @Masd925

silly mistake

CamperBot
@camperbot
Jul 04 2016 07:23
buntybru sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2031 | @masd925 |http://www.freecodecamp.com/masd925
tkruger3902
@tkruger3902
Jul 04 2016 07:23
@NatashaBloong "The " + myAdjective + " " + myNoun + " "...
ahmed abouhay
@abohay
Jul 04 2016 07:23

var count = 0;

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

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

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

Markus Kiili
@Masd925
Jul 04 2016 07:23
@BuntyBru The last if is also redundant. Just return str1===newstr; You could also use built in .join("") instead of reduce.
Justin Woodward
@jwoo92
Jul 04 2016 07:23
@Jonhnwhantcoding is it making sense yet?
Indhu
@Indhusethu
Jul 04 2016 07:24
can anyone help me in manipulating complex objects??
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:24
@jwoo92 can you write code and give me
?
michael dorsey
@mikedorsey1021
Jul 04 2016 07:25
@badc0ded ok thank you for all your help
CamperBot
@camperbot
Jul 04 2016 07:25
mikedorsey1021 sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 401 | @badc0ded |http://www.freecodecamp.com/badc0ded
ahmed abouhay
@abohay
Jul 04 2016 07:25
any one can help me with counting cards challenge
Sean DiSanti
@badc0ded
Jul 04 2016 07:25
no problem, i'm glad i could help
Justin Woodward
@jwoo92
Jul 04 2016 07:25
@NatashaBloong make a sentence out of the provided arguments. example: "my " + myAdjective + myNoun +......
Indhu
@Indhusethu
Jul 04 2016 07:26
send your code @abohay
shweta rajput
@ShwetaRajput
Jul 04 2016 07:26
@Masd925 its not working
ahmed abouhay
@abohay
Jul 04 2016 07:26

@Indhusethu
var count = 0;

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

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

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

Indhu
@Indhusethu
Jul 04 2016 07:26
so tat i can see wat mistake you have done
shweta rajput
@ShwetaRajput
Jul 04 2016 07:27
function largestOfFour(arr) {
  // You can do this
  var greatest=0;
for(var i=0;i<=arr.length;i++){
  for(var j=0;j<=arr[i].length;j++){
    if(arr[i][j]>greatest){
      greatest=arr[i][j];
    }
  }    return greatest;

}
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@Masd925
Justin Woodward
@jwoo92
Jul 04 2016 07:27
@Jonhnwhantcoding i can give you another hint. var myStr = 'Here is a backslash: \\ \n \t \t'; would be the first part. pay attention on how to use escape sequences.
Indhu
@Indhusethu
Jul 04 2016 07:27
why do you use or symbol??
while using switch case
@abohay
shweta rajput
@ShwetaRajput
Jul 04 2016 07:27
@Masd925 its only returning the largest element of first array
Markus Kiili
@Masd925
Jul 04 2016 07:28
@ShwetaRajput After i loop declaration, you need to initialize largest to 0 or -Infinity. That way it will reset for each subarray.
Indhu
@Indhusethu
Jul 04 2016 07:28
remove that || @abohay
NatashaBloong
@NatashaBloong
Jul 04 2016 07:28
Screenshot (81).png
I am trying to call on the different words in wordBlanks( ) to insert them into my sentence. How do I do this properly?
ahmed abouhay
@abohay
Jul 04 2016 07:28
@Indhusethu to shortcut different cases is that wrong?
ehekatlOf
@ehekatlOf
Jul 04 2016 07:29
so stupid question
Indhu
@Indhusethu
Jul 04 2016 07:29
yes!!
ehekatlOf
@ehekatlOf
Jul 04 2016 07:29
is there any way to beautiful code
Indhu
@Indhusethu
Jul 04 2016 07:29
case:
ehekatlOf
@ehekatlOf
Jul 04 2016 07:29
when I'm doing a view-source on the script of a site?
Indhu
@Indhusethu
Jul 04 2016 07:29
use case:,this is the syntax @abohay
ehekatlOf
@ehekatlOf
Jul 04 2016 07:29
it always looks like spaghetti with no formatting
Joni petriashvili
@Jonhnwhantcoding
Jul 04 2016 07:30
@jwoo92 I have to give up thanks for everything
CamperBot
@camperbot
Jul 04 2016 07:30
jonhnwhantcoding sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 382 | @jwoo92 |http://www.freecodecamp.com/jwoo92
ahmed abouhay
@abohay
Jul 04 2016 07:30
@camperbot what's that ?
Markus Kiili
@Masd925
Jul 04 2016 07:30
@ehekatlOf You can indent the code with some editors or web pages, and format it when you post in on chat.
Norvin Burrus
@ndburrus
Jul 04 2016 07:30
@abohay what is this: return "Change Me"; for?
Markus Kiili
@Masd925
Jul 04 2016 07:30
explain format
CamperBot
@camperbot
Jul 04 2016 07:30

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

ehekatlOf
@ehekatlOf
Jul 04 2016 07:30
like I was prying twitch
and it looks like spaghetti
Indhu
@Indhusethu
Jul 04 2016 07:30
you have done many mistakes,jus change it one by one @abohay
shweta rajput
@ShwetaRajput
Jul 04 2016 07:31
@Masd925 i did that. but we have to return the array of greatest element of every subarray.
Markus Kiili
@Masd925
Jul 04 2016 07:31
@ShwetaRajput Then after j loop block, assign largest to arr[i]. That way you store the largest number of subarray arr[i].
shweta rajput
@ShwetaRajput
Jul 04 2016 07:31
after initialisation or end?
Markus Kiili
@Masd925
Jul 04 2016 07:32
@ShwetaRajput After j loop block.
@ShwetaRajput And return arr after i loop block.
Indhu
@Indhusethu
Jul 04 2016 07:33
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
}
"artist": "Mark",
"title": "Piano girl",
"release_year": 1975,
"formats": [
"CS",
"8T",
"LP" ],
"gold":true
];
Justin Woodward
@jwoo92
Jul 04 2016 07:33
@Jonhnwhantcoding var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs."; will return:
Here is a backslash: .
Here is a new line with two tabs.
look at how it works and try to understand it.
Indhu
@Indhusethu
Jul 04 2016 07:33
@Masd925
point out my mistake please
Norvin Burrus
@ndburrus
Jul 04 2016 07:33
@ehekatlOf these may be useful :sparkles: :smile:
ehekatlOf
@ehekatlOf
Jul 04 2016 07:33
@ndburrus awesome, thanks man
CamperBot
@camperbot
Jul 04 2016 07:33
ehekatlof sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 814 | @ndburrus |http://www.freecodecamp.com/ndburrus
Indhu
@Indhusethu
Jul 04 2016 07:33
remove the spaces @jwoo92
Norvin Burrus
@ndburrus
Jul 04 2016 07:34
@Indhusethu seperate the records with a comma...
Markus Kiili
@Masd925
Jul 04 2016 07:34
@Indhusethu The structure should be like: var myMusic=[{...},{...}];
Indhu
@Indhusethu
Jul 04 2016 07:34
okk @Masd925
@ndburrus
NatashaBloong
@NatashaBloong
Jul 04 2016 07:35
Screenshot (83).png
@Indhusethu It gives the correct output, what am I doing wrong with my code?
Justin Woodward
@jwoo92
Jul 04 2016 07:35
@Indhusethu that was from me copying his original code. i did not realize i left that in there.
Indhu
@Indhusethu
Jul 04 2016 07:36
This message was deleted
Rafael Nunes
@orafanunes
Jul 04 2016 07:36
Hello, guys.. Can anybody tell me why my code is not working?
I'm at the 273º challenge (Caesars Cipher) and my ROT13 decoder does not work for all my inputs..
function rot13(str) { 
  str = str.split("");
  var finalString = [];
  for ( var i = 0 ; i < str.length ; i++){
    str[i] = str[i].charCodeAt(0)+13;
    finalString[i] = String.fromCharCode(str[i]); 
  }

  return finalString.join('');
}
rot13("SERR PBQR PNZC");
Justin Woodward
@jwoo92
Jul 04 2016 07:36
@NatashaBloong you need to enter words in between each argument. you may choose whatever words you want.
Markus Kiili
@Masd925
Jul 04 2016 07:37
@orafanunes You should only change characters that are A-Z. Others are left untouched.
NatashaBloong
@NatashaBloong
Jul 04 2016 07:37

@jwoo92 can you give me an example of what you mean?

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line
result = "My" + myAdjective + myNoun + myVerb + myAdverb + ".";
// Your code above this line
return result;
}
// Change the words here to test your function
wordBlanks(" dog", " big", " ran", " quickly");

Rafael Nunes
@orafanunes
Jul 04 2016 07:37
so.. should i filter the characters first?
@Masd925
Indhu
@Indhusethu
Jul 04 2016 07:38
var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true
},
var myMusic=[
{
"artist": "Mark",
"title": "Piano girl",
"release_year": 1975,
"formats": [
"CS",
"8T",
"LP" ],
"gold":true
}
];
@Masd925
i'm stuck
Markus Kiili
@Masd925
Jul 04 2016 07:38
@orafanunes You can make a check on the charcode of the looped character.
Norvin Burrus
@ndburrus
Jul 04 2016 07:38
@Indhusethu this: var myMusic=[ should include both records...
Rafael Nunes
@orafanunes
Jul 04 2016 07:39
ok, thx @Masd925
CamperBot
@camperbot
Jul 04 2016 07:39
orafanunes sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2032 | @masd925 |http://www.freecodecamp.com/masd925
Indhu
@Indhusethu
Jul 04 2016 07:39
ok @ndburrus

var myMusic = [
{
"artist": "Billy Joel",
"title": "Piano Man",
"release_year": 1973,
"formats": [
"CS",
"8T",
"LP" ],
"gold": true

"artist": "Mark",
"title": "Piano girl",
"release_year": 1975,
"formats": [
"CS",
"8T",
"LP" ],
"gold":true
}
];

@ndburrus

am i right??
Justin Woodward
@jwoo92
Jul 04 2016 07:40
@NatashaBloong make it return my dog is big and ran very quickly.
Norvin Burrus
@ndburrus
Jul 04 2016 07:41
@Indhusethu conceptually, the object will have two seperate (but essentially equivalent) records. does this help? hint: how can one record be distinguished from the other?
Indhu
@Indhusethu
Jul 04 2016 07:41
i'm getting an issue again :worried:
NatashaBloong
@NatashaBloong
Jul 04 2016 07:41
Screenshot (84).png
@jwoo92 like this?
that still gives me an error so im guessing you mean in the word blanks?
Indhu
@Indhusethu
Jul 04 2016 07:42
i found where i went wrong :smile:
thank you both @ndburrus @Masd925
CamperBot
@camperbot
Jul 04 2016 07:43
indhusethu sends brownie points to @ndburrus and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2033 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 815 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jul 04 2016 07:43
@Indhusethu nice work :+1:
guiguivey
@guiguivey
Jul 04 2016 07:44
hey @Indhusethu, can you tell me where you went wrong please ? I have the same issue as you, but I can't find my error :(
ahmed abouhay
@abohay
Jul 04 2016 07:44
@badc0ded thanks
CamperBot
@camperbot
Jul 04 2016 07:44
abohay sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 402 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
Jul 04 2016 07:44
no problem, thank you for the points
i'm gald i could help
Justin Woodward
@jwoo92
Jul 04 2016 07:44
@NatashaBloong did you put those spaces in the arguments at the bottom function?
NatashaBloong
@NatashaBloong
Jul 04 2016 07:45
@jwoo92 yes
greedylemon
@greedylemon
Jul 04 2016 07:45
can any one tell me how to do accessing objects properties with variables?

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

// Only change code below this line;
var shit = 16;
var playerNumber = testObj[Monata]; // Change this Line
var player = testObj[shit];

Justin Woodward
@jwoo92
Jul 04 2016 07:45
@NatashaBloong you do not do that. put the spaces in the function your working in on the words you are creating.
greedylemon
@greedylemon
Jul 04 2016 07:46
i don't know how to get that 16 by using []
Justin Woodward
@jwoo92
Jul 04 2016 07:46
@NatashaBloong "my " + myNoun + " is "...
NatashaBloong
@NatashaBloong
Jul 04 2016 07:46
@jwoo92 Thanks! it worked :D
CamperBot
@camperbot
Jul 04 2016 07:46
natashabloong sends brownie points to @jwoo92 :sparkles: :thumbsup: :sparkles:
:cookie: 383 | @jwoo92 |http://www.freecodecamp.com/jwoo92
Justin Woodward
@jwoo92
Jul 04 2016 07:46
@NatashaBloong awesome!
guiguivey
@guiguivey
Jul 04 2016 07:47
I found! thank you for what you have written @inesdes @ndburrus and @Masd925
CamperBot
@camperbot
Jul 04 2016 07:47
guiguivey sends brownie points to @inesdes and @ndburrus and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 185 | @inesdes |http://www.freecodecamp.com/inesdes
:cookie: 816 | @ndburrus |http://www.freecodecamp.com/ndburrus
:star2: 2034 | @masd925 |http://www.freecodecamp.com/masd925
ahmed abouhay
@abohay
Jul 04 2016 07:48
@Indhusethu thanks
CamperBot
@camperbot
Jul 04 2016 07:48
abohay sends brownie points to @indhusethu :sparkles: :thumbsup: :sparkles:
:cookie: 96 | @indhusethu |http://www.freecodecamp.com/indhusethu
Amey Singh
@AmeySingh
Jul 04 2016 07:49
i am facing problem with string challange 143
ahmed abouhay
@abohay
Jul 04 2016 07:50
@AmeySingh what's it?
Markus Kiili
@Masd925
Jul 04 2016 07:50
@AmeySingh There are no challenge numbers, only names.
kuldeep
@gurukd
Jul 04 2016 07:53
@greedylemon Not possible bro.\
Krzysztof Borowy
@Krizzu
Jul 04 2016 07:55
@greedylemon If you want access value Montana, you have to use key 16
because, js' objects are key-value pairs
key: value
so 16: Montana
to access Montana, go for
var x = object['16'];
Happy-Ferret
@Happy-Ferret
Jul 04 2016 07:56
Hello World
CamperBot
@camperbot
Jul 04 2016 07:56

welcome to FreeCodeCamp @Happy-Ferret!

kuldeep
@gurukd
Jul 04 2016 07:57
properties or keys as name suggest to unlock the door to access the entry. But not vice versa @greedylemon
devpaaji
@devpaaji
Jul 04 2016 07:57
@Masd925 hello how are you
Markus Kiili
@Masd925
Jul 04 2016 07:58
@devpaaji Fine, thanks.
CamperBot
@camperbot
Jul 04 2016 07:58
masd925 sends brownie points to @devpaaji :sparkles: :thumbsup: :sparkles:
:cookie: 167 | @devpaaji |http://www.freecodecamp.com/devpaaji
Happy-Ferret
@Happy-Ferret
Jul 04 2016 07:58
So is this group only for specific FCC challenges or is it ok to ask for help with other JS related problems, as well?
devpaaji
@devpaaji
Jul 04 2016 07:59

Sum All Numbers in a Range

We'll pass you an array of two numbers. Return the sum of those two numbers and all numbers between them.

do we use reduce
Markus Kiili
@Masd925
Jul 04 2016 07:59
@Happy-Ferret All JS related stuff. Talk is mainly about FCC algorith challenges. There are separate rooms for front and backend stuff.
devpaaji
@devpaaji
Jul 04 2016 07:59
or min max
from js
Happy-Ferret
@Happy-Ferret
Jul 04 2016 08:00
@Masd925 Thanks
CamperBot
@camperbot
Jul 04 2016 08:00
happy-ferret sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2035 | @masd925 |http://www.freecodecamp.com/masd925
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 08:02
Hey, I am on "Factorialize a Number" challenge, this was my code (but it doesn
satisfy the condition that factorial 0 = 1

function factorialize(num) {
  var arr = []; 
  for(i=1; i<= num; i++){
        arr[i-1] = i;
        }

  arr = arr.reduce(function(a,b){

        return a*b;
  });

  if(num !== 0){
  return arr;
  }
  else{
  return 1;
  }
}
Happy-Ferret
@Happy-Ferret
Jul 04 2016 08:03

Alright then.

I'd appreciate some help with establishing a proper namespacing pattern for a small function library.

This is what I got, so far:

foo = function() {
    if (window === this) {
        return foo();
    }
}

/*    Constructor
============================*/

foo.prototype = {
    test:   function(str) {
                window.alert(str);
    }
};

As it stands, it's only callable through foo().test("This is a test."); (note the first parentheses following foo).

This is, quite obviously, not ideal.

Is there any way I can retain the prototype pattern while getting rid of the front parentheses?

i. e. foo.test("This is a test.");

Tiana
@tianap
Jul 04 2016 08:08
This message was deleted
Jonathan Mitchell
@Vanhealen
Jul 04 2016 08:15
who understands the _.memoize function in the underscore library and can explain to me what is going on???
Chris Cullen
@123xylem
Jul 04 2016 08:15

@123xylem

function gen(n) {         
    if (n === 1) {          
      permutations.push(arr.join('')); 
    } else {
      for (var i = 0; i != n; i++) {
        gen(n - 1);
        swap(n % 2 ? 0 : i, n - 1); //WHAT DOES THIS LINE MEAN? SWAP is a previously made swap function for (a,b) but I dont understand the ternary after the modulo
      }
    }
  }
  gen(arr.length);
  return permutations;

Can someone explain how this function works?
With my comment

Jonathan Mitchell
@Vanhealen
Jul 04 2016 08:16
@123xylem whats the swap function?
Chris Cullen
@123xylem
Jul 04 2016 08:17
a= temp... a=b...b=temp it just swaps a and b
Reach4dstars
@endencia
Jul 04 2016 08:18
I am getting a reference error: Invalid left-hand side in assignment
This is the code:
// Only change code below this line
remainder = 11;
remainder % 3 = 2;
I tried using 11 % 3=2; but it also was coming up with reference error. Please help.
darlin-m
@darlin-m
Jul 04 2016 08:24
var myStr="Here is a backslash:\.\n \t \t Here is a new line with two tabs.";// Change this line
myStr should have encoded text with the proper escape sequences and spacing.
i can't find the wrong.
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 08:25
What's meaning of adding prototype when we type something.prototype.somethingElse ?
kirbyedy
@kirbyedy
Jul 04 2016 08:33
@darlin-m mind the spaces
llamatarianism
@llamatarianism
Jul 04 2016 08:33
the prototype of an object is what all 'instances' of that object inherit from
so if I say Foo.prototype.bar = 5; then I create a new Foo object
then that object will automatically have a bar property
which will be equal to 5
you can also set the entire prototype object at once
e.g. Foo.prototype = new Baz
now, any time I create a new Foo, it'll inherit all the properties that a Baz has
Mustafijur rahman
@Dinar717
Jul 04 2016 08:36

function binaryAgent(str) {
  var arr= str.split(' ');
  var num=0;var sentence="";
  for(var i=0;i<arr.length;i++){
    for(var j=0;j<arr[i].lenght;j++){
      if(arr[i][j]==1)
      num+=Math.pow(2,arr[i].length-j-1); 
    }
    sentence+=String.fromCharCode(num);
    num=0;
  }
  return sentence;

}

binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111");
what is wrong with my code?
Kevin
@KevinBruland
Jul 04 2016 08:39
length spelled wrong
in the nested for loop
@Dinar717 I do that a lot for some reason, specifically lenght
Mustafijur rahman
@Dinar717
Jul 04 2016 08:40
@Benalron thanks .
CamperBot
@camperbot
Jul 04 2016 08:40
dinar717 sends brownie points to @benalron :sparkles: :thumbsup: :sparkles:
:cookie: 342 | @benalron |http://www.freecodecamp.com/benalron
Kevin
@KevinBruland
Jul 04 2016 08:41
im pretty stuck on the symmetric difference algorithm if anyone can help
Markus Kiili
@Masd925
Jul 04 2016 08:51
@a-y-u-s-h If you add a property to the constructor, every object gets its own copy of the property. If you add the property to the prototype, there is only one property and all the object use it along the prototype chain. That is why methods are usually added to the prototype.
Oria
@OriaK
Jul 04 2016 08:56
hey guys, I'm really having trouble with "testing Objects for Properties" on the JavaScript part... anyone care to help?
I don't know how to tell the if function to return the value of the property...
it's just not working like I think it should
Ayush Sharma
@a-y-u-s-h
Jul 04 2016 09:02
@Masd925 Thanks.
CamperBot
@camperbot
Jul 04 2016 09:02
a-y-u-s-h sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2036 | @masd925 |http://www.freecodecamp.com/masd925
lazy_bunny
@lazyCoder036
Jul 04 2016 09:09
can any one help me to understand this problem
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
 console.log(myObj[checkProp]);
  //pony
 console.log(myObj.checkProp);             
  //undefined           

}
the first console log is working as expected but the second one is not
Mustafijur rahman
@Dinar717
Jul 04 2016 09:10
I don't understand this problem. "Arguments Optional"
can anyone help...
Nicholas Ayleet Wease
@nwease
Jul 04 2016 09:12
Can anybody help me with this double quotation mess I have here.
Jayrex Acilo
@ajayrexluega
Jul 04 2016 09:12
@mitul036 you need to use if