These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Jun 2016
Stephen James
@sjames1958gm
Jun 09 2016 00:00
@eduwin7 console.log - doesn't return anything. so you are just returning product unchanged
Eric
@Code-Eric
Jun 09 2016 00:00

prompt:
We have an array of objects representing different people in our contacts lists.
The function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.

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

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

If prop does not correspond to any valid properties then return "No such property"

can someone explain what is wrong with this piece of code?
Stephen James
@sjames1958gm
Jun 09 2016 00:00
@Code-Eric What is lookUpProfile - I thought the collection was called contacts?
Norvin Burrus
@ndburrus
Jun 09 2016 00:00
@eduwin7 ok, it would help to carefully consider the math used to generate the solution/result.. :)
eduwin7
@eduwin7
Jun 09 2016 00:01
I am lost lol
Diego Mayer
@Chrono79
Jun 09 2016 00:01
@Code-Eric ypu don't need 2 loops, No such contract <- should be contact, beware of how you capitalize words
Norvin Burrus
@ndburrus
Jun 09 2016 00:02
@eduwin7 ...focus in here it multiplies the product variable by each number in the sub-arrays of arr :sparkles:
Stephen James
@sjames1958gm
Jun 09 2016 00:02
@eduwin7 You have the product variable. That is supposed to ultimately contain the product of all the values.
Kathy Fan
@kathyfan
Jun 09 2016 00:03
hey! what if on a page, i wrote //noprotect and caused the page to crash, and now when i try to re-open the page it always crashes before i have the chance to click "reset" or something? any way to fix it so i can go back to the challenge?
Eric
@Code-Eric
Jun 09 2016 00:04
@kathyfan have you tried a different browser? I dont know if that will make a difference haha
Diego Mayer
@Chrono79
Jun 09 2016 00:04
help infinite loop
CamperBot
@camperbot
Jun 09 2016 00:04
no wiki entry for: infinite loop
Diego Mayer
@Chrono79
Jun 09 2016 00:05
which challenge is it? @kathyfan
eduwin7
@eduwin7
Jun 09 2016 00:05
okay so product *=
Stephen James
@sjames1958gm
Jun 09 2016 00:05
@eduwin7 Check!
eduwin7
@eduwin7
Jun 09 2016 00:05
and not console.log
thanks @sjames1958gm
CamperBot
@camperbot
Jun 09 2016 00:05
eduwin7 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: eduwin7 already gave sjames1958gm points
Stephen James
@sjames1958gm
Jun 09 2016 00:05
@eduwin7 Yes console.log is good for debugging by writing info to the console, it does not return values from the function.
Rémi Fortier
@mizujin
Jun 09 2016 00:05
Hello people, what would be the correct way to load a Json data file in another file ? This json contains some data much like a DB but i'm working locally and doesn't need mongo or such
eduwin7
@eduwin7
Jun 09 2016 00:06
omg thanks. I need to take some classes
and or keep talking to you guys here. thanks a lot.
Stephen James
@sjames1958gm
Jun 09 2016 00:07
Try to not take the example too literally. Use them as a guide
Kathy Fan
@kathyfan
Jun 09 2016 00:07
@Code-Eric hmm yeah all my code is erased in a different browser so i guess that works too. @Chrono79 it's the javascript while loop iteration one haha
Stephen James
@sjames1958gm
Jun 09 2016 00:08
help reset
CamperBot
@camperbot
Jun 09 2016 00:08
no wiki entry for: reset
Diego Mayer
@Chrono79
Jun 09 2016 00:09
@kathyfan you can copy and paste the url, deleting all that's after (including) ?
Kathy Fan
@kathyfan
Jun 09 2016 00:10
fixed; thanks guys!
Stephen James
@sjames1958gm
Jun 09 2016 00:13
@kathyfan :+1:
Eric
@Code-Eric
Jun 09 2016 00:17
is anyone free to help out with the dilemma I am having?
Joe B
@jbreality
Jun 09 2016 00:18
is anybody able to help with my quote generator page? I'm not sure what I'm screwing up
I'm not sure why when I click the button it doesn't change that P, I know right now it will not overwrite testing3, but I just want the quote to show up
David Halls
@DavidHalls
Jun 09 2016 00:20
@jbreality your function declarations for get quote seems weird, has it worked like that for you in the past?
Joe B
@jbreality
Jun 09 2016 00:21
it's an option I found to do for this, I'm open to adjusting it, but I've spent days on this so far with not much luck using these API's heh
even if I add it to the getQuote() on click function, it doesn't add the message
David Halls
@DavidHalls
Jun 09 2016 00:27
@jbreality well it is probably something with your ajax call
Joe B
@jbreality
Jun 09 2016 00:28
any idea what? it looks fairly simple, the URL works, it's jsonp
David Halls
@DavidHalls
Jun 09 2016 00:30
@jbreality have you been able to change that p element with the button click?
Joe B
@jbreality
Jun 09 2016 00:30
not yet, I even tried with just some basic text
but I'm not 100% familiar with ajax, it looks right from what I've read, and ther'es only 4 lines
David Halls
@DavidHalls
Jun 09 2016 00:34
@jbreality it looks like jquery is not working, i put this to your function and can change that element function getQuote() {
alert('this');
document.getElementById('quote-content').innerHTML = 'bye';
Joe B
@jbreality
Jun 09 2016 00:35
if jquery wasn't working, wouldn't the page not change colors when you click get message?
can someone help me with this
David Halls
@DavidHalls
Jun 09 2016 00:39
@jbreality yea, i see that it is working there, the problem looks to be in the getQuote function, dont know what it is though as i did not use that
Joe B
@jbreality
Jun 09 2016 00:40
yea, I've tried like 4-5 different ways and none of them have worked so far :-/
I can create an array with a bunch of quotes on it, but I want to try to use an API
skipperhi
@skipperhi
Jun 09 2016 00:41
@emmanuelledebarge You don't need more than one line of code, it should all be in the gloveBoxContents variable. Also, you forgot to go "inside" the car
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 00:42
h @skipperhi thanks
CamperBot
@camperbot
Jun 09 2016 00:42
emmanuelledebarge sends brownie points to @skipperhi :sparkles: :thumbsup: :sparkles:
:cookie: 258 | @skipperhi |http://www.freecodecamp.com/skipperhi
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 00:43
@skipperhi var myStorage = myStorage.car.inside["glove box"];
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 09 2016 00:43
Can anyone help me with Using objects for Lookups ?
skipperhi
@skipperhi
Jun 09 2016 00:43
@emmanuelledebarge Yep!
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 09 2016 00:43

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

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

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

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

skipperhi
@skipperhi
Jun 09 2016 00:45
@NguyenThuongHuy When accessing an array with a variable, you have to use bracket notation i.e. array[var]
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 09 2016 00:46
@skipperhi oh yeah, i forgot i should use bracket
Cathy Sullivan
@cesullivan
Jun 09 2016 00:46
Hi everyone.
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 09 2016 00:46
@skipperhi Thank you!
CamperBot
@camperbot
Jun 09 2016 00:46
nguyenthuonghuy sends brownie points to @skipperhi :sparkles: :thumbsup: :sparkles:
:cookie: 259 | @skipperhi |http://www.freecodecamp.com/skipperhi
skipperhi
@skipperhi
Jun 09 2016 00:47
@cesullivan Hi Cathy
@NguyenThuongHuy Anytime :thumbsup:
Cathy Sullivan
@cesullivan
Jun 09 2016 00:47
@skipperhi I am working on the Record Collection
bscyrpt
@bscyrpt
Jun 09 2016 00:48
@jbreality the url is not returning any data, i've tried several but getting nothing, its throwing an error every time
Cathy Sullivan
@cesullivan
Jun 09 2016 00:48
When I try to delete a prop, the prop is still there but it is empty.
skipperhi
@skipperhi
Jun 09 2016 00:48
@cesullivan What do you use to delete the prop?
Juwdohr
@Juwdohr
Jun 09 2016 00:48
Hey any one know how to control the length of an audio file in javascript?
Cathy Sullivan
@cesullivan
Jun 09 2016 00:49
var album = collection[id]; delete album[prop];
Thomas Mullen
@t-mullen
Jun 09 2016 00:49

Hey guys, I got a question:
I have a javascript module containing several submodules. It passes configuration options through a global object. Like this:

var ParentModule = (function (module) {
    var global = {};
    var ChildModule = (function(global){
           // Need to use global.prop
   })(global);

    module.initialize = function(){
            global = {prop: "value"};
    }
}({}));

I thought this should work, but I guess global.prop is undefined since when it's passed to ChildModule it's empty, and isn't initialized until later?

Wouldn't changing global later also change global in ChildModule? Isn't a reference passed? Is there another way I can do this?

skipperhi
@skipperhi
Jun 09 2016 00:50
@cesullivan Well it seems right, can you send me the link?
Cathy Sullivan
@cesullivan
Jun 09 2016 00:50
Just the link from the page I'm working on? This is my first time asking help.
channsin
@channsin
Jun 09 2016 00:50
thanks @Chrono79 @JonesFuego
CamperBot
@camperbot
Jun 09 2016 00:50
channsin sends brownie points to @chrono79 and @jonesfuego :sparkles: :thumbsup: :sparkles:
:star2: 1102 | @chrono79 |http://www.freecodecamp.com/chrono79
:warning: could not find receiver for jonesfuego
skipperhi
@skipperhi
Jun 09 2016 00:50
@cesullivan Yeah, just the link will work
Cathy Sullivan
@cesullivan
Jun 09 2016 00:50
This message was deleted
Eeep. Next time I'll got to tinyurl or something
Diego Mayer
@Chrono79
Jun 09 2016 00:51
@cesullivan better paste the code
help format
CamperBot
@camperbot
Jun 09 2016 00:51

: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

colin aulds
@auldsyababua
Jun 09 2016 00:53
can someone tell me why im getting a reference error: wheels is not defined? here

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

var myCar = new Car(3,1,2);

Cathy Sullivan
@cesullivan
Jun 09 2016 00:53
// 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) {

  var album = collection[id];

  var hasProp = album.hasOwnProperty[prop];

  if (!hasProp & prop === "tracks") {
    album[prop] = [];
    album[prop].push(value);
  }    
  else if (!hasProp) {
    album[prop] = value;
  }    
  else if (hasProp & value.length === 0 ) {
    delete album[prop];    
  }
  else if (hasProp & prop === "tracks") {     
    album[prop].push(value);
  }
  else if (hasProp) {
    album[prop] = value;
  }  
  return collection;
}

// Alter values below to test your code
  updateRecords(5439, "artist", "ABBA");
  updateRecords(5439, "tracks", "Take a Chance on Me");
  updateRecords(2548, "artist", "");
// updateRecords(1245, "tracks", "Blue Green");
CamperBot
@camperbot
Jun 09 2016 00:53
:bulb: to format code use backticks! ``` more info
Diego Mayer
@Chrono79
Jun 09 2016 00:56
@cesullivan hasOwnProperty is a method, use it with () instead of []
Cathy Sullivan
@cesullivan
Jun 09 2016 00:57
That was it. Thanks @Chrono79
CamperBot
@camperbot
Jun 09 2016 00:57
cesullivan sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1103 | @chrono79 |http://www.freecodecamp.com/chrono79
Thomas Mullen
@t-mullen
Jun 09 2016 00:58
Solution to my question if anyone is wondering:
var ParentModule = (function (module) {
    var global = {};
    var ChildModule = (function(){ //Do not pass global to child
           // Need to use global.prop
   })(); //Do not pass global to child

    module.initialize = function(){
            global = {prop: "value"};
    }
}({}));
Diego Mayer
@Chrono79
Jun 09 2016 00:58
@cesullivan no problem, you could refactor your code to make it shorter
Cathy Sullivan
@cesullivan
Jun 09 2016 01:00
True. Thanks again.
Robert Friedman
@robfr77
Jun 09 2016 01:12

can anyone help me with this native javascript api? I'm used to jquery and idk why this isn't working using classList to toggle a class off and on

var disabled = document.querySelector('.disabled');
disabled.classList.toggle('disabled');

error: cannot read property classList of null
OK i see react doesn't support this...

Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 01:13
This message was deleted
Joe B
@jbreality
Jun 09 2016 01:16
so going one by one, I figure out where it stops working
it's when I do success : function(){$("#quote-text").html("Testing..Testing..Testing");}
if I remove the fucntion(){} and just have $("#quote-text").html("Testing..Testing..Testing"); it works
IndiraShrestha
@IndiraShrestha
Jun 09 2016 01:17
for (j = 0; j <= contacts[i].likes.length; j++){
        return contacts[i][j];
      }
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i <= contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (prop == contacts[i].lastName){
        return contacts[i].lastName;
      } else if (prop == contacts[i].number){
        return contacts[i].number;
      } else if (prop == contacts[i].likes){
        for (j=0; j<= contacts[i].likes.length; j++){
          return contacts[i].likes[j];
        }
      }

    } else if (firstName != contacts[i].firstName){
      return "No such contact";
    } else if (prop != contacts[i].likes){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
how do i get the property of object firstName
where did i go wrong
Eclogesh
@Eclogesh
Jun 09 2016 01:18
what does it mean myVar = myVar should be changed
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 01:20
This message was deleted
This message was deleted
Eclogesh
@Eclogesh
Jun 09 2016 01:23
Any inputs.. I didn't understand the question of myVar = myVar has to be changed..
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 01:23
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = "pine"; // Change this line
 myPlants[1].list[1];
can someone help with with this
Stephen James
@sjames1958gm
Jun 09 2016 01:24
@IndiraShrestha You are comparing prop to the value of various properties which is not the challenge. You are supposed to check if prop is a property on the contact and then return the value.
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 01:25
Retrieve the second tree from the variable myPlants using object dot and array bracket notation
Tomislav
@lastJson
Jun 09 2016 01:25
.hasOwnProperty()
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 01:25
those arre the instructions
Blake Harris
@bharris62
Jun 09 2016 01:25
I am working on the algo challenge 'Search and Replace' how do I go about preserving the initial casing?
my code (that replaces, but doesn't preserve)
function myReplace(str, before, after) {
  var initialArray = str.split(" ");
  var start = initialArray.indexOf(before);
  var removed = initialArray.splice(start, 1, after);
  var newArray = initialArray.join(" ");
  return newArray;
}

myReplace("Let us get back to more Coding", "Coding", "algorithms");
Puvendran Pillay
@puven12
Jun 09 2016 01:25
Hey guys do you know what javascript to use?
Tomislav
@lastJson
Jun 09 2016 01:26
?
Stephen James
@sjames1958gm
Jun 09 2016 01:26
@bharris62 You can check the case of before and then modify after to match.
Puvendran Pillay
@puven12
Jun 09 2016 01:26
  • we are using in FCC
Blake Harris
@bharris62
Jun 09 2016 01:26
ah thats clever. I'll give that a go, thanks @sjames1958gm
CamperBot
@camperbot
Jun 09 2016 01:26
bharris62 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1487 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 09 2016 01:27
@bharris62 :+1:
Puvendran Pillay
@puven12
Jun 09 2016 01:27
what is the javascript version we are using?
Tomislav
@lastJson
Jun 09 2016 01:28
probably es5
Puvendran Pillay
@puven12
Jun 09 2016 01:28

Node v0.10.33
Node v0.10.33/Babel
Node v6.0.0
Node v6.0.0/Babel

which one ?

Blake Harris
@bharris62
Jun 09 2016 01:28
i've used some es6, its usually allows it (prob depends on broswer) but you will get a warning
just use the most recent versiono
i have
Puvendran Pillay
@puven12
Jun 09 2016 01:29
im practising js in codewars.com so thats the options i have?

Node v0.10.33
Node v0.10.33/Babel
Node v6.0.0
Node v6.0.0/Babel

which one ?

Lucati
@Lucati
Jun 09 2016 01:31
hey, i'm working on the counting card chalenge
my result is correct but i can't pass the chalenge
GGvibes
@GGvibes
Jun 09 2016 01:32
Hey @Lucati I am having problems with this one too. My results are only right for count <= 0..
Puvendran Pillay
@puven12
Jun 09 2016 01:33
@Lucati can i see your code?
Lucati
@Lucati
Jun 09 2016 01:33
@GGvibes i'm using ifs on the function going to put it here

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

if(card >= 2 && card <= 6){
count++;
}
else if(card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A'){
count--;

}
if(count > 0){
return "\"" + count + " Bet\"";
}
return "\"" + count + " Hold\"";

// Only change code above this line
}

GGvibes
@GGvibes
Jun 09 2016 01:33
Yours is right for both positive and negative ?
Lucati
@Lucati
Jun 09 2016 01:34
yes try it
Moisés Man
@moigithub
Jun 09 2016 01:34
no need to add \"
Taylor Bostick
@Taylorbostick32
Jun 09 2016 01:34
I'm stcuk on return early pattern for functions. I have been trying for the past hour and cant figur it out. can someone please help me out.
Puvendran Pillay
@puven12
Jun 09 2016 01:34
use single quotes
GGvibes
@GGvibes
Jun 09 2016 01:34
I am using switch statement
Lucati
@Lucati
Jun 09 2016 01:35
ok
Puvendran Pillay
@puven12
Jun 09 2016 01:35
'Bet' or 'Hold'
IndiraShrestha
@IndiraShrestha
Jun 09 2016 01:35
@sjames1958gm I am having trouble getting through it
could you please point in the right direction?
Lucati
@Lucati
Jun 09 2016 01:38
@puven12 but that doesn't solve my problem
the results are correct but i can't pass the chalenge
Blake Harris
@bharris62
Jun 09 2016 01:41

function myReplace(str, before, after) {
  var ifUpper = '';

  if (before[0] == before.toUpperCase()){
    ifUpper = after[0].stringToUpper();
  }
  var initialArray = str.split(" ");
  var start = initialArray.indexOf(before);
  var removed = initialArray.splice(start, 1, ifUpper || after);
  var newArray = initialArray.join(" ");
  return newArray;
}

myReplace("Let us get back to more Coding", "Coding", "algorithms");
GGvibes
@GGvibes
Jun 09 2016 01:41
@Taylorbostick32 I was stuck on this for awhile too couldn't figure out why but it was simply because undefined should be written as a keyword with no quotes around it. It will appear purple
Blake Harris
@bharris62
Jun 09 2016 01:41
still kinda stuck
Joe B
@jbreality
Jun 09 2016 01:42
so I've tried a differnet API, but I'm still running into the same issue, I'm not sure why. my .ajax works, and it stops working as soon as I enter a function for success. if I put any other code next to success, it runs without issue.
GGvibes
@GGvibes
Jun 09 2016 01:42
how do you share code like that? @bharris62 haha still figuring this out
Blake Harris
@bharris62
Jun 09 2016 01:43
use 3 back ticks on top and 3 back ticks on bottom
backtick is they left of the 1
GGvibes
@GGvibes
Jun 09 2016 01:43
okay thanks! @bharris62
CamperBot
@camperbot
Jun 09 2016 01:43
ggvibes sends brownie points to @bharris62 :sparkles: :thumbsup: :sparkles:
:cookie: 305 | @bharris62 |http://www.freecodecamp.com/bharris62
Blake Harris
@bharris62
Jun 09 2016 01:43
you are welcome
GGvibes
@GGvibes
Jun 09 2016 01:44
@Lucati This is my function so far, still has an issue:
This message was deleted
This message was deleted
This message was deleted
function cc(card) {
// Only change code below this line
var count = 0;
switch(card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count = count + 1;
}
switch(card) {
case 10:
case "J":
case "Q":
case "K":
case "A":
count = count - 1;
}
switch(card) {
case 7:
case 8:
case 9:
count = count + 0;
}
if (count <= 0) {
return (count + " Hold");
}
else if (count > 0) {
return (count + " Bet");
}
Lucati
@Lucati
Jun 09 2016 01:47
u can put the count like count++ and count--
i don't like switch that's why i have used if else
GGvibes
@GGvibes
Jun 09 2016 01:47
oh yeah I know that not sure if that will help though
Lucati
@Lucati
Jun 09 2016 01:48
no won't solve the problem is just an optimization
ok but remove the var = 0 inside of the function
GGvibes
@GGvibes
Jun 09 2016 01:49
Hah that fixed it. it worked lol
Lucati
@Lucati
Jun 09 2016 01:49
it's already declared outside of the function as global variable
;)
GGvibes
@GGvibes
Jun 09 2016 01:50
I saw it was already defined but thought it was showing up as not a variable since it was white
now I know
Thank you @Lucati !
CamperBot
@camperbot
Jun 09 2016 01:50
ggvibes sends brownie points to @lucati :sparkles: :thumbsup: :sparkles:
:cookie: 216 | @lucati |http://www.freecodecamp.com/lucati
Lucati
@Lucati
Jun 09 2016 01:50
(Y)
Joe B
@jbreality
Jun 09 2016 01:50
anybody able to help? I've been working ont his for days and I feel like I'm right here, but I can't figure out what's going wrong with my .ajax success line
Lucati
@Lucati
Jun 09 2016 01:52
it doesn't work for me, crazy
Joe B
@jbreality
Jun 09 2016 01:55
I'm not sure why at all
Alan Saber
@Alan95
Jun 09 2016 01:55
can someone help me withthe Golf Code? in the function GolfScore am i working for example with if (par, par + 1) {} etc. or with numbers?
Joe B
@jbreality
Jun 09 2016 01:55
I've tried multiple API's
Lucati
@Lucati
Jun 09 2016 01:58
@Alan95 it will be something like this
if(strokes == 1){
return "Hole-in-one!";
}
else if(strokes <= par - 2){
return "Eagle";
}
no you just need to do the other steps
Alan Saber
@Alan95
Jun 09 2016 01:59
so the value of par is unimportant for "Hole in One" ?
Lucati
@Lucati
Jun 09 2016 01:59
did you understand why @Alan95
yes because hole in one is just one stroke
when it's one u don't need to verify the par condition
Alan Saber
@Alan95
Jun 09 2016 02:01
and for return "par" its stroke = par ?
Lucati
@Lucati
Jun 09 2016 02:01
yes
but is stroke == par
Alan Saber
@Alan95
Jun 09 2016 02:02
ok thanks
thanks @Lucati
CamperBot
@camperbot
Jun 09 2016 02:02
alan95 sends brownie points to @lucati :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @lucati |http://www.freecodecamp.com/lucati
Lucati
@Lucati
Jun 09 2016 02:02
;)
one = is attribution 2 == is comparing
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:06
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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


  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
can someone help me its saying its not correct
it passes all the test except one
Sean DiSanti
@badc0ded
Jun 09 2016 02:06
which fails?
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:06
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Ramesh syangtan
@rameshsyn
Jun 09 2016 02:07
Hey , is there any ways to do this :smile:
var myArray = [1,2,3];   // change this array to string like below 
//myArray should be like this "[1,2,3]"
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:08
Hey , is there any ways to do this :smile:
var myArray = [1,2,3];   // change this array to string like below 
//myArray should be like this "[1,2,3]"
Lucati
@Lucati
Jun 09 2016 02:08
@rameshsyn no it will be like this ["1", "2","3"]
Sean DiSanti
@badc0ded
Jun 09 2016 02:08
your condition for handling 'tracks' prop doesn't create the array
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:08
@rameshsyn yea "
Sean DiSanti
@badc0ded
Jun 09 2016 02:08
it just assumes its there and tries to push to it
which won't work, because undefined doesn't have method "push"
Lucati
@Lucati
Jun 09 2016 02:09
sorry i get it now lol
Ramesh syangtan
@rameshsyn
Jun 09 2016 02:09
@emmanuelledebarge i can do that @Lucati :smile:
Sean DiSanti
@badc0ded
Jun 09 2016 02:09
so you have to check if the id hasOwnProperty(prop)
and push if it does, or create it and initialize it to an array, THEN push
make sense?
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:10
@badc0ded honestly, this stuff is confusing
@badc0ded i dont even understand what i am doing half the time when it comes to arrays and such
Alanna
@yerawizardlani
Jun 09 2016 02:10
hey, i’m working on the Factorialize a Number algorithm and it keeps saying that I have an infinite loop.

The code looks like this function factorialize(num) {
i = 1;
n = num;
while (i <= n){
n = i * n;
i++;
}
return num;
}

factorialize(5);

what am i doing wrong?
Sean DiSanti
@badc0ded
Jun 09 2016 02:11
it happens.
just take it slow, and if you want to supplement the fcc material a little, w3schools.com has a lot of info too
like....
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:12
ok @badc0ded thanks
CamperBot
@camperbot
Jun 09 2016 02:12
emmanuelledebarge sends brownie points to @badc0ded :sparkles: :thumbsup: :sparkles:
:cookie: 377 | @badc0ded |http://www.freecodecamp.com/badc0ded
Sean DiSanti
@badc0ded
Jun 09 2016 02:13
no problem
Ken Haduch
@khaduch
Jun 09 2016 02:13
@yerawizardlani - you are changing i within your loop, as well as changing n. If you don't have an actual infinite loop, a loop-detector might see that as a problem.
Sean DiSanti
@badc0ded
Jun 09 2016 02:13
did what i said about checking hasOwnProperty make sense?
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:14
@badc0ded no
well kinda
i should assign th .hasOwnProperty to id
Sean DiSanti
@badc0ded
Jun 09 2016 02:16
no, here i can explain it a little easier i think
i take that back, i actually have to run to get daughter from work
bitgrower
@bitgrower
Jun 09 2016 02:17

After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.

That seems to be a recently added test case ...

basically, you need to check to see if the property exists, if the property does not exist, it's easily added to the object with a line of code similar to this:

myObj[prop] = value;

Sean DiSanti
@badc0ded
Jun 09 2016 02:17
yes, bitgrower can explain
thanks @bitgrower
CamperBot
@camperbot
Jun 09 2016 02:17
badc0ded sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1089 | @bitgrower |http://www.freecodecamp.com/bitgrower
Lucati
@Lucati
Jun 09 2016 02:18
so how do u send brownies?? :smile:
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:19
@bitgrower where should i add it
bitgrower
@bitgrower
Jun 09 2016 02:19

i dont even understand what i am doing half the time when it comes to arrays and such

@emmanuelledebarge -- review, review, review ... it make take a bit for things to sink in ... if you haven't checked out the "video hikes" (listed toward the bottom of the map) ... it's useful to go thru those to understand a bit about what's actually happening within the computer ...

Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:20
@bitgrower I took a java class at school and we learned about all that.
bitgrower
@bitgrower
Jun 09 2016 02:21
when certain words are included in a comment along with a camper's name, @camperbot will give them brownie points ... like this ... thanks ! (note it doesn't matter where you put the name and the word, @camperbot will give the user a brownie point (only 1 at a time, only 1 per person to another person per hour) ... such as I can now say @bitgrower (of course, it will object !)
CamperBot
@camperbot
Jun 09 2016 02:21
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1852 | @camperbot |http://www.freecodecamp.com/camperbot
Ken Haduch
@khaduch
Jun 09 2016 02:22
@bitgrower - you gave camperbot brownie points - how could it object? :)
bitgrower
@bitgrower
Jun 09 2016 02:22
@emmanuelledebarge -- well, if you still don't understand half the time (I did quote the right person, right?) ... more review wouldn't hurt ... :)
ah ... I guess they fixed it so it doesn't give an error message when you mention your own name now ... it used to ...
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:22
@bitgrower yes thank you
CamperBot
@camperbot
Jun 09 2016 02:22
emmanuelledebarge sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1090 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 09 2016 02:22
yw
Lucati
@Lucati
Jun 09 2016 02:24
@bitgrower brownie points
damn
bitgrower
@bitgrower
Jun 09 2016 02:24
@emmanuelledebarge -- as for where to put the line ... I pretty much gave you what you need to do and the "template" for the line of code to use ... it's up to you to figure out where to put it ! :) For me to do so just doesn't seem fair ...
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:24
@Lucati thanks
CamperBot
@camperbot
Jun 09 2016 02:24
emmanuelledebarge sends brownie points to @lucati :sparkles: :thumbsup: :sparkles:
:cookie: 219 | @lucati |http://www.freecodecamp.com/lucati
bitgrower
@bitgrower
Jun 09 2016 02:24
thanks, tax ty tax @khaduch
CamperBot
@camperbot
Jun 09 2016 02:24
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1285 | @khaduch |http://www.freecodecamp.com/khaduch
Lucati
@Lucati
Jun 09 2016 02:24
ok ogt now
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:24
lol
bitgrower
@bitgrower
Jun 09 2016 02:24
all of those should do it ...
thank you also works ... there are some other ways of doing it that I've seen someone else use it -- but I haven't figured it out (and she hasn't told me ... yet ... she just said I'd figure it out .. LOL.)
thanks @camperbot
CamperBot
@camperbot
Jun 09 2016 02:25
bitgrower sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:warning: bitgrower already gave camperbot points
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:26
@camperbot thanks
CamperBot
@camperbot
Jun 09 2016 02:26
emmanuelledebarge sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1853 | @camperbot |http://www.freecodecamp.com/camperbot
ALMY91
@ALMY91
Jun 09 2016 02:26
can anybody tell me
bitgrower
@bitgrower
Jun 09 2016 02:26
see ... now @camperbot objects, because it hasn't been 60 min yet ... LOL @camperbot is a BOT ... doesn't really need points ... :)
ALMY91
@ALMY91
Jun 09 2016 02:26
whats the difference between a toString() method and toLocaleString() method
bitgrower
@bitgrower
Jun 09 2016 02:27
the other way you can get info (I think is mentioned in early FCC challenges) is by doing something like this:
help brownie
CamperBot
@camperbot
Jun 09 2016 02:27

:point_right: brownie points [wiki]

Brownie Points

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

A user profile picture next to a with Brownie Points score

There are two ways you can get Brownie Points:

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

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

They also add to your Streak.

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

bitgrower
@bitgrower
Jun 09 2016 02:27
This message was deleted
you can also use "find", "wiki" and <term> -- works for challenges as well ... like
help record collection
CamperBot
@camperbot
Jun 09 2016 02:27

:point_right: challenge record collection [wiki]

Challenge Record Collection

Instructions

You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.

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

For the given id in collection:

If value is non-blank (value !== ""), then update or set the value for the prop.

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.

:pencil: read more about challenge record collection on the FCC Wiki

Angelo Ryndon
@AIRyndon
Jun 09 2016 02:28
Halo Everyone! I'm at the Roman Numeral Converter. Here's what I did. Question is why am I getting inside that loop when the key is bigger than the number
function convertToRoman(num) {

  var convertedNumber = "";
  var romanNumbers = [{1:"I"},{4:"IV"},{5:"V"},{9:"IX"},{10:"X"},{40:"XL"},{50:"L"},
                    {90:"XC"},{100:"C"},{400:"CD"},{500:"D"},{900:"CM"},{1000:"M"}];
  var key = "";
  if(num > 0){
  romanNumbers.reverse().forEach(function(value){

    key = Object.keys(value);

    if(key < num.toString()){
        console.log(key);
       console.log(num.toString());
      convertedNumber += value[key];
      num -= parseInt(key);
      console.log(num);
    }    
  });
  }

 return convertedNumber;
}

convertToRoman(36);
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:28
i would thank you camperbot but i already gave you points
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:28
weird
ALMY91
@ALMY91
Jun 09 2016 02:29
HELLLOOOOO
HELLOOOOO
bitgrower
@bitgrower
Jun 09 2016 02:30
@ALMY91 -- it's used by the code to give location specific versions of the data ... the example given in MDN, for instance, talks about differences in how dates are represented in different "locales"
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:30
I mean inside the if condition within the loop
ALMY91
@ALMY91
Jun 09 2016 02:30
@bitgrower mdn?
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:30
Mozilla Dev Network
ALMY91
@ALMY91
Jun 09 2016 02:32
@bitgrower do u hv the link to the site?
Salomon May
@sollymay
Jun 09 2016 02:32
Hi guys! I am losing it with the arguments optional challenge. I don’t know how to go about it:(
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:32
@sollymay what challenge?
found the solution to my question...don't compare strings with <=...use parseInt lol
Joe B
@jbreality
Jun 09 2016 02:35
so for my local quote machine, it apparently is just a codepen issue, I moved the code to an editor, and it works fine
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:36
@sollymay what have you tried?
Salomon May
@sollymay
Jun 09 2016 02:40
something along the lines of this:
function addTogether() {
  if (arguments.length >0){
    if (arguments.length ==1){
      return addTogether();
    }
    else if(arguments.length ==2){
      if (isNaN(arguments[0]) || isNaN(arguments[1])){
        return undefined;
      }

      else {
        return arguments[0]+ arguments[1];
      }

    }
  }
  else return undefined;


}
bitgrower
@bitgrower
Jun 09 2016 02:40
@ALMY91 -- if you just type in toLocaleString into Google, it will be one of the results, toward the top ... as long as I've seen you in here ... I'm a bit surprised you don't know it yet (it's also mentioned in the FCC training, and many, many of the "helpful" links take you to the associated MDN page ...
ALMY91
@ALMY91
Jun 09 2016 02:41
was it under the basic Javascript challenges? @bitgrower
bitgrower
@bitgrower
Jun 09 2016 02:41
@sollymay just fyi -- isNaN can be very problematic if you don't know if you have a value which is of type number (and, yes, NaN is considered a "number") .. :)
ALMY91
@ALMY91
Jun 09 2016 02:42
@bitgrower cos so far ive just done that only haha
Salomon May
@sollymay
Jun 09 2016 02:42
@AIRyndon I know there are still a few things to consider, but I don’t quite understand how to do the addTogether(2)(2) part
like I am calling a function with arguments, and that has to return a function, right?
bitgrower
@bitgrower
Jun 09 2016 02:43
https://developer.mozilla.org/en-US/ (or whatever your locale is ... ) ... find yours, engrave it in your heart, your hand ...every place you'll look when you need JS help :) :) :)
Salomon May
@sollymay
Jun 09 2016 02:44
the other parts I know how to figure them out. the issue is how to return the function in order to do the right call
bitgrower
@bitgrower
Jun 09 2016 02:44
I don't know where it was first described, @ALMY91 -- but a good 75% of the "helpful links" of which I'm sure there are some in the basic js challenges ... go to MDN ...
IndiraShrestha
@IndiraShrestha
Jun 09 2016 02:46
Hi All, I am working on profile lookup and having trouble with the understanding
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i <= contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (prop == contacts[i].lastName){
        return contacts[i].lastName;
      } else if (prop == contacts[i].number){
        return contacts[i].number;
      } else if (prop == contacts[i].likes){
        for (j=0; j<= contacts[i].likes.length; j++){
          return contacts[i].likes[j];
        }
      }

    } else if (firstName != contacts[i].firstName){
      return "No such contact";
    } else if (prop != contacts[i].likes){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Can anyone point me in right direction
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:51
i changed my code i dont understand whats wrong
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0A%20%20if%20(prop%20%3D%3D%3D%20%22tracks%22%20%26%26%20value%20!%3D%3D%20%22%22)%20%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%20%20%7D%20else%20if%20(value%20!%3D%3D%20%22%22)%7B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D%20%3D%20value%3B%0A%20%20%7D%20else%20%7B%0A%20%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%7D%0A%0A%0A%20%20return%20collection%3B%0A%7D%0A%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
Angelo Ryndon
@AIRyndon
Jun 09 2016 02:55
@sollymay sorry my browser crashed..access what you passed to the first function on the function it returned
Xavier Sumba
@cuent
Jun 09 2016 02:55

@cuent
Hello. Why in this problem:

Drop it
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.

The second argument, func, is a function you'll use to test the first elements of the array to decide if you should drop it or not.

Return the rest of the array, otherwise return an empty array.

dropElements([0, 1, 0, 1], function(n) {return n === 1;}) should return [1, 0, 1].
?

Angelo Ryndon
@AIRyndon
Jun 09 2016 02:55
@sollymay in case you only pass 1 argument
@sollymay that is the tricky part for you I think
Ken Haduch
@khaduch
Jun 09 2016 02:55
@emmanuelledebarge - I have not been following your changes, it looks like you only have one case left. The difference about that one that is failing is that you are being given a "tracks" entry to add to an album that currently has no tracks record. So you have to check for that case, and add it a little differently than just simply using the .push() method.
Norvin Burrus
@ndburrus
Jun 09 2016 02:56
@IndiraShrestha are you wanting to follow the logic in the same order as it given?
IndiraShrestha
@IndiraShrestha
Jun 09 2016 02:56
yes but i feel lost
i am not fully able to grasp the concept and struggling with it
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 02:58
@khaduch so i need to add another else if statement?
Norvin Burrus
@ndburrus
Jun 09 2016 02:59
@IndiraShrestha well, the first if statement logic looks accurate. the second if statement (if you're mapping to the exercise logic in order) should check for and the given property (prop) is a property of that contact. the code has (for the 2nd if statement) if (prop == contacts[i].lastName){ to check if the given prop is present, we would need to use bracket notation, as opposed to dot notation...
Salomon May
@sollymay
Jun 09 2016 03:00
yeahhhhhhhh @AIRyndon just did it!!! Thanks!
CamperBot
@camperbot
Jun 09 2016 03:00
sollymay sends brownie points to @airyndon :sparkles: :thumbsup: :sparkles:
:cookie: 293 | @airyndon |http://www.freecodecamp.com/airyndon
Angelo Ryndon
@AIRyndon
Jun 09 2016 03:01
@sollymay NP :)
Ken Haduch
@khaduch
Jun 09 2016 03:02
@emmanuelledebarge - yes, and it should be connected to the prop === 'tracks' section - there are two cases, if the object has a tracks property already, or if it doesn't - you are currently using the assumption that it does have a tracks property - you have to test for that.
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:04
@ndburrus How do i check the given property (prop) is a property of that contact.
if (firstName == contacts[i].firstName && prop = ){
i am using && prop
but what condition do i use for prop?
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 03:07
@khaduch so i have to use .hasOwnProperty
Norvin Burrus
@ndburrus
Jun 09 2016 03:08
@IndiraShrestha ok, the first if statment check for a match on the record firstname. Within that record, we need to check if the prop is present. so, we could start with the contacts record, and use the same i counter/loop variable. but, we need to add prop to see if prop is available/present. we already mentioned that we should use bracket notation because prop is a variable. so, can you write this if statement?
Dan
@dcgoings
Jun 09 2016 03:09

alright, running into a little dilemma here. not looking for an answer, just a point in the right direction on the "check for palindromes" alg challenge. this is what i have so far:

function palindrome(str) {
  var forwardArr = [];
  var backwardArr = [];

  for (var i = 0; i < str.length; i++) {
    if (str[i].match(/[a-z]/i)) {
      forwardArr.push(str[i]);
    }  
  }

  var forwardStr = forwardArr.join('');

  backwardArr = forwardArr.reverse();

  var backwardStr = backwardArr.join('');

  //return backwardStr + "\n" + forwardStr;

  if (forwardStr.toLowerCase() == backwardStr.toLowerCase()){
    return true;
  } else return false;
}

palindrome("1 eye for of 1 eye.");

this solution satisfies everything EXCEPT when there is a damn number (i.e. "1 eye for of 1 eye"). ive been racking my brain on this for a few hours now.

Ken Haduch
@khaduch
Jun 09 2016 03:10
@emmanuelledebarge - that should do it!
Dan
@dcgoings
Jun 09 2016 03:10
hmm...
hahahahahaha, oh man. all i had to add was one little piece of code. :)
Ken Haduch
@khaduch
Jun 09 2016 03:12
@dcgoings - Hello there - you can use a regular expression to eliminate all of the non-word + underscore characters from the string, which looks like you're trying to do that with your .match and loop there. That makes it easier to deal with the numbers and get the other kruft out of the way.
Dan
@dcgoings
Jun 09 2016 03:12
yep!! i just realized i could do "a-z0-9"
i just found out i could do that haha
that solved it. thanks @khaduch !
CamperBot
@camperbot
Jun 09 2016 03:13
dcgoings sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1286 | @khaduch |http://www.freecodecamp.com/khaduch
Dan
@dcgoings
Jun 09 2016 03:14
@khaduch -- is there anything you would / i should have done differently or more efficiently, you think?
Ken Haduch
@khaduch
Jun 09 2016 03:15
@dcgoings - well, I just looked at my version, and it was two lines of code. And it could probably be one, somehow... but the point is that you could have shortened things a bit.
Dan
@dcgoings
Jun 09 2016 03:15
that's depressing. :(
Ken Haduch
@khaduch
Jun 09 2016 03:17
@dcgoings - actually, you probably have everything in there, I was able to chain things together, I used a replace with a regular expression to just get the funky characters out of there, and that made it happen. Getting it to work is the first step - congratulations on that!. You just have some extra steps in there.
Dan
@dcgoings
Jun 09 2016 03:17
awesome, great to know. sounds a bit more promising then! i just need to streamline it. thanks again!
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:18

@ndburrus ```
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i <= contacts.length; i++){
if (firstName == contacts[i].firstName){
if (prop == contacts[i][prop]){
if (prop == contacts[i].likes){
for (j=0; j<= contacts[i].likes.length; j++){
return contacts[i].likes[j];
}
} return contacts[i][prop];
}

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

}
// Only change code above this line
}

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

function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i <= contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (prop == contacts[i][prop]){
        if (prop == contacts[i].likes){
          for (j=0; j<= contacts[i].likes.length; j++){
          return contacts[i].likes[j];
         }
        } return contacts[i][prop];  
      }

    } else if (firstName != contacts[i].firstName){
      return "No such contact";
    } else if (prop != contacts[i].likes){
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
@ndburrus no success
Ken Haduch
@khaduch
Jun 09 2016 03:19

@dcgoings - here is one example of how you can tighten up your code - you have this at the end:

if (forwardStr.toLowerCase() == backwardStr.toLowerCase()){
    return true;
  } else return false;

it could just be:

return forwardStr.toLowerCase() == backwardStr.toLowerCase();

Some of the other things that you did were just small inefficiencies, like you could convert the string to lowercase, strip out the characters, and then just reverse the string (withoug the extra .toLowerCase() calls.)

Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 03:19
This message was deleted

` function updateRecords(id, prop, value) {
if(collection[id].hasOwnProperty(prop))
collection[id][prop].push(value);
else
collection[id][prop]=[value];
collection[id][prop].push(value);

return collection; `

Norvin Burrus
@ndburrus
Jun 09 2016 03:20
@IndiraShrestha ok, in this statement if (prop == contacts[i][prop]){, we really don't need the prop == part. contacts[i][prop] checks to see if prop exists for the firstname record match... see that?
Dan
@dcgoings
Jun 09 2016 03:21
that definitely makes sense. i actually had that at first and i set it back for some weird reason, thinking that was why my code was failing with the "1 eye for of 1 eye" haha. silly mistakes.
your suggestions definitely make a lot of sense though.
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 03:21
whats wrong i checked it and now it doesnt pass at all
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:21
@ndburrus but aren't we checking he given property (prop) is a property of that contact.
the given*
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 03:23
https://www.freecodecamp.com/challenges/record-collection#?solution=%0A%2F%2F%20Setup%0Avar%20collection%20%3D%20%7B%0A%20%20%20%202548%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22Slippery%20When%20Wet%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Bon%20Jovi%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%22Let%20It%20Rock%22%2C%20%0A%20%20%20%20%20%20%20%20%22You%20Give%20Love%20a%20Bad%20Name%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%202468%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%221999%22%2C%0A%20%20%20%20%20%20artist%3A%20%22Prince%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%0A%20%20%20%20%20%20%20%20%221999%22%2C%20%0A%20%20%20%20%20%20%20%20%22Little%20Red%20Corvette%22%20%0A%20%20%20%20%20%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%201245%3A%20%7B%0A%20%20%20%20%20%20artist%3A%20%22Robert%20Palmer%22%2C%0A%20%20%20%20%20%20tracks%3A%20%5B%20%5D%0A%20%20%20%20%7D%2C%0A%20%20%20%205439%3A%20%7B%0A%20%20%20%20%20%20album%3A%20%22ABBA%20Gold%22%0A%20%20%20%20%7D%0A%7D%3B%0A%2F%2F%20Keep%20a%20copy%20of%20the%20collection%20for%20tests%0Avar%20collectionCopy%20%3D%20JSON.parse(JSON.stringify(collection))%3B%0A%0A%2F%2F%20Only%20change%20code%20below%20this%20line%0Afunction%20updateRecords(id%2C%20prop%2C%20value)%20%7B%0Aif(collection%5Bid%5D.hasOwnProperty(prop))%0A%20%20%20%20%20%20collection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%20%20%20%20else%20if%20(value%20%3D%3D%3D%20%22%22)%20%7B%0A%20%20%20delete%20collection%5Bid%5D%5Bprop%5D%3B%0A%20%20%7D%0A%20%20%0A%20%20else%0A%20%20%20%20%20%20collection%5Bid%5D%5Bprop%5D%3D%5Bvalue%5D%3B%0A%20%20%20%20collection%5Bid%5D%5Bprop%5D.push(value)%3B%0A%0A%20%0A%20%20return%20collection%3B%0A%7D%0A%0A%20%20%0A%2F%2F%20Alter%20values%20below%20to%20test%20your%20code%0AupdateRecords(5439%2C%20%22artist%22%2C%20%22ABBA%22)%3B%0A%0A
anyways not it works but the other 2 cases failed
Norvin Burrus
@ndburrus
Jun 09 2016 03:23
@IndiraShrestha yes, we have identfied "that contact" with the first if statement/loop.... now we check that record for a macth to the input prop variable. it, the next if statement, will evaluate to true of false..
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:24
i thought the second if statement was checking for the input prop variable
Norvin Burrus
@ndburrus
Jun 09 2016 03:24
it is.. just take off the unecessary part - prop ==
spaceforestchu
@spaceforestchu
Jun 09 2016 03:25
help
CamperBot
@camperbot
Jun 09 2016 03:25

CamperBot

Hi, I'm CamperBot! I can help you in this chatroom :smile:

Basic Commands:

  • find TOPIC find all entries about topic. e.g. find js
  • wiki TOPIC show contents of topic page
  • thanks @username send brownie points to another user
  • about @username shows info on that user
  • Algorithm BONFIRENAME info on a Algorithm

meet CamperBot in FreeCodeCamp/camperbotPlayground

:pencil: read more about camperbot on the FCC Wiki

IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:25
what would the condition be in the if statement
spaceforestchu
@spaceforestchu
Jun 09 2016 03:25
find Return Largest Numbers in Arrays
CamperBot
@camperbot
Jun 09 2016 03:25
find return largest numbers in arrays
nothing found
spaceforestchu
@spaceforestchu
Jun 09 2016 03:25
find Return Largest Numbers in Arrays
Eclogesh
@Eclogesh
Jun 09 2016 03:25
@erictleung .. I saw your response ..But i dont understand why the ticket is closed without even discussing what was the actual issue
CamperBot
@camperbot
Jun 09 2016 03:25

find return largest numbers in arrays

:zero: algorithm return largest numbers in arrays

Ken Haduch
@khaduch
Jun 09 2016 03:27
@Eclogesh - the ticket system is for problems that exist in the code, not for help with solutions for problems. It looks like you just have incorrect code for that particular challenge, so typically they close the ticket after making that comment about coming to the chat rooms for coding help, otherwise the ticket system would just be overloaded with open tickets...
Norvin Burrus
@ndburrus
Jun 09 2016 03:27
@IndiraShrestha if (contacts[i][prop]) the same as you had without the prop ==
charlieb410
@charlieb410
Jun 09 2016 03:28
I have the code all correct outputs for caesars cipher but still cant pass. can someone help me understand what im doing wrong? any help would be greatly appreciated. thanks in advance. heres my code:
Eclogesh
@Eclogesh
Jun 09 2016 03:28
@khaduch ..ok let say the question itself not clear where as it was pretty much staright forward myVar = myVar should be changed
?
what does it indicates
charlieb410
@charlieb410
Jun 09 2016 03:29

function rot13(str) {
var output ="";

for(var i= 0;i < str.length - 1;i++){

var charCode = str.charCodeAt(i);

  if(charCode == 32){
output += "";
  }
else if(charCode > 77){
    charCode-=13;
}
else{
    charCode+=13;
}

output += String.fromCharCode(charCode);

}

if(str.charAt(str.length - 1) == '?' || str.charAt(str.length - 1) == '!' || str.charAt(str.length - 1) == '.')
output += str.charAt(str.length - 1);
else{
var decodeChar = str.charCodeAt(str.length - 1);
if(decodeChar > 77){
decodeChar -= 13;
}
else{
decodeChar += 13;
}
var str1 = String.fromCharCode(decodeChar);

output += str1;

}
return '"'+output+'"';
}

rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.");

Eclogesh
@Eclogesh
Jun 09 2016 03:31
@khaduch could you please respond..
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:31
@ndburrus so let's say the argument for the function was ("Akira", "likes") that would set the if (contacts[i][prop]) if (likes){..... };
there isn't really a condition out there
Ken Haduch
@khaduch
Jun 09 2016 03:31

@Eclogesh - the instructions / explanation are:

You can easily increment or add one to a variable with the ++ operator.

i++;

is the equivalent of

i = i + 1;

Note
The entire line becomes i++;, eliminating the need for the equal sign.

So they just want you to do this:

Instructions
Change the code to use the ++ operator on myVar.

and if you put those instructions together with the test results and see where it is failing, you will find that myVar should equal 88, and it starts out at 87so they just want you to increment it with the ++ operator. And take away any code that has an equal sign in it.

Eclogesh
@Eclogesh
Jun 09 2016 03:32
@khaduch i think there is a mis understanding
Norvin Burrus
@ndburrus
Jun 09 2016 03:32
@IndiraShrestha so that would return false... wait, that would return true becuae Akira does have a likes property... make ense?
Eclogesh
@Eclogesh
Jun 09 2016 03:32
let me paste the code .. And why the ticket has been raised. if i missed anything i am happy to go back and check it
@khaduch .. the challenge was myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line

and what code i had was
var myVar = 87;

// Only change code below this line

myVar = myVar+1;

myVar = myVar++;

@khaduch @Eclogesh
let me paste the code .. And why the ticket has been raised. if i missed anything i am happy to go back and check it
the challenge was myVar should equal 88
myVar = myVar should be changed
Use the ++ operator
Do not change code above the line
and what code i had was
var myVar = 87;

// Only change code below this line

myVar = myVar+1;

myVar = myVar++;

Ken Haduch
@khaduch
Jun 09 2016 03:34

@Eclogesh - you possibly misunderstood the information or the explanation is not clear enough for you. The original line of code is this:

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

So they just want you to follow the example that they had in the text description and use the ++ operator instead of the myVar = myVar + 1; method.

IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:34

@ndburrus I am really having trouble understanding the concept out here ```
function lookUpProfile(firstName, prop){
// Only change code below this line
for (i = 0; i <= contacts.length; i++){
if (firstName == contacts[i].firstName){
if (contacts[i][prop]){
if (prop == contacts[i].likes){
for (j=0; j<= contacts[i].likes.length; j++){
return contacts[i].likes[j];
}
} return contacts[i][prop];
}

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

}
// Only change code above this line
}```

function lookUpProfile(firstName, prop){
// Only change code below this line
  for (i = 0; i <= contacts.length; i++){
    if (firstName == contacts[i].firstName){
      if (contacts[i][prop]){
        if (prop == contacts[i].likes){
          for (j=0; j<= contacts[i].likes.length; j++){
          return contacts[i].likes[j];
         }
        } return contacts[i][prop];  
      }

    } else if (firstName != contacts[i].firstName){
      return "No such contact";
    } else if (prop != contacts[i].likes){
      return "No such property";
    }
  }
// Only change code above this line
}
Eclogesh
@Eclogesh
Jun 09 2016 03:35
@khaduch i do have it at the last .. If you look at m code..
Norvin Burrus
@ndburrus
Jun 09 2016 03:35
@IndiraShrestha ok, do you understand that this statement if (contacts[i][prop]){ checks to see if the inputted variable prop is in the record being looped?
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:36
@ndburrus yes that would return true
Eclogesh
@Eclogesh
Jun 09 2016 03:36
blob
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:36
now that i get it but i think i am missing out something
Eclogesh
@Eclogesh
Jun 09 2016 03:36
@khaduch i think the attachment will be clear..of my issue.Still i didnt get what i have missed
Norvin Burrus
@ndburrus
Jun 09 2016 03:36
@IndiraShrestha ok, so if true, then we need to: If both are true, then return the "value" of that property. this is where we are. we have received 2 true conditions..
Ken Haduch
@khaduch
Jun 09 2016 03:38

@Eclogesh - but you have done more than you were instructed to do, and incorrectly. The example says that instead of having this code:

i = i + 1;

you can just have this code:

i++;

Now in the code for you to work on, you have var myVar = 87;, and you have to get myVar to be equal to 88, using the ++ operator. So you are keeping the myVar = myVar + 1; and adding another line to it, when all you need to do is use myVar++; - it should then pass the test. You were just adding too many things, just make that simple change, as per the description.

Norvin Burrus
@ndburrus
Jun 09 2016 03:40
@IndiraShrestha so how would we return the prop?
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:40
@ndburrus return contacts[i][prop];
@ndburrus return contacts[i][prop];
Norvin Burrus
@ndburrus
Jun 09 2016 03:40
@IndiraShrestha nice... ready to move on?
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:40
but since likes is an array i will have to use for loop to loop through it
Eclogesh
@Eclogesh
Jun 09 2016 03:41
@khaduch sorry i didnt work..Please look at the screenshot
blob
@khaduch i have only problem with this increment..
Ken Haduch
@khaduch
Jun 09 2016 03:42

@Eclogesh - you haven't put in the correct code to do what they are asking. You did, indeed, use the ++ operator, but you didn't do it correctly. You should change the line that initially reads myVar = myVar + 1;

Just reset your code and redo that as you now have it, or reload the page, it might have the incorrect information cached in the browser.

Norvin Burrus
@ndburrus
Jun 09 2016 03:42
This message was deleted
Eclogesh
@Eclogesh
Jun 09 2016 03:44
@khaduch because still not sure what is the context myVar = myVar should be changed means..and why it is failing... And i did cleared the cache...
Ken Haduch
@khaduch
Jun 09 2016 03:45
@Eclogesh - I just looked at your attachment again - please totally remove the line that you have commented out with the // myVar = myVar + 1; - the test might be scanning the code and still seeing that. Sorry that I did not see that initially, it was faded out because of the syntax highlighting.
Norvin Burrus
@ndburrus
Jun 09 2016 03:46
@IndiraShrestha oops, accidentally deleted message. anyway, it does return an array... you don't have to loop through it, the function will just return everything (in the/that property)... so, moving on, what do we need to do if the condition is false?
Eclogesh
@Eclogesh
Jun 09 2016 03:48
@khaduch yes it works after removing the commented out code..
Ken Haduch
@khaduch
Jun 09 2016 03:50
@Eclogesh - I just reproduced it. So it does work - sometimes when they are checking for things in the tests, they actually examine the code (by a script, of course) so it was looking for that line to be removed, actually, replaced with the new code, so they didn't account for it being commented out - so not a perfect system, perhaps worthy of a ticket, but essentially that's the problem. Glad you got it working! Good luck going forward...
Eclogesh
@Eclogesh
Jun 09 2016 03:51
@khaduch Appreciate it.. thanks for taking time to help me ..
CamperBot
@camperbot
Jun 09 2016 03:51
eclogesh sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1287 | @khaduch |http://www.freecodecamp.com/khaduch
Angelo Ryndon
@AIRyndon
Jun 09 2016 03:52
Hello Everyone! I have something weird going on.. when I check the code in browser console, I'm getting the desired value. But the challenge still won't pass, am I missing something? here is the code

var romanNumbers = {"1000": "M","900": "CM","500": "D","400": "CD","100": "C","90": "XC","50": "L",
                     "40": "XL","10": "X","9": "IX","5": "V","4": "IV","1": "I"};
var keys = Object.keys(romanNumbers).reverse();
var convertedNumber = "";

function convertToRoman(num) {

  var key = "";
  console.log(keys);
  for(var i = 0;i < keys.length;i++){

    key = keys[i];

     if(parseInt(key) <= num){ 
       convertedNumber += romanNumbers[key];
       num -= parseInt(key);
       break;
     }     
   }  
    if(num <= 0){
      console.log(convertedNumber);
     return convertedNumber;
   }
    else{
    convertToRoman(num);
  }
}

convertToRoman(3999);
Ken Haduch
@khaduch
Jun 09 2016 03:52
@Eclogesh you are welcome! I'm signing off for tonight, good luck with the next lessons!
Blake Harris
@bharris62
Jun 09 2016 03:52
check out this beauty @khaduch
function translatePigLatin(str) {
  if (str[0] === 'a' || str[0] === 'e' || str[0] === 'i' || str[0] === 'o' || str[0] === 'u') {
      return str + 'way';
      }else if (str[0] !== 'a' && str[1] === 'a' || str[0] !== 'e' && str[1] === 'e' || str[0] !== 'i' && str[1] === 'i' || str[0] !== 'o' && str[1] === 'o' || str[0] !== 'u' && str[1] === 'u'){
         var otherVar = str.split(',').slice(0).join();
         otherVar = otherVar.substr(1) + otherVar.substr(0,1) + 'ay'; 
         return otherVar; 
       }else{
        var newVar = str.split(',').slice(0,2).join();
        newVar = newVar.substr(2)+ newVar.substr(0,2) + 'ay'; 
        return newVar;
        }
      }


translatePigLatin("california");
lmao
IndiraShrestha
@IndiraShrestha
Jun 09 2016 03:52
@ndburrus return "No such property";
@ndburrus return "No such property";
Ken Haduch
@khaduch
Jun 09 2016 03:52
@bharris62 - yikes!
Blake Harris
@bharris62
Jun 09 2016 03:52
i think i need to learn regex lmao
but again, it does work lol
although it was kinda made to fit the challenge, which i know i shouldn't do...
Norvin Burrus
@ndburrus
Jun 09 2016 03:54
@IndiraShrestha yes, exactly... ok, which way now... we are inside the outer if loop (at this point)...
Ken Haduch
@khaduch
Jun 09 2016 03:55
@bharris62 - yes, get cracking on the regular expressions! So helpful (at least for these challenges) and I guess with real-world problems, too! Do you know that sites like regexone.com or regex101.com? Those are nice sites.
khaduch @khaduch - leaving the campground for the night... happy coding to all!
Angelo Ryndon
@AIRyndon
Jun 09 2016 03:57
Can't we declare global variables on their test page when doing challenges? this is confusing me... code checks out on Browser console but not the test window
var romanNumbers = {"1000": "M","900": "CM","500": "D","400": "CD","100": "C","90": "XC","50": "L",
                     "40": "XL","10": "X","9": "IX","5": "V","4": "IV","1": "I"};
var keys = Object.keys(romanNumbers).reverse();
var convertedNumber = "";
function convertToRoman(num) {


  var key = "";
  console.log(keys);
  for(var i = 0;i < keys.length;i++){

    key = keys[i];

     if(parseInt(key) <= num){ 
       convertedNumber += romanNumbers[key];
       num -= parseInt(key);
       break;
     }     
   }  
    if(num <= 0){
      console.log(convertedNumber);
     return convertedNumber;
   }
    else{
    convertToRoman(num);
  }
}


convertToRoman(36);
I hope there is someone that can help
jmilee
@jmilee
Jun 09 2016 04:00
Hi Guys, can someone help me with 144??
amit kumar soni
@4mit
Jun 09 2016 04:00

var Bike = function() {

// Only change code below this line.
var gear=0 ;
this.setGear = function(agrpass){
gear =gear+agrpass;
};

this.getGear = function(){
return gear;
};

};

Make Object Properties Private \ it showing correct for input myBike.getGear() should return 4 after calling myBike.setGear(4)\ but not for other inputs // Any one please tell me Why
Angelo Ryndon
@AIRyndon
Jun 09 2016 04:04

Tried this now

function convertToRoman(num) {

var romanNumbers = {"1000": "M","900": "CM","500": "D","400": "CD","100": "C","90": "XC","50": "L",
                     "40": "XL","10": "X","9": "IX","5": "V","4": "IV","1": "I"};
var keys = Object.keys(romanNumbers).reverse();
var convertedNumber = "";

function convert(num){
  var key = "";

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

    key = keys[i];

     if(parseInt(key) <= num){ 
       convertedNumber += romanNumbers[key];
       num -= parseInt(key);
       break;
     }     
  }  
      if(num <= 0){
       return convertedNumber;
      }
      else{
      convert(num);
      }
 } 
  convert(num);
}


convertToRoman(3999);

I wrapped everything in a function..still same result..Browser console checks out but the test challenge window doesn't.

This is the final code..I really want to solve this using recursion but the test window won't let me pass
function convertToRoman(num) {

var romanNumbers = {"1000": "M","900": "CM","500": "D","400": "CD","100": "C","90": "XC","50": "L",
                     "40": "XL","10": "X","9": "IX","5": "V","4": "IV","1": "I"};
var keys = Object.keys(romanNumbers).reverse();
var convertedNumber = "";

function convert(num){
  var key = "";

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

    key = keys[i];

     if(parseInt(key) <= num){ 
       convertedNumber += romanNumbers[key];
       num -= parseInt(key);
       break;
     }     
  }  
      if(num <= 0){
        console.log(convertedNumber);
       return convertedNumber;
      }
      else{
      convert(num);
      }
 } 
  return(convert(num));
}


convertToRoman(3999);
amit kumar soni
@4mit
Jun 09 2016 04:11
This message was deleted
Eric Leung
@erictleung
Jun 09 2016 04:23

@Eclogesh I apologize if it seemed rash to close so soon, we see lots of issues that are mostly coding help and the code you had on the issue was incorrect, so I default to closing the issue :sweat_smile: Your issue didn't have enough information on it. If you have feedback on the challenge, please put as much detail in the issue so that we can triage it appropriately.

I read through the discussion above and it appears you felt the myVar = myVar should be changed test was unclear on what it meant?

UtkarshShukla7
@UtkarshShukla7
Jun 09 2016 04:25
@erictleung I also have an issue FreeCodeCamp/FreeCodeCamp#8979 why no one is assigned to it
Eric Leung
@erictleung
Jun 09 2016 04:29
@UtkarshShukla7 thanks for bringing this to my attention. We get a lot of issues daily so sometimes they get buried a bit :sweat_smile: Thanks for that issue, you bring up a good point. I'll comment on it accordingly.
CamperBot
@camperbot
Jun 09 2016 04:29
erictleung sends brownie points to @utkarshshukla7 :sparkles: :thumbsup: :sparkles:
:cookie: 596 | @utkarshshukla7 |http://www.freecodecamp.com/utkarshshukla7
UtkarshShukla7
@UtkarshShukla7
Jun 09 2016 04:30
@erictleung np ,thanks for checking it :smile:
WannabeProdigy
@WannabeProdigy
Jun 09 2016 04:31

Hello, need help for Profile Lookup. What I tried was testing first if firstName and prop were true, then using switch to return the correct string according to the results of the testing.

var firstNameTrue = false;
var propTrue = false;

for (var i = 0; i < contacts.length; i++) {
if (contacts[i][0] === firstName) {
firstNameTrue = true;
break;
}
else {
firstNameTrue = false;
continue;
}

}

for (var j = 0; j < contacts.length; j++) {
for (var k = 0; k < contacts[j].length; k++) {
if (contacts[j][k] === prop) {
propTrue = true;
break;
}
else {
propTrue = false;
continue;
}
}
}

switch (firstNameTrue, propTrue) {
case true, true:
return contacts.firstName[prop];
case true, false:
return "No such property";
case false, true:
return "No such contact";
case false, false:
return "Invalid";

What is wrong with this?
Brian
@BrianCodes33
Jun 09 2016 04:51
function doFirst() {
        'use strict';
        var x = document.getElementById('canvas');
        canvas = x.getContext('2d');
        canvas.font="bold 36px Tahoma";
        canvas.textAlign = "end";
        canvas.fillText("hey", 200, 100);
}

window.addEventListener("load", doFirst, false);
why does it say canvas undefined?
Jason Shoemaker
@kutsuya1
Jun 09 2016 04:55
@BrianCodes33 var canvas?
Jason Shoemaker
@kutsuya1
Jun 09 2016 05:02
:dancer:
Brian
@BrianCodes33
Jun 09 2016 05:02
?
David Halls
@DavidHalls
Jun 09 2016 05:05
@BrianCodes33 do you have an element with the id of canvas in your html?
Ross
@Woodywoodruff3
Jun 09 2016 05:06
Can someone look at this code and see why its not calling my if console.log if I type Yes to my first prompt and to my second prompt?
case "HIT":
var power = prompt("Do you need Extra Power? YES or NO").toUpperCase();
var location = prompt("Hit in FACE or GUT?").toUpperCase();
if(power === "YES" && location === "FACE"){
console.log("What a sweet upper cut!");
}else{
console.log("You need to choose wisely. You Lose!");
}
break;
Brian
@BrianCodes33
Jun 09 2016 05:07
@kutsuya1 @Byzgig yea i have that in html
<body>
    <div id="canvas"></div>
    <script src="main.js"></script>
</body>
David Halls
@DavidHalls
Jun 09 2016 05:08
@BrianCodes33 maybe put a # infront of canvas in the script
Brian
@BrianCodes33
Jun 09 2016 05:08
still says canvas undefined
hmm
not defined*
David Halls
@DavidHalls
Jun 09 2016 05:10
@BrianCodes33 it is refering to all of the 'canvas' in white as not being defined
@BrianCodes33 you could try changing all of those to x
or change x to canvase
Brian
@BrianCodes33
Jun 09 2016 05:15
still not working
Angelo Ryndon
@AIRyndon
Jun 09 2016 05:18
Solved it, yay!
unction convertToRoman(num) {

var romanNumbers = {"1000": "M","900": "CM","500": "D","400": "CD","100": "C","90": "XC","50": "L",
                     "40": "XL","10": "X","9": "IX","5": "V","4": "IV","1": "I"};
var keys = Object.keys(romanNumbers).reverse();
var convertedNumber = "";

function convertRecursive(num){
  var key = "";

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

    key = keys[i];
     if(parseInt(key) <= num){ 
       convertedNumber += romanNumbers[key];
       num -= parseInt(key);
       break;
     }     
  }  
     return num <=0?convertedNumber:convertRecursive(num);
 }   
  return(convertRecursive(num));
}

convertToRoman(3999);
Thomas
@TheCodyKnight
Jun 09 2016 05:20

hi! how is it possible to target the 5 and 6 in the following element with a method?
if I call the length in a function, the last two numbers are ignored. also using an array index to target a number is only possible up until 3 (where the actual array ends).

function([1, 2, 3, 1, 2, 3], 5,6);

Markus Kiili
@Masd925
Jun 09 2016 05:21
@TheCodyKnight If the function has only one parameter, you have to use the arguments object for those extra arguments.
Angelo Ryndon
@AIRyndon
Jun 09 2016 05:21
@TheCodyKnight use the arguments
Markus Kiili
@Masd925
Jun 09 2016 05:22
@AIRyndon I solved Roman numerals with reduce:
function convert(num) {
  var NUM = [1000,900,500,400,100,90,50,40,10,9,5,4,1];
  var ROM = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'];
  return NUM.reduce(function(prev,curr,index){
    var result = prev += ROM[index].repeat(num/curr>>0);
    num -= (num/curr>>0)*curr;
    return result;
  }, '');
}
Thomas
@TheCodyKnight
Jun 09 2016 05:22
aha, I will try that! thanks @AIRyndon @Masd925
CamperBot
@camperbot
Jun 09 2016 05:22
thecodyknight sends brownie points to @airyndon and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 295 | @airyndon |http://www.freecodecamp.com/airyndon
:star2: 1775 | @masd925 |http://www.freecodecamp.com/masd925
stricknein
@stricknein
Jun 09 2016 05:23
Can some one can explain to me why you can use the expression /\s/ on split but not on join?
Vale
@hophuochoanggia
Jun 09 2016 05:23
Can anyone help me with the us phone number validation?
Abhijit
@blackbirdabhi
Jun 09 2016 05:23
hi guys..just did the first switch statement challenge. Noticed that the break statements show up as errors (yellow exclamation mark) even though i passed the challenge. Is this a bug?
Angelo Ryndon
@AIRyndon
Jun 09 2016 05:23
@Masd925 I wanted to do it with my own recursive call :)
Ross
@Woodywoodruff3
Jun 09 2016 05:24
@blackbirdabhi What challenge number?
David Halls
@DavidHalls
Jun 09 2016 05:24
@blackbirdabhi did you use return statements in your switch?
Abhijit
@blackbirdabhi
Jun 09 2016 05:24
206.
Yes @Byzgig
David Halls
@DavidHalls
Jun 09 2016 05:25
@blackbirdabhi that is why
Abhijit
@blackbirdabhi
Jun 09 2016 05:26
So is there another statement in place of return? :sweat_smile:
Markus Kiili
@Masd925
Jun 09 2016 05:26
@stricknein Split argument can be given with string or regular expression. Join with only string. Quite logical actually.
David Halls
@DavidHalls
Jun 09 2016 05:27
@blackbirdabhi break, you would need to format your switch a little different, the return exits the switch before hitting the break, that is what the ! is telling you, you have an unreachable break
Brian
@BrianCodes33
Jun 09 2016 05:27
this is driving me crazy why isn't it working?
function doFirst() {
        'use strict';
        var x = document.getElementById('canvas');
        var canvas = x.getContext('2d');


        canvas.font="bold 36px Tahoma";
        canvas.textAlign = "end";
        canvas.fillText("hey", 200, 100);
}

window.addEventListener("load", doFirst, false);
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<section id="main">
    <canvas id="canvas" width="600" height="400"></canvas>
 </section>

<script src="main.js"></script>

</body>
</html>
Angelo Ryndon
@AIRyndon
Jun 09 2016 05:27
@Masd925 is reduce like a new function? I'm noob at JS and don't even know a quarter of built-in ones hahah
stricknein
@stricknein
Jun 09 2016 05:27
@Masd925 how is that logical ? I do not follow bro. Why cant a regular expression be used in join ??
Angelo Ryndon
@AIRyndon
Jun 09 2016 05:28
@stricknein hmmm...I don't you want to use regex on a join, regex kinda means you want to filter/search for somethin
@stricknein I don't think*
Abhijit
@blackbirdabhi
Jun 09 2016 05:28
@Byzgig i see, how do I format my switch then?
pavan
@pavan20593
Jun 09 2016 05:28
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element. in Record collection Map-211 , every other task is completed. the aobove mention condition is not working
any help?

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

return collection;
}

Markus Kiili
@Masd925
Jun 09 2016 05:29
@stricknein Regexp is a pattern. "join the elements with something space-like?"
stricknein
@stricknein
Jun 09 2016 05:29
@Masd925 @AIRyndon Aw I c that makes sence now haha.
pavan
@pavan20593
Jun 09 2016 05:29
this is my function for updating the JSON
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"
}
};
this is the JSON i have
David Halls
@DavidHalls
Jun 09 2016 05:29
@blackbirdabhi i would need to see your code, but probably where you have the return, make it an assignment instead like x = y;
stricknein
@stricknein
Jun 09 2016 05:30
@Masd925 Ya I figured it would just join on spaces... forgot /\s/ isnt just refering to spaces.
Islam Abasov
@IslamA
Jun 09 2016 05:30
find Truncate a string
CamperBot
@camperbot
Jun 09 2016 05:30

find truncate a string

:zero: algorithm truncate a string

Abhijit
@blackbirdabhi
Jun 09 2016 05:31
Okay.
stricknein
@stricknein
Jun 09 2016 05:31
@Masd925 @AIRyndon Thanks for clearing that up. I need to go to be haha not thinkin straight lol
CamperBot
@camperbot
Jun 09 2016 05:31
stricknein sends brownie points to @masd925 and @airyndon :sparkles: :thumbsup: :sparkles:
:star2: 1776 | @masd925 |http://www.freecodecamp.com/masd925
:cookie: 296 | @airyndon |http://www.freecodecamp.com/airyndon
Joseph Jordan
@Garousen
Jun 09 2016 05:32
Hello. I'm still a bit new to this, having a bit of trouble on a lesson...
stricknein
@stricknein
Jun 09 2016 05:33
@Garousen which one ?
Joseph Jordan
@Garousen
Jun 09 2016 05:33
@stricknein Finding a Remainder in JavaScript
Ross
@Woodywoodruff3
Jun 09 2016 05:34
@BrianCodes33 in my ID's ive built(which isnt many) I have them this way. $(#"canvas").font
stricknein
@stricknein
Jun 09 2016 05:34
@Garousen what is your question ?
Joseph Jordan
@Garousen
Jun 09 2016 05:34
it's giving me the right answer, but won't recognize the operator
stricknein
@stricknein
Jun 09 2016 05:34
@Garousen can I see your code
Joseph Jordan
@Garousen
Jun 09 2016 05:34

var remainder;

remainder = 11 % 3;
This is the code I have showing--am I missing something?

stricknein
@stricknein
Jun 09 2016 05:35
looks normal to me.. but I dont remember what it is looking for what one are you on ?
Ross
@Woodywoodruff3
Jun 09 2016 05:36
var remainder=11%3;
Joseph Jordan
@Garousen
Jun 09 2016 05:36
Finding a Remainder--The value of the remainder equals 2, and it wants the % operator. It recognized that the remainder is correct, but not the operator use
stricknein
@stricknein
Jun 09 2016 05:37
@Woodywoodruff3 @Garousen he already has a declaration of var remainder, is it just looking for an initilization too ?
Justin Dado
@rene-justin-dado
Jun 09 2016 05:37
Help. :/
This is from the 'Record Collection challenge'. I'm badly blocked here, coz i'm getting:
TypeError: Cannot set property 'prop' of undefined
The Dev Tools debugger tells me there's something wrong with the code in my first IF statement
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
  /*If value is non-blank (value !== "") and prop is not "tracks" then update or set the value for the prop.*/
  if (value !== "" && prop !== "tracks") {
       collection.id.prop = value;
  }
  /*If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.*/
  else if (prop == "tracks" && value !== "") {
    collection.id.value.push(value);
  }

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

  return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
CamperBot
@camperbot
Jun 09 2016 05:37
no wiki entry for: this is from the record collection challenge im badly blocked here coz im gettingtypeerror cannot set property prop of undefinedthe dev tools debugger tells me theres something wrong with the code in my first if statement setupvar 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 testsvar collectioncopy jsonparsejsonstringifycollection only change code below this linefunction updaterecordsid prop value if value is non-blank value and prop is not tracks then update or set the value for the prop if value prop tracks collectionidprop value if the prop is tracks and value is non-blank push the value onto the end of the tracks array else if prop tracks value collectionidvaluepushvalue else if value delete collectionidprop return collection alter values below to test your codeupdaterecords5439 artist abba
Ross
@Woodywoodruff3
Jun 09 2016 05:37
You dont need the first line
Abhijit
@blackbirdabhi
Jun 09 2016 05:37
@Byzgig
switch (val)
{
case "a":
    return"apple";

    break;
  case "b": 
    return"bird";
    break;
  case "c": 
    return "cat";

    break;
  default: return "stuff";
}
this is my code..
Markus Kiili
@Masd925
Jun 09 2016 05:37
@rene-justin-dado The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants". Bracket notation works with keys that can be arbitrary strings cat["lives left"]; //returns 3, variables var key="clothes"; cat[key]; //returns "pants", or expressions cat["lives"+" "+"left"]; //returns 3.
Joseph Jordan
@Garousen
Jun 09 2016 05:38
thank you @Woodywoodruff3--that worked, I don't know how to do the points thing
CamperBot
@camperbot
Jun 09 2016 05:38
garousen sends brownie points to @woodywoodruff3--that :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for woodywoodruff3--that
Markus Kiili
@Masd925
Jun 09 2016 05:38
So .id and .prop won't work.
stricknein
@stricknein
Jun 09 2016 05:38
@Garousen just do an initilization it looks like it wants you to do that instead of declaring the varibale then assigning
Jason Shoemaker
@kutsuya1
Jun 09 2016 05:38
@BrianCodes33 '<canvas id="canvas"></canvas> '
Justin Dado
@rene-justin-dado
Jun 09 2016 05:38
Thanks, @Masd925 . That's a huge help. Will see what I can do with that. :)
CamperBot
@camperbot
Jun 09 2016 05:38
rene-justin-dado sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1777 | @masd925 |http://www.freecodecamp.com/masd925
David Halls
@DavidHalls
Jun 09 2016 05:39
@blackbirdabhi then change return to val = "bird" or whatever the var is in place of val
Joseph Jordan
@Garousen
Jun 09 2016 05:39
Alright...thank you both very much, I was stuck for a while on that.
Abhijit
@blackbirdabhi
Jun 09 2016 05:39
okay.
stricknein
@stricknein
Jun 09 2016 05:39
@Garousen @Woodywoodruff3 Ya that is what I had too, that is wierd it is forcing you to initilize. Just so you no normally your code would have worked has to do with the way they programmed the challenge.
Abhijit
@blackbirdabhi
Jun 09 2016 05:39
Thanks!
Ross
@Woodywoodruff3
Jun 09 2016 05:39
@Garousen Just put Thanks @Woodywoodruff3 make sure it just the name with no space by it. the Forum figures out the points
CamperBot
@camperbot
Jun 09 2016 05:39
woodywoodruff3 sends brownie points to @garousen :sparkles: :thumbsup: :sparkles:
:cookie: 138 | @garousen |http://www.freecodecamp.com/garousen
Joseph Jordan
@Garousen
Jun 09 2016 05:40
Thanks @Woodywoodruff3
CamperBot
@camperbot
Jun 09 2016 05:40
garousen sends brownie points to @woodywoodruff3 :sparkles: :thumbsup: :sparkles:
:cookie: 277 | @woodywoodruff3 |http://www.freecodecamp.com/woodywoodruff3
Ross
@Woodywoodruff3
Jun 09 2016 05:40
There ya go
palash gupta
@palashcode
Jun 09 2016 05:41

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length;i++){

if(firstName ==contacts[i][firstName] && contacts[i][prop]){
return contacts[i][prop];
}

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

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

else {
return "";
}

}
// Only change code above this line
}

someone please help
Ross
@Woodywoodruff3
Jun 09 2016 05:41
What needs done?
Markus Kiili
@Masd925
Jun 09 2016 05:41
@palashcode if(firstName ==contacts[i][firstName] <- quotes here on firstName.
Abhijit
@blackbirdabhi
Jun 09 2016 05:41
@Byzgig i did as u said, i immediately got switchOfStuff("a") should have a value of "apple" error. Same for the rest.
except default
stricknein
@stricknein
Jun 09 2016 05:41
@palashcode have to define your conditionals more
Markus Kiili
@Masd925
Jun 09 2016 05:42
@palashcode Format your code please.
explain format
CamperBot
@camperbot
Jun 09 2016 05:42

: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

Abhijit
@blackbirdabhi
Jun 09 2016 05:42
never mind..i found the issue..
David Halls
@DavidHalls
Jun 09 2016 05:43
@blackbirdabhi did you change retrun to 'val' or to the variable that was declared earlier?
Robert Baker
@RobertBaker14
Jun 09 2016 05:43

Hi everyone. I'm stuck on the Record Challenge and I'm not sure what's wrong with my syntax. I think I've nailed the first and last portion, but I'm struggling with the second part. The instructions are as follows:

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

For the second portion, I’ve tried switching value into bracket notation to see if it would affect the output but it’s still showing up an as an error. I’m not sure if id is needed or not. I’ve omitted the id and use dot notation like this collection.tracks.push([value]) and I still get an error. If anyone can point out my mistake or help me understand where I’m messing up, I’d greatly appreciate it.

function updateRecords(id, prop, value) {

if(value !== "" && prop !== collection.tracks) {

collection[id][prop] = value;

}

else if (prop === "tracks" && value !== "") {

collection[id].tracks.push([value]);

}

else if(value === "") {

delete collection[id][prop];

}

return collection;
}

stricknein
@stricknein
Jun 09 2016 05:43
@palashcode just have to think like the computer. Is the arguements going to match the first member in the array ?? if not then it will automatically go down your other conditionals
Abhijit
@blackbirdabhi
Jun 09 2016 05:43
it seems that it was "answer" instead of "val". Passed the challenge :smile:
stricknein
@stricknein
Jun 09 2016 05:43
@RobertBaker14 Im almost certain it is your conditionals.
Markus Kiili
@Masd925
Jun 09 2016 05:44
@RobertBaker14 Your conditions should check value and prop, and on if blocks you access collection.
stricknein
@stricknein
Jun 09 2016 05:45
@RobertBaker14 Think about how the compiler is going to process the arguments. If the arguments dont match your first conditional it continue on and if it matches your other conditionals that are not intended for it, you will end up going down the wrong branch.
Chris Cullen
@123xylem
Jun 09 2016 05:45
function sumFibs(num) {
  var count=0;
  var arr=[];
  var digit=1;
  while(!digit+digit %2===0&& digit<num){
    count+=digit;
  }
  return count;
}

sumFibs(4);
Im trying to find and add all the odd fib numbers of num... My FCC has been crashing a lot tho so just checking whats going on here to only return 0 when I run it?
Markus Kiili
@Masd925
Jun 09 2016 05:48
@123xylem There might be a precedence problem with your while condition. !digit is evaluated before + leading to coercions.
Robert Baker
@RobertBaker14
Jun 09 2016 05:49
@stricknein @Masd925 Thanks guys for the response. I'm looking back at my conditionals now and trying to revise them so I can get the correct output.
CamperBot
@camperbot
Jun 09 2016 05:49
robertbaker14 sends brownie points to @stricknein and @masd925 :sparkles: :thumbsup: :sparkles:
:cookie: 242 | @stricknein |http://www.freecodecamp.com/stricknein
:star2: 1778 | @masd925 |http://www.freecodecamp.com/masd925
Robert Baker
@RobertBaker14
Jun 09 2016 05:50
@Masd925 @stricknein Brownie points to both of you.
Chris Cullen
@123xylem
Jun 09 2016 05:50
@Masd925 ok il mess with the while order... I was before running a for loop which was <num (4) and pushed the nums into an array... but that kept crashing the browser.. Some of the numbers were like 82348484 so do you think it wouldnt let me run it because the forloop would take too much space?

function sumFibs(num) {
  var count=0;
  var arr=[];
  var digit=1;
  while(digit<num && digit+digit %2!==0 ){
    count+=digit; 
  }
  return count;

}

sumFibs(5);
THis is supposedly an infinite loop
even though digit is <num
if i move the return up it just gives count=1
SHREYA GUPTA
@shreyag020
Jun 09 2016 05:54

var Bike = function() {

// Only change code below this line.
var gear=10;
this.getGear = function(change) {
gear += change;
};

this.setGear = function() {
gear-= 5;
};
};

stricknein
@stricknein
Jun 09 2016 05:54
@123xylem possible I have had some issues with some while loops that clame to be infinite loops. Prob just went over the limited processing power I would think.
SHREYA GUPTA
@shreyag020
Jun 09 2016 05:54
functions not working
stricknein
@stricknein
Jun 09 2016 05:55
@shreyag020 try to not increment and just do a reg assign
SHREYA GUPTA
@shreyag020
Jun 09 2016 05:56
not working
Markus Kiili
@Masd925
Jun 09 2016 05:56
@123xylem It is an infinite loop because you increment count but your condition only checks digit.
Chris Cullen
@123xylem
Jun 09 2016 05:57
@Masd925 good job thanks
CamperBot
@camperbot
Jun 09 2016 05:57
123xylem sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1779 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Jun 09 2016 05:59
@shreyag020 getGear should return value of gear and setGear assign to gear.
Zach
@Moose1551
Jun 09 2016 05:59

Can someone help me out with this? My for loop returns the unicode value of the string being tested, so how do I add 13 to the unicode values of those that need it? Is it as close to being as easy as saying

if (strArr[i].charCodeAt() < 77) {
return strArr[i].charCodeAt() +13; }

Here is the full code:

function rot13(str) {
var strArr = str.split('');


  for (var i = 0; i < strArr.length; i++) {
    strArr[i] = strArr[i].charCodeAt();
      if (strArr[i].fromCharCode(65, 66, 68, 69, 70, 71, 72, 73, 74, 75,                                 76, 77, 78)) {
       return strArr[i].fromCharCode() + 13;
  } return strArr;
}
}
rot13("SERR PBQR PNZC");
palash gupta
@palashcode
Jun 09 2016 05:59




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


function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length;i++){

  if(firstName ===contacts[i][firstName] && contacts[i][prop]!==undefined){
     return contacts[i][prop];
  }

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

  if (!contacts[i][prop])
  {
    return "No such property";
  } 

}

}

// Change these values to test your function
lookUpProfile("harry", "likes");
Markus Kiili
@Masd925
Jun 09 2016 06:00
@Moose1551 If the charcode at the array needs to be changed, change it and assign it back to the array. Then it is easy to make the result string at the end from the array.
SHREYA GUPTA
@shreyag020
Jun 09 2016 06:01

var Bike = function() {

// Only change code below this line.
var gear=10;
this.getGear = function() {
return gear;
};

this.setGear = function(change) {
gear+= change;
};
};

Markus Kiili
@Masd925
Jun 09 2016 06:01
@Moose1551 Returning inside the loop would terminate the function before the result is ready and returned.
@shreyag020 Assign, don't increment.
stricknein
@stricknein
Jun 09 2016 06:02
@shreyag020 just return on the get function and use a simple assign on the other function
SHREYA GUPTA
@shreyag020
Jun 09 2016 06:03
ok thanks @Masd925 @stricknein
CamperBot
@camperbot
Jun 09 2016 06:03
shreyag020 sends brownie points to @masd925 and @stricknein :sparkles: :thumbsup: :sparkles:
:cookie: 244 | @stricknein |http://www.freecodecamp.com/stricknein
:star2: 1780 | @masd925 |http://www.freecodecamp.com/masd925
palash gupta
@palashcode
Jun 09 2016 06:04
look at my code please




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


function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i=0; i<contacts.length;i++){

  if(firstName ===contacts[i][firstName] && contacts[i][prop]!==undefined){
     return contacts[i][prop];
  }

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

  if (!contacts[i][prop])
  {
    return "No such property";
  } 

}

}

// Change these values to test your function
lookUpProfile("harry", "likes");
stricknein
@stricknein
Jun 09 2016 06:07
@palashcode go through your conditionals
@palashcode there is a logic error in the 2nd and third one
@palashcode Think like the compiler and trace the execution of your function with different parameters, will they go down the right conditional each case ?
@palashcode if not restrict the conditional more to get rid of the false positives
Yildirim
@yildirimmurat
Jun 09 2016 06:09
Hello
Markus Kiili
@Masd925
Jun 09 2016 06:10
@palashcode if(firstName ===contacts[i]["firstName"] <- quotes needed on firstName
stricknein
@stricknein
Jun 09 2016 06:11
@Masd925 @palashcode they are not needed... you use [] for variables without quotes to access the member
Markus Kiili
@Masd925
Jun 09 2016 06:11
@palashcode Proper way to check property existence is .hasOwnProperty() or .propertyIsEnumerable(). Other ways have problems.
@stricknein Here we are not looking the property key stored in parameter firstName. We are looking for the actual property key "firstName" that exist in each contact.
stricknein
@stricknein
Jun 09 2016 06:12
@Masd925 @palashcode that is true. but he is missing a needed &&
Yildirim
@yildirimmurat
Jun 09 2016 06:12

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

// Only change code below this line

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

What is wrong with this code? can anyone help pls
stricknein
@stricknein
Jun 09 2016 06:13
@Masd925 are you sure its not looking at the value of the member... that wouldnt make sense to me if it was just looking for the member... because later it looks to see if the name is apart of the members
Markus Kiili
@Masd925
Jun 09 2016 06:15
@stricknein If for example firstname "Akira" is passed as an argument into the function, contacts[i]["firstName"] would check the looped contacts property value of key "firstName". contacts[i][firstName] would look for property value with key "Akira" which is never there.
stricknein
@stricknein
Jun 09 2016 06:17
@Masd925 Ooo i c never mind I confused myself.. I used contacts[i].firstName when I went through it... wouldnt it be better to use dot notation then when looking for the string literal as a property key value ?
Markus Kiili
@Masd925
Jun 09 2016 06:18
@stricknein Both work. Some prefer dot notation when it works, to separate object access from array access.
stricknein
@stricknein
Jun 09 2016 06:19
@Masd925 wait a sec... how come my comparison to firstName worked then... wont either way .firstName and [firstName] refer to the value at the kety.. which is what should be compared
@Masd925 here is my implementation to show you how I got it... Maybe it was a fluked that I got through it, that one gave me a bit trouble. If you can see what happened I would appreciate it if you gave me insight to it when you have a chance.
for(var i = 0; i < contacts.length; i++){

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

    else if(contacts[i].firstName != firstName && i == contacts.length-1){
      return "No such contact";
    }

    else if(!contacts[i].hasOwnProperty(prop) && contacts.length-1){
      return "No such property";
    }
  }
// Only change code above this line
}
Markus Kiili
@Masd925
Jun 09 2016 06:21
@stricknein No, [firstName] looks for the property key stored in parameter firstName. Why would we look for the key "Will" if it is passed as an argument. We always look for property key "firstName" there.
SHREYA GUPTA
@shreyag020
Jun 09 2016 06:21
@shreyag020
array = string.split('\t');
what should i put as argument
stricknein
@stricknein
Jun 09 2016 06:22
@Masd925 because it says to check firstName is the actual contacts name... At least that is the way I solved it
@Masd925 all of them have the member firstName, I thought the point was to make sure the param matched the name stored at that firstName member
Markus Kiili
@Masd925
Jun 09 2016 06:23
@stricknein .firstName is the same as ["firstName"] yes. Neither have anything to do with parameter firstName, which [firstName] would use.
stricknein
@stricknein
Jun 09 2016 06:25
@Masd925 sorry to bog you down but I got confused. So both .firstName and ["firstName"] are refering to the value assinged to the member firstName.... Not looking to match firstName with firstName... Do I have that right ? because that is the way I have been seeing it but now I am a bit confused haha
Donovan
@dnvn999
Jun 09 2016 06:25
Hi, all. Can anyone help me in challenge - Record Collection? My codes are below,
// 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) {
 for (collection.[i]){
  (value !== "" && prop != collection["tracks"]){
    return prop = value;

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

  } else if (value == "") {
  delete prop;
  }
  return collection;
}
Joe B
@jbreality
Jun 09 2016 06:26
hmm
I've played around with position and such, how can I get the button to not move when the quote updates
Chris Cullen
@123xylem
Jun 09 2016 06:26

function sumFibs(num) {
var count=0;
var arr=[];
var digit=1;

while(digit<num){
//while dig is less than num
digit= digit+ digit;
//digit = 1 + prev digit

if(digit+digit %2!==0){

arr.push(digit); 

}}
return arr;

}

sumFibs(5);
Now im confused .. THis is giving me only even numbers on digit!?? WTF?

Chris Cullen
@123xylem
Jun 09 2016 06:26
function sumFibs(num) {
  var count=0;
  var arr=[];
  var digit=1;

  while(digit<num){
    //while dig is less than num
 digit= digit+ digit;
    //digit = 1 + prev digit

    if(digit+digit %2!==0){

    arr.push(digit); 
  }}
  return arr;

}

sumFibs(5);
THis is giving me only even numbers on digit!??
stricknein
@stricknein
Jun 09 2016 06:27
@dnvn999 what is i refering to ?
Donovan
@dnvn999
Jun 09 2016 06:27
@stricknein JScript challenge - Record Collection?
stricknein
@stricknein
Jun 09 2016 06:27
@dnvn999 think you ment id ??
Donovan
@dnvn999
Jun 09 2016 06:28
@stricknein yup
stricknein
@stricknein
Jun 09 2016 06:28
@dnvn999 lol no in collection[i]... shoudnt be collection[i] should be collection[id]
@dnvn999 also your for loop what is it doing ?
@dnvn999 you dont need a loop
Donovan
@dnvn999
Jun 09 2016 06:29
@stricknein because the question is asking "For the given id in collection:"
stricknein
@stricknein
Jun 09 2016 06:29
@dnvn999 ya but that doesnt mean you need a for loop
Donovan
@dnvn999
Jun 09 2016 06:30
@stricknein I see, do you want to talk this through private chatbox?
Markus Kiili
@Masd925
Jun 09 2016 06:30
@stricknein We need to check the firstname of the looped contact. The contact has four fixed property keys and one is "firstName". Function invokation puts the passed firstname as the value of firstName parameter. So value of firstName could be "Johnny". When we get the firstName of the looped contact, we use the fixed property key "firstName", not the name stored in firstName. Therefore we access the contact with contacts[i]["firstName"] or contacts[i].firstName. The wrong way contacts[i][firstName] would be same as contacts[i].Johnny, which is not correct as you see. Then the looped contacts firstname is compared with the value of firstName parameter contacts[i]["firstName"]===firstName.
stricknein
@stricknein
Jun 09 2016 06:31
@dnvn999 its ok just remove the for loop and think about your conditionals, the key is getting them set to process the data correctly. Play around with different arguments and hit me back up if you get stuck again
David Halls
@DavidHalls
Jun 09 2016 06:32
on spinal tap, do i need multiple regex's?
Donovan
@dnvn999
Jun 09 2016 06:33
@stricknein sure, what is the proper way to code prop is not "tracks" instead of my 'prop != collection["tracks"]`
David Halls
@DavidHalls
Jun 09 2016 06:33
```

jsfunction spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
var arr = str.toLowerCase();
str = arr.replace(/\W/g, '-');
return str;
}

spinalCase('This Is Spinal Tap');

```
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:35
Hi everyone, i am currently working on the intermediate project - twitch tv, i need help appending <div> element with an <img>. The URL of the img is stored as an object key value pair, and i am just not able to find how to use that object.key as an src for <img> element
Markus Kiili
@Masd925
Jun 09 2016 06:35
@kapoorradhika Post the code about the object and what you need to access.
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:36
This is my code

$(document).ready(function () {
$.getJSON('https://api.twitch.tv/kraken/streams/esl_sc2', function(data) {

// get information of the user in gamerInfo
var gamerInfo = {
"userName": data.stream.channel.display_name,
"status": data.stream,
"logo": data.stream.channel.logo,
"gameName": data.stream.channel.game,
"userURL": data.stream.channel.url,

findStatus: function () {
    if (gamerInfo.status === null) {
        gamerInfo.status = "Offline";
    } // if statement
    else { 
        gamerInfo.status = "Online";
    } //else statement
}, // find status method

createDiv: function () {

    $(".newUser").append(
        '<div id="id' + gamerInfo.status + '" class="col-md-4 img">' + gamerInfo.logo + '</div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.userName + '</div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.gameName + '</div>'
    ); // closing append

} // create Div method

}; // gamerInfo Object

gamerInfo.createDiv();

}); // $.getJSON
}); // document.ready

Donovan
@dnvn999
Jun 09 2016 06:36
@stricknein is it better?
// Only change code below this line
function updateRecords(id, prop, value) {

  (value !== "" && prop != collection[i].tracks){
    return prop = value;

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

  } else if (value === "") {
  delete prop;
  }
  return collection;
}
David Halls
@DavidHalls
Jun 09 2016 06:37
@kapoorradhika something like this '<img src="'imgscr'">' inside one of your divs
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:37
but that <img> src is stored as gamerInfo.logo @Byzgig
stricknein
@stricknein
Jun 09 2016 06:38
@Masd925 gotcha ok, so we were talking about the same thing I just initially mixed up the [firstName] and ["firstName"], one accesses the value at the key and the other is refering to the variable, silly me. Thank you for takin the time to clarify that.
CamperBot
@camperbot
Jun 09 2016 06:38
stricknein sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1781 | @masd925 |http://www.freecodecamp.com/masd925
David Halls
@DavidHalls
Jun 09 2016 06:38
@kapoorradhika and all all of those white divs mean you have a '' or " " misplaced
stricknein
@stricknein
Jun 09 2016 06:38
@dnvn999 ya you are missing an if though
David Halls
@DavidHalls
Jun 09 2016 06:39
@kapoorradhika so create an img tag inside one of your divs, then include the link in the src=
stricknein
@stricknein
Jun 09 2016 06:39
@dnvn999 use .hasOwnProperty instead of prop!=
@dnvn999 also you have an assignment in the else if
@dnvn999 again use hasOwnProperty
@dnvn999 also think about the order you will need the conditionals in
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:40
Screen Shot 2016-06-08 at 11.39.46 PM.png
@Masd925 @Byzgig the src is stored in gamerInfo object as gamerInfo.logo
how do i use an object value for src
i tried it, it isnt working
David Halls
@DavidHalls
Jun 09 2016 06:41
@kapoorradhika gamerInfo.logo has a URL right?
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:42
yes its value is a URL @Byzgig
stricknein
@stricknein
Jun 09 2016 06:42
does the reverse string challenge need quotes as well as the char reversed ?
David Halls
@DavidHalls
Jun 09 2016 06:42
@kapoorradhika so then wouldn't it be <img src="url"></img>?
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:43
you mean <img src = gamerInfo.logo></img>
stricknein
@stricknein
Jun 09 2016 06:44
@kapoorradhika @Byzgig img doesnt have a closing tag
David Halls
@DavidHalls
Jun 09 2016 06:44
@kapoorradhika if gamerInfo.logo = a url then yes
stricknein
@stricknein
Jun 09 2016 06:44
@kapoorradhika @Byzgig <img stuff in here >
Markus Kiili
@Masd925
Jun 09 2016 06:44
@stricknein You just return the string.
stricknein
@stricknein
Jun 09 2016 06:44
@Masd925 I did but it wont pass me for some reason and Im gettin the expected output haha
Markus Kiili
@Masd925
Jun 09 2016 06:45
@stricknein Post the code.
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:45
@stricknein @Byzgig okay, let me add a closing tag and use the object value as src and see if it is working. 2 mins plz
stricknein
@stricknein
Jun 09 2016 06:45
@Masd925 I dont need "s tho so something else must be wrong I did a push and unshift and it still wont pass me
@Masd925 here is the code
var myArray = [];
  for(var i = 0; i < str.length; i++){
    myArray.push(str[i]);
  }
  myArray.reverse();
  str = myArray.join(" ");
  return str;
}
Donovan
@dnvn999
Jun 09 2016 06:46
@stricknein like this? if (value !== "" && prop != collection.hasOwnProperty("tracks")) I thought prop is an argument in the parameters?
I dont get what you meant by assignment and i thought i followed the order for the conditionals already.
Markus Kiili
@Masd925
Jun 09 2016 06:46
@stricknein Join without spaces.
@stricknein You could use .split("") instead of implementing it with your for loop.
stricknein
@stricknein
Jun 09 2016 06:47
@kapoorradhika @Masd925 thanks man you are the best. why the heck was teh output showing spaces hahaha tricky suckkers haha
CamperBot
@camperbot
Jun 09 2016 06:47
stricknein sends brownie points to @kapoorradhika and @masd925 :sparkles: :thumbsup: :sparkles:
:warning: stricknein already gave masd925 points
:cookie: 319 | @kapoorradhika |http://www.freecodecamp.com/kapoorradhika
stricknein
@stricknein
Jun 09 2016 06:47
@Masd925 ya I know I thought I would be sneaky and just push to an array. for some reason I thought it would act like a stack and output in reverse order
Dan
@dcgoings
Jun 09 2016 06:48
hey guys.. so im just now getting into using an editor outside of codepen for js.. i truly have no idea what im doing.
stricknein
@stricknein
Jun 09 2016 06:48
@kapoorradhika @Byzgig just remeber img does not have an end tag jsut end it with >
Vivek
@vivek28111992
Jun 09 2016 06:48
hi does amazon recruit js developer?
Dan
@dcgoings
Jun 09 2016 06:48
read a few videos. installed atom + a ton of packages.
im also running script and atom-runner.. however, i can print out a simple hello world.. but if i try and paste in one of my algorithms from FCC, it's just blank.
any ideas?
just trying to figure out what key piece im missing here.
stricknein
@stricknein
Jun 09 2016 06:49
@dnvn999 this is where your assignment was } else if (value !== "" && prop = collection[i].tracks){
collection.tracks.push(value);
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:50
@stricknein @Masd925 hey guys, its not getting that image..
this is what i wrote

// get information of the user in gamerInfo
var gamerInfo = {
"userName": data.stream.channel.display_name,
"status": data.stream,
"logo": data.stream.channel.logo,
"gameName": data.stream.channel.game,
"userURL": data.stream.channel.url,

findStatus: function () {
    if (gamerInfo.status === null) {
        gamerInfo.status = "Offline";
    } // if statement
    else { 
        gamerInfo.status = "Online";
    } //else statement
}, // find status method

createDiv: function () {

    $(".newUser").append(
        '<div id="id' + gamerInfo.status + '" class="col-md-4 img"> <img src = gamerInfo.logo></img></div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.userName + '</div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.gameName + '</div>'
    ); // closing append

} // create Div method

}; // gamerInfo Object

stricknein
@stricknein
Jun 09 2016 06:50
@kapoorradhika post your img tag
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:50
createDiv: function () {

    $(".newUser").append(
        '<div id="id' + gamerInfo.status + '" class="col-md-4 img"> <img src = gamerInfo.logo></div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.userName + '</div>' +
            '<div id="id' + gamerInfo.status + '" class="col-md-4">' + gamerInfo.gameName + '</div>'
    ); // closing append

} // create Div method
stricknein
@stricknein
Jun 09 2016 06:51
@kapoorradhika <img src = gamerInfo.logo></img> should be <img src = "http://blahblahblah" alt = "something for vis impaired">
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:51
Screen Shot 2016-06-08 at 11.47.42 PM.png
stricknein
@stricknein
Jun 09 2016 06:51
@kapoorradhika img is a self closing tag meaning no end </img> just a > to close that element
David Halls
@DavidHalls
Jun 09 2016 06:51
@kapoorradhika take off the </img> and you need to include quotes @stricknein she said gamerInfo.logo is a variable that has the URL
@kapoorradhika oh, you need the whole url, not just gamerInfo
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:52
img is a self closing tag it doesnt need </img>
stricknein
@stricknein
Jun 09 2016 06:52
@Byzgig I didnt see that
David Halls
@DavidHalls
Jun 09 2016 06:53
@kapoorradhika post the URL to your codepen
Donovan
@dnvn999
Jun 09 2016 06:54
@stricknein What should I correct in my code now? I dont know how to correct the syntax error in the line - delete prop;
// Only change code below this line
function updateRecords(id, prop, value) {

  if (value !== "" && prop != collection.hasOwnProperty("tracks")){
    return prop == value;

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

  } else if (value === "") {
  delete prop;
  }
  return collection;
}
Markus Kiili
@Masd925
Jun 09 2016 06:55
@kapoorradhika Isn't this bit just a string, so no variable accessed? '" class="col-md-4 img"> <img src = gamerInfo.logo></div>'
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:55
okay @Masd925 @Byzgig @stricknein this is my codepen link to the project http://codepen.io/radhikakapoor/pen/EyPVGG
Markus Kiili
@Masd925
Jun 09 2016 06:55
@kapoorradhika Should it be '" class="col-md-4 img"> <img src = `+gamerInfo.logo+`></div>'
stricknein
@stricknein
Jun 09 2016 06:56
@dnvn999 you can not delet prop. that isnt malloc memory like an object just a variable well parameter to be specific. can only use the delete on the object. so delete the specific object member
Clyde
@hea-hea
Jun 09 2016 06:56
hi everyone :)
I'm solving the "Sum All Odd Fibonacci Numbers" challenge now - and I'm really close
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:57
@Masd925 ok let me try that
Markus Kiili
@Masd925
Jun 09 2016 06:57
@kapoorradhika Same way you append the status value later.
Clyde
@hea-hea
Jun 09 2016 06:58
it looks like I'm missing one iteration to make it right - for sumFibs(75025) and sumFibs(75024) it returns the same end sum.
Zach
@Moose1551
Jun 09 2016 06:58
@Masd925 , I thought I was trying to do that, haha. Is this closer to what you mean?
function rot13(str) {
var strArr = str.split('');


  for (var i = 0; i < strArr.length; i++) {
    strArr[i] = strArr[i].charCodeAt();

  } return strArr;

} if (strArr.fromCharCode(65, 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78)) {
return strArr.fromCharCode(i) + 13;
}

  rot13("SERR PBQR PNZC");
Clyde
@hea-hea
Jun 09 2016 06:59
would anyone be so nice and have a look at my code?
function sumFibs(num) {
  var sum = 0;
  var sumOdd = 0;

  var numA = 0;
  var numB = 1;


  while (sum<=num){
    sum = numA + numB; // 1     // 2            // 3
    numA = numB; // numA -> 1   // numA -> 1    // numA -> 2
    numB = sum;  // numB -> 1   // num B -> 2   // numB -> 3
    console.log(sum);

    if (sum%2 === 0)  {
      sumOdd += sum;

    }


  }

  return sumOdd;

}
Radhika Kapoor
@kapoorradhika
Jun 09 2016 06:59
@Masd925 nope that isnt working :(
Clyde
@hea-hea
Jun 09 2016 06:59
like I said it almost works ;)
Markus Kiili
@Masd925
Jun 09 2016 07:00
@Moose1551 Only return at the end when you have the array joined as a string.
Donovan
@dnvn999
Jun 09 2016 07:00
@stricknein is it like this? with or without the "tracks"
  } else if (value === "") {
  delete collection.hasOwnProperty("tracks");
Markus Kiili
@Masd925
Jun 09 2016 07:01
@Moose1551 You can put the mapping logic here inside the first loop.
for (var i = 0; i < strArr.length; i++) {
    strArr[i] = strArr[i].charCodeAt();

  }
@Moose1551 Check if the charcode is between A-Z charcodes, and change the code if it is.
stricknein
@stricknein
Jun 09 2016 07:02
@dnvn999 no you need to point delete to the members you want deleted. hasOwnProperty returns a Bool
Hong
@designBuildShipSoftware
Jun 09 2016 07:02
Hi, I am learning Render Images from Data Sources by json. There is one line in the code like this:
html += "<img src = '" + val.imageLink + "'>"
I wonder why it isn't html += "<img src = " + val.imageLink + ">"
David Halls
@DavidHalls
Jun 09 2016 07:03
@kapoorradhika i have it working on your pen
Donovan
@dnvn999
Jun 09 2016 07:04
@stricknein I need an example for that cz i dont know how to code the logic you just said. :/
stricknein
@stricknein
Jun 09 2016 07:04
@dnvn999 it is in the previous challenges but hold on I will find an example
Zach
@Moose1551
Jun 09 2016 07:05

@Masd925 , thanks for the help, man. I have no idea what I'm doing with these for loops.

for (var i = 0; i < strArr.length; i++) {
    strArr[i] = strArr[i].charCodeAt();
      if (strArr[i].charCodeAt() > 64 && strArr[i].charCodeAt() < 93) {
  } return strArr.join().charCodeAt([i]) + 13;

Is this what you're implying?

CamperBot
@camperbot
Jun 09 2016 07:05
moose1551 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1782 | @masd925 |http://www.freecodecamp.com/masd925
stricknein
@stricknein
Jun 09 2016 07:06
@dnvn999 delete something[x][y]
Donovan
@dnvn999
Jun 09 2016 07:08
@stricknein I still dont get you. i change to delete collection.tracks;
stricknein
@stricknein
Jun 09 2016 07:09
@dnvn999 no... I suggest looking at the previous challenges to understand it better, but you need to delete collections[id][prop];
Robert Baker
@RobertBaker14
Jun 09 2016 07:09
@dnvn999 Just take a close look at the syntax that's he provided you
Radhika Kapoor
@kapoorradhika
Jun 09 2016 07:10
thanks a ton @stricknein @Byzgig for helping me. I got the image.
CamperBot
@camperbot
Jun 09 2016 07:10
kapoorradhika sends brownie points to @stricknein and @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 246 | @stricknein |http://www.freecodecamp.com/stricknein
:cookie: 295 | @byzgig |http://www.freecodecamp.com/byzgig
Markus Kiili
@Masd925
Jun 09 2016 07:10
@Moose1551 You returnus interruptus. You just manipulate the array values and only return once at the end.
Ramon Vizcarra
@ahandyman
Jun 09 2016 07:11

function rot13(str) 
{ // LBH QVQ VG!
    var res = []; //create array

    for(var i = 0; i < str.length; i++)
    {
          // console.log(str.charCodeAt(i)); test irratation through the string
                  // ALL CAPS
                  // 65-77 A-M
                  // 32 space
                  // 78-90 N-Z
          var charValue = str.charCodeAt(i);
          // charValue = the value for each character using method charCodeAt
          // console.log(String.fromCharCode(charValue));
          // determine the character from the value (charValue) 

          if ((charValue >= 65 && charValue <= 77) && charValue != 32) 
          {

              var upChar = charValue + 13;
              console.log ("value of index: " + i + " is: " + charValue + " new value is: " + upChar);

              console.log("original character: " + String.fromCharCode(charValue) + " new character: " + String.fromCharCode(upChar));
          }
          if ((charValue >= 78 && charValue <= 90) && charValue != 32) 
          {

              var downChar = charValue - 13;
              console.log ("value of index: " + i + " is: " + charValue + " new value is: " + downChar);
              console.log("original character: " + String.fromCharCode(charValue) + " new character: " + String.fromCharCode(downChar));
          }
          if(charValue == 32) {
              console.log(String.fromCharCode(32));
          }
          // push() method iterate throug string
         // res.push(String.fromCharCode(str.charCodeAt(i)));
         // push() method iterate throug charVal +13

         // res.push(String.fromCharCode(str.charCodeAt(i)));

         // res.push(String.fromCharCode(charValue));
    }

    return(res.join());
    //return str;
}

// Change the inputs below to test
// rot13("ABCDEFGHIJKLM NOPQRSTUVWXYZ");
rot13("SERR PBQR PNZC");
Working on Caesars Cipher, and i'm a little lost console.log'ed like a mad man any tips on directions much appreciated
Robert Baker
@RobertBaker14
Jun 09 2016 07:12
@dnvn999 He used bracket notation for the example of [x][y] because that's the only way you can access the properties that you want to delete for the object. And the exercise he is referring to is Delete Properties From An Object.
Radhika Kapoor
@kapoorradhika
Jun 09 2016 07:12
@Masd925 thanks :smile: :sparkles: :clap: :+1:
CamperBot
@camperbot
Jun 09 2016 07:12
kapoorradhika sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1783 | @masd925 |http://www.freecodecamp.com/masd925
Zach
@Moose1551
Jun 09 2016 07:13
@Masd925 , Do I manipulate the array values inside the for loop with an if/else statement and some insertions of those magical [i]'s?
Donovan
@dnvn999
Jun 09 2016 07:14
@RobertBaker14 @stricknein I think I am getting to understand, let me work with my codes a while more. :D
Markus Kiili
@Masd925
Jun 09 2016 07:14
@Moose1551 Yes. You check if the charcode needs changing and you change it if needed and assign is back to the array.
stricknein
@stricknein
Jun 09 2016 07:15
@dnvn999 good to hear, sorry if I seem a bit cryptic but I dont want to just tell you what to code, biggest part of learning to code is doing it and failing.
Zach
@Moose1551
Jun 09 2016 07:15
@Masd925 , am I not doing that here, though?
for (var i = 0; i < strArr.length; i++) {
    strArr[i] = strArr[i].charCodeAt();
      if (strArr[i].charCodeAt() > 64 && strArr[i].charCodeAt() < 93) {
Umair
@umairbalani
Jun 09 2016 07:16
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
var myStr; // Change this line
myStr = '\ \t \r \n';
What I'm doing wrong here?
Sanne
@sannek
Jun 09 2016 07:16
@umairbalani You need to escape your backslash as well, and you need two tabs, not 1
You'r almost there
Umair
@umairbalani
Jun 09 2016 07:16
I've typed two \ \t \r \n
Markus Kiili
@Masd925
Jun 09 2016 07:16
@Moose1551 You should check strArr[i] because you just changed the element to be the charcode. No need to .charCodeAt() twice.
Zach
@Moose1551
Jun 09 2016 07:17
@Masd925 , I just throw those [i]s around. I have no idea what to do with them. I've gone over and over them, but I still have no idea when to use them and where.
Donovan
@dnvn999
Jun 09 2016 07:17
@stricknein no worries, I understand.
Umair
@umairbalani
Jun 09 2016 07:17
How do I escape my \
@sannek how do I escape my \
Zach
@Moose1551
Jun 09 2016 07:18
@Masd925 , thanks though, dude. You've got the patience of a saint. I've plateau'ed since the end of Basic JavaScript. Nothing is clicking.
CamperBot
@camperbot
Jun 09 2016 07:18
moose1551 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: moose1551 already gave masd925 points
Yildirim
@yildirimmurat
Jun 09 2016 07:18

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

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

return collection;
}

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

what is wrong with this code?
Donovan
@dnvn999
Jun 09 2016 07:18
@stricknein so how do I know when should i use prop, collection.hasOwnProperty() and collections[id][prop]
|
?
stricknein
@stricknein
Jun 09 2016 07:19
@dnvn999 well you need to understand what they do before you can know when to use them
focus on understanding what each statement is actually doing then it will click when to use certain statements over others. but If I just tell you what to do and when you will not get anything out of it. For instance prop is a parameter in your function so it is a local variable that is passed in by the function call. the hasOwnProperty is a function that returns a boolean value based on if the property is present. and [foo] is a method for accessing the propertys.
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 07:22
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];
    collection[id][prop].push(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");
Sanne
@sannek
Jun 09 2016 07:22
@umairbalani Same as all characters, by putting \ in front of it, so to get a backslash to show up you need \
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 07:22
can someone help me my first test issnt running but all the other ones are
stricknein
@stricknein
Jun 09 2016 07:23
redo your conditionals
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 07:23
After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"
@stricknein me?
stricknein
@stricknein
Jun 09 2016 07:23
@emmanuelledebarge yes
Emmanuelle DeBarge
@emmanuelledebarge
Jun 09 2016 07:23
@stricknein which one
stricknein
@stricknein
Jun 09 2016 07:24
@emmanuelledebarge it is a logic error. think about the branch of logic each input will take, I suggest changing the function call to get a better idea of what is going on if you havent done so already
@emmanuelledebarge There are several ways to do it, but think about what you need to check your and in what order. Change the function calls arguements to filter out the logic errors.
Yildirim
@yildirimmurat
Jun 09 2016 07:28

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

return collection;
}

I have some problems too.
After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.
Anyone help?
stricknein
@stricknein
Jun 09 2016 07:29
@yildirimmurat You have a logic error as well
Yildirim
@yildirimmurat
Jun 09 2016 07:29
how can i correct it
stricknein
@stricknein
Jun 09 2016 07:30
@yildirimmurat think about the parameters that come in and what order they come in. If they do not fufil the first 2 conditionals they will automatically fall down the else branch
@yildirimmurat by restricting the conditionals. Making sure that parameters only go down the correct path. Think about the order that you should have the if and else if statements, and think about how you can be more restrictinve with &&s and what not to ensure only the right params go down that path of logic.
Arjun
@arjunsingh81989
Jun 09 2016 07:32
I have a question regarding Grunt JS task runner. Why do we install external grunt plugin locally and not globally?
Yildirim
@yildirimmurat
Jun 09 2016 07:32
thanks a lot
Islam Abasov
@IslamA
Jun 09 2016 07:36
find Chunky Monkey
CamperBot
@camperbot
Jun 09 2016 07:36

find chunky monkey

:zero: algorithm chunky monkey

Dan Couper
@DanCouper
Jun 09 2016 07:38
@arjunsingh81989 it keeps the copy of Grunt local to whatever you're working on, and you can pass that onto someone else and it will work. In a professional environment, you'd be working with other people. You need to ensure everything works for them as well: if it only installs globally, you may have a different version to someone else: if you rely on some feature that isn't implemented in the version one of your colleagues has installed, they will find that things won't work when they try to run the same code
Islam Abasov
@IslamA
Jun 09 2016 07:38
Thanks @kirah1314 @Rafase282 @jsommamtek @oshliaer for your help with Algorithm: Chunky Monkey
CamperBot
@camperbot
Jun 09 2016 07:38
islama sends brownie points to @kirah1314 and @rafase282 and @jsommamtek and @oshliaer :sparkles: :thumbsup: :sparkles: