These are chat archives for FreeCodeCamp/HelpJavaScript

23rd
Jun 2016
96street
@96street
Jun 23 2016 00:00
@BKinahan that makes sense, ty
CamperBot
@camperbot
Jun 23 2016 00:00
96street sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1761 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 23 2016 00:00
@paul7536 do you know about if statements?
Coy Sanders
@coymeetsworld
Jun 23 2016 00:00
@paul7536 whats the problem?
Paul Hwang
@paul7536
Jun 23 2016 00:00
yes i do know if statements
Brendan Kinahan
@BKinahan
Jun 23 2016 00:01
@paul7536 so you need to construct one to find out if a is less than 0 or if b is less than 0. If either is true, return undefined, because the function can't use values like those.
Paul Hwang
@paul7536
Jun 23 2016 00:01
the samples doesnt mention if statements tho
function myFun() {
console.log("Hello");
return "World";
console.log("byebye")
}
myFun();
Brendan Kinahan
@BKinahan
Jun 23 2016 00:01
@paul7536 note that you should return undefined and not "undefined"
Paul Hwang
@paul7536
Jun 23 2016 00:02
okay
i will try
thx @BKinahan
CamperBot
@camperbot
Jun 23 2016 00:02
paul7536 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1762 | @bkinahan |http://www.freecodecamp.com/bkinahan
Coy Sanders
@coymeetsworld
Jun 23 2016 00:02
you should've done if statements by now, no @paul7536 ?
Brendan Kinahan
@BKinahan
Jun 23 2016 00:02
@paul7536 the line console.log("byebye"); does nothing since there is a return statement before it, by the way
Paul Hwang
@paul7536
Jun 23 2016 00:02
got it
pnirav
@pnirav
Jun 23 2016 00:03
@ndburrus I got now. Thank you so much!
CamperBot
@camperbot
Jun 23 2016 00:03
pnirav sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 684 | @ndburrus |http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Jun 23 2016 00:03
@pnirav excellent! you're welcome... nice work :sparkles:
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:03
´´´html
oops
´´´html
Paul Hwang
@paul7536
Jun 23 2016 00:04

// Setup
function abTest(a, b) {
  // Only change code below this line
 if  (a < 0 || b < 0)
  return undefined;
  // Only change code above this line

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

// Change values below to test your code
abTest(-2,2);
worked
Brendan Kinahan
@BKinahan
Jun 23 2016 00:04
@Daniel-Skoglund those are some kind of front-ticks. You want backticks :D
@paul7536 :thumbsup:
Norvin Burrus
@ndburrus
Jun 23 2016 00:10
@Daniel-Skoglund the key to the left of the number one "1" key...
Joe O.
@joffenhauser
Jun 23 2016 00:11
hi guys, I’m stuck on the ‘Record Collection’ challenge and could use some help. I think the only problem left at this point is that I can’t figure out how to add a new array to my object. here’s my code:
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

} else delete collection[id][prop];
return collection;
}
Joe O.
@joffenhauser
Jun 23 2016 00:17
is anyone home? lol
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:17
Hey people I am stuck on the "Stand in Line" lesson.
"Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed."

function nextInLine(arr, item) {
  // Your code here
  var myArr = [1,2,3,4,5];
  myArr.push(item);
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
I have no clue what I am doing with this, just tried something...
Brendan Kinahan
@BKinahan
Jun 23 2016 00:19
@Daniel-Skoglund use arr, not a new variable.
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:19
sorry @joffenhauser I can not help you friend ^^
Joe O.
@joffenhauser
Jun 23 2016 00:19
no worries dude @Daniel-Skoglund
Diego Mayer
@Chrono79
Jun 23 2016 00:20
@joffenhauser collection[id].tracks = []; like this you're adding a new property (array) to your object
but:
  • you're doing it in the wrong case
  • you need to push the value after creating the property
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:21
"'arr' is already defined" that did not work, instead I got a warning, any more ideas? @BKinahan
Joe O.
@joffenhauser
Jun 23 2016 00:21
ok thank, I think I understand what you mean in your second bullet but could you explain a little more what you mean by the first?
@Chrono79
Brendan Kinahan
@BKinahan
Jun 23 2016 00:22
@Daniel-Skoglund don't declare arr again; it's already available beacuse it's the function parameter
Diego Mayer
@Chrono79
Jun 23 2016 00:22
@joffenhauser
function updateRecords(id, prop, value) {
if (value !== "") {
  if (prop === "tracks") {
    if (collection[id].hasOwnProperty("tracks")) {
        collection[id][prop].push(value);
    }
  } else { // this else means prop isn't tracks
      collection[id].tracks = [];
  }
} else delete collection[id][prop];
return collection;
}
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:24
@BKinahan Oh right! I think I have an idea now
Diego Mayer
@Chrono79
Jun 23 2016 00:24
if prop isn't "tracks" you have to do another thing @joffenhauser
Joe O.
@joffenhauser
Jun 23 2016 00:25
ok. so first, I think you’re saying, I need to put the code that creates the array immediately following the third if statement? @Chrono79
Diego Mayer
@Chrono79
Jun 23 2016 00:27
@joffenhauser you could do so, or, I think it's better to ask if it hasn't the property, create it, and then push (in any case when prop is "tracks")
inside the else I commented, you have to do this:
If prop does not contain the key "tracks", then update or set the value for that incomplete prop.
Joe O.
@joffenhauser
Jun 23 2016 00:27
ok that makes sense, let men give it a shot here @Chrono79
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 00:32
This is how far I came
function nextInLine(arr, item) {
  arr.push(item);// Your code here
  arr.shift();
  return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
and it meets the requirements for 2 out of 4 goals
what does this actually mean: "nextInLine([2], 1) should return 2
nextInLine([5,6,7,8,9], 1) should return 5"
Diego Mayer
@Chrono79
Jun 23 2016 00:35
@Daniel-Skoglund item is what you added at the end, not what you removed from the front
:point_up: 22 de junio de 2016 17:33 here I explained what it means the first of your 2 questions
Joe O.
@joffenhauser
Jun 23 2016 00:40
well I gave it a shot, still not right though
here’s what I have now:
// Setup
var collection = {
    "2548": {
      "album": "Slippery When Wet",
      "artist": "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    "2468": {
      "album": "1999",
      "artist": "Prince",
      "tracks": [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    "1245": {
      "artist": "Robert Palmer",
      "tracks": [ ]
    },
    "5439": {
      "album": "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {
if (value !== "") {
  if (collection[id].hasOwnProperty("tracks")) {
     if (prop === "tracks"){
       collection[id].tracks = [];
       collection[id][prop].push(value);
    }
  } else if (prop !== "tracks") {
    collection[id].prop = [];
    collection[id][prop].push(value);
  }
} else delete collection[id][prop];
return collection;
}
  // include the value im adding says towel head
// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");
@Chrono79
Diego Mayer
@Chrono79
Jun 23 2016 00:41
@joffenhauser no, and no need to paste all, with only the function is ok, just to not use all the window chat I mean
If prop isn't tracks, you don't need to create an array
Joe O.
@joffenhauser
Jun 23 2016 00:41
sorry
Diego Mayer
@Chrono79
Jun 23 2016 00:42
just set the property value
you shouldn't ask if hasOwnProperty before testing for prop === "tracks"
What I meant before was, test por !hasOwnProperty and create the prop using the empty array, and both if it existed or if you created it, use push, that should be inside the ifs value != ="" and prop === "tracks"
Joe O.
@joffenhauser
Jun 23 2016 00:45
ok haha only nowhere in this course has !hasOwnProperty ever been introduced
Brendan Kinahan
@BKinahan
Jun 23 2016 00:46
Read-Search-Ask ;)
there's a whole Internet out there
Joe O.
@joffenhauser
Jun 23 2016 00:47
but it could also easy have been mentioned in passing on one of the challenges is all I’m saying
Diego Mayer
@Chrono79
Jun 23 2016 00:47
function updateRecords(id, prop, value) {
if (value !== "") {
  if (prop === "tracks") {
    if (collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = [];
    }
    collection[id][prop].push(value);
  } else { // this else means prop isn't tracks
     //do another thing
  }
} else delete collection[id][prop];
return collection;
}
Joe O.
@joffenhauser
Jun 23 2016 00:47
but I hear you
Diego Mayer
@Chrono79
Jun 23 2016 00:47
@joffenhauser you can use === false
Joe O.
@joffenhauser
Jun 23 2016 00:47
I’ve been on this challenge for coming up on two days no so I’ve already been doing a lot read search as and no where has that come up until now
DC
@dctor
Jun 23 2016 00:48
@Chrono79 i am working on where art thou algo and my code can't pass this test case. can you see why? thanks
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var key = Object.keys(source);
  for (var i in collection) {   
    for (var j=0;j<key.length;j++){
      if (collection[i][key[j]]===source[key[j]]) {
          arr.push(collection[i]);
      }
      }
    }
  return arr;
  // Only change code above this line
  //return arr;
}

whereAreYou([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });
CamperBot
@camperbot
Jun 23 2016 00:48
dctor sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1272 | @chrono79 |http://www.freecodecamp.com/chrono79
Pritesh Gandhi
@prijuly2000
Jun 23 2016 00:48
hi guys
i have a problem with JSON operations
After updateRecords(2548, "artist", ""), artist should not be set
this task
i did the code perfectly bt its not working
Brendan Kinahan
@BKinahan
Jun 23 2016 00:50
hm. maybe the code isn't perfect.
let's find out!
Pritesh Gandhi
@prijuly2000
Jun 23 2016 00:50

function updateRecords(id, prop, value) {
if(value==="")
return;

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

return collection;
}

Melissa Guerrero
@Mmgfrog
Jun 23 2016 00:51
ugh my solution to Escape Sequences in Strings isn't working, keeps giving me errors that "myStr should have encoded text with the proper escape sequences and spacing" and then "myStr should not have any spaces in between consecutive escape sequences." But when I remove spaces it gives me even more error messages,
Brendan Kinahan
@BKinahan
Jun 23 2016 00:51
@prijuly2000 well, you don't delete anything if value === ""
@prijuly2000 so your code is not perfect :)
David Halls
@DavidHalls
Jun 23 2016 00:51
@Mmgfrog post your code
Brendan Kinahan
@BKinahan
Jun 23 2016 00:52
@Mmgfrog probably a missing or extra space somewhere. paste it here, preferably formatted :)
Pritesh Gandhi
@prijuly2000
Jun 23 2016 00:52
@BKinahan not working
Melissa Guerrero
@Mmgfrog
Jun 23 2016 00:52
var myStr = "Here is a backslash: \.\ \n\t\t Here is a new line with two tabs.";
Brendan Kinahan
@BKinahan
Jun 23 2016 00:52
@Mmgfrog slap some backticks around that: `like this`
it'll display escaped characters correctly in the chat
pahosler
@pahosler
Jun 23 2016 00:53
@prijuly2000 here was my solution to Record Collection, it's a slightly different approach...
Brendan Kinahan
@BKinahan
Jun 23 2016 00:53
@pahosler very concise :P
pahosler
@pahosler
Jun 23 2016 00:53
oops, hold on a sec... LOL
Pritesh Gandhi
@prijuly2000
Jun 23 2016 00:53
yap
pahosler
@pahosler
Jun 23 2016 00:54

// 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 (! collectionCopy[id].hasOwnProperty("tracks")) {
       collection = collectionCopy[id].tracks=[];
    }

// create an empty array for tracks if !exists before pushing a track to it

// if tracks exists and is non-blank then push the value onto the end of
// the existing tracks array
//               
//if value is blank, delete that prop
  if (value === "") {
    return collection = delProp(id,prop);
  }else if (prop === "artist") {
    console.log("Updating Artist to: ", value);
    return collection = addArtist(id,prop,value);
  } else if (prop === "album") {
    console.log("Updating Album to: ", value);
    return collection = addAlbum(id,prop,value);
  } else if (prop === "tracks") {
    console.log("Adding tracks: ", value);
    return collection = addTrack(id,prop,value);
  } else {

    console.log("INVALID ENTRY!!!\n\n\n");
    return collection;
  }
}

function addTrack(id,prop,value) {
    collectionCopy[id][prop].push(value);

    return collectionCopy;
}

function addArtist(id,prop,value) {
    collectionCopy[id][prop]=value;
    return collectionCopy;
}

function addAlbum(id,prop,value) {
    collectionCopy[id][prop] = value;
    return collectionCopy;
}

function delTracks(id,prop) {
    delete collectionCopy[id][prop];
    collectionCopy[id][prop]=[];
    return collectionCopy;
}

function delProp(id,prop) {
    delete collectionCopy[id][prop];
    return collectionCopy;
}



// Alter values below to test your code
updateRecords(5439, "artist"," ");
crud, only meant to post the function, copy/pasta in the dark...
functions...
David Halls
@DavidHalls
Jun 23 2016 00:55
@Mmgfrog you have a few extra spces
spaces
Diego Mayer
@Chrono79
Jun 23 2016 00:56
@dctor have you seen what your function returns?
David Halls
@DavidHalls
Jun 23 2016 00:56
@Mmgfrog and \ has to be escaped alsso
Melissa Guerrero
@Mmgfrog
Jun 23 2016 00:57
var myStr = "Here is a backslash: \.\ \n\t\t Here is a new line with two tabs."; // Change this line
Where do you want back ticks, around the whole thing?
Brendan Kinahan
@BKinahan
Jun 23 2016 00:57

@pahosler in

function delTracks(id,prop) {
    delete collectionCopy[id][prop];
    collectionCopy[id][prop]=[];
    return collectionCopy;
}

you don't need delete collectionCopy[id][prop] (and those functions should probably operate on collection instead of collectionCopy)

David Halls
@DavidHalls
Jun 23 2016 00:57
help format
CamperBot
@camperbot
Jun 23 2016 00:57

: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

Jorge
@liberaltech
Jun 23 2016 00:57
David Halls
@DavidHalls
Jun 23 2016 00:57
@Mmgfrog
Brendan Kinahan
@BKinahan
Jun 23 2016 00:58
@Mmgfrog yeah, just one at the start of your code and one at the end, is all you need for a single line. the triple-backticks stuff is for multi-line code snippets
@Mmgfrog so your code will look like this and \\ won't get escaped to look like \
DC
@dctor
Jun 23 2016 00:58
@Chrono79 something like circular object..
Shaflumbles
@Shaflumbles
Jun 23 2016 00:58
Hello! Anyone got time for a quick question regarding the Stand in Line challenge?
David Halls
@DavidHalls
Jun 23 2016 00:59
@liberaltech bottom right square does not work, reset does nothing
pahosler
@pahosler
Jun 23 2016 00:59
used collectionCopy as a buffer basically, technically you don't need to do that
Brendan Kinahan
@BKinahan
Jun 23 2016 00:59
@Shaflumbles if it's quick enough then of course I have time enough :D
by definition ._.
Shaflumbles
@Shaflumbles
Jun 23 2016 00:59
Am I supposed to delete everything below Test Setup?
Melissa Guerrero
@Mmgfrog
Jun 23 2016 00:59
var myStr = "Here is a backslash: \\.\ \n\t\t Here is a new line with two tabs."; // Change this line
Diego Mayer
@Chrono79
Jun 23 2016 00:59
@dctor try using a count and only push if all the properties of source are in collection object
pahosler
@pahosler
Jun 23 2016 00:59
@BKinahan but I see your point not needing the delete...
Brendan Kinahan
@BKinahan
Jun 23 2016 01:00
@Mmgfrog Okay, so the \ right after the first sentence isn't needed (or the space after it). There's also an extra space between the second \t and the word Here
Shaflumbles
@Shaflumbles
Jun 23 2016 01:00
Or at least deleting the var and the references to it in the console.logs?
David Halls
@DavidHalls
Jun 23 2016 01:00
@Mmgfrog too many spaces
pahosler
@pahosler
Jun 23 2016 01:00
the console.log stuff was left over from testing on node, forgot to delete them
Melissa Guerrero
@Mmgfrog
Jun 23 2016 01:00
@Byzgig and @BKinahan thanks
CamperBot
@camperbot
Jun 23 2016 01:00
mmgfrog sends brownie points to @byzgig and @bkinahan :sparkles: :thumbsup: :sparkles:
:cookie: 354 | @byzgig |http://www.freecodecamp.com/byzgig
:star2: 1763 | @bkinahan |http://www.freecodecamp.com/bkinahan
Melissa Guerrero
@Mmgfrog
Jun 23 2016 01:00
I know, but it won't accept fewer spaces either,
Andrew Regan
@andrewregan
Jun 23 2016 01:01
@Mmgfrog I'm having trouble with the Escape Sequences in String lesson as well. Here's what mine looks like: var myStr = "Here is a backslash:\\.\n\t\tHere is a new line with two tabs.";
Brendan Kinahan
@BKinahan
Jun 23 2016 01:01
@Mmgfrog if it still doesn't work, post it again with the changes :)
#hashtagsAreLikeH1Here
Jorge
@liberaltech
Jun 23 2016 01:01
@Byzgig i know, reset does nothing either way. I fixed the bottom right square if youd like to double check it for me
David Halls
@DavidHalls
Jun 23 2016 01:01
@andrewregan you do need a space after the :
Andrew Regan
@andrewregan
Jun 23 2016 01:03
@Byzgig Oh my goodness, I can't believe I missed that! Thanks
CamperBot
@camperbot
Jun 23 2016 01:03
andrewregan sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @byzgig |http://www.freecodecamp.com/byzgig
3jM310
@3jM310
Jun 23 2016 01:03
Guys someone can give a example The WORD BLANK game??
Joe O.
@joffenhauser
Jun 23 2016 01:03
This message was deleted
Melissa Guerrero
@Mmgfrog
Jun 23 2016 01:04
Got it! Thanks everybody @BKinahan your suggestions were perfecto
CamperBot
@camperbot
Jun 23 2016 01:04
mmgfrog sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: mmgfrog already gave bkinahan points
Diego Mayer
@Chrono79
Jun 23 2016 01:04
@joffenhauser you need to create tracks only if it doesn't exist, like I showed before
Joe O.
@joffenhauser
Jun 23 2016 01:04
sorry sent the wrong code above, but yeah still trying to figure out record collection. here’s my code
function updateRecords(id, prop, value) {
if (value !== "") {
  if (prop === "tracks") {
    if (collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = [];
    }
    collection[id][prop].push(value);
  } else if (prop === "artists") {
       if (collection[id].hasOwnProperty("artist") === false) {
       collection[id].artist = [];
       }
       collection[id][prop].push(value);
  }
}
 else delete collection[id][prop];
return collection;
}
David Halls
@DavidHalls
Jun 23 2016 01:04
@liberaltech , that is working, i would add X winner or O winner and if it is a Tie
Brendan Kinahan
@BKinahan
Jun 23 2016 01:05
@Mmgfrog :thumbsup:
Diego Mayer
@Chrono79
Jun 23 2016 01:05
@joffenhauser why prop == "artists" ?
just leave that as else without another if and set the prop value, no need to create an array and using push
Jorge
@liberaltech
Jun 23 2016 01:05
@Byzgig ive thought of that but right now im trying to get the reset button to work
Joe O.
@joffenhauser
Jun 23 2016 01:05
because that is the input of one of the test parameters @Chrono79
i tried this as well
function updateRecords(id, prop, value) {
if (value !== "") {
  if (prop === "tracks") {
    if (collection[id].hasOwnProperty("tracks") === false) {
        collection[id].tracks = [];
    }
    collection[id][prop].push(value);
  } else if (prop === "") {
       if (collection[id].hasOwnProperty(prop) === false) {
       collection[id].prop = [];
       }
       collection[id][prop].push(value);
  }
}
 else delete collection[id][prop];
return collection;
}
pahosler
@pahosler
Jun 23 2016 01:07
@joffenhauser don't make your artist an array, use delete
Diego Mayer
@Chrono79
Jun 23 2016 01:07
@joffenhauser prop isn't empty in any test case
go back and look at what I posted before
pahosler
@pahosler
Jun 23 2016 01:07
only tracks is an array
Nathaniel Nasarow
@Torgian
Jun 23 2016 01:07
argh >.<
having a tough time with Seek and Destroy
Brendan Kinahan
@BKinahan
Jun 23 2016 01:08
@Torgian YOU CAN DO IT
Joe O.
@joffenhauser
Jun 23 2016 01:08
 } else if (prop === [] ) {
       if (collection[id].hasOwnProperty(prop) === false) {
       collection[id].prop = [];
       }
       collection[id][prop].push(value);
  }
}
? @Chrono79
Lauren Adam
@laurenamy
Jun 23 2016 01:08
can someone tell me how to paste code so it looks nice?
paste code here*
Diego Mayer
@Chrono79
Jun 23 2016 01:09
:point_up: 22 de junio de 2016 21:47 @joffenhauser
you only need one line of code there
Joe O.
@joffenhauser
Jun 23 2016 01:09
I have been looking at it! lol I’m really confused! :?
Brendan Kinahan
@BKinahan
Jun 23 2016 01:09
@laurenamy
```js
your code here
```
Pritesh Gandhi
@prijuly2000
Jun 23 2016 01:09
no thr is a bug in it
it should work
@Chrono79
i have done the similar kind of coding
it works in my system
Lauren Adam
@laurenamy
Jun 23 2016 01:10
ok, so I'm getting a potential unlimited loop here with this code, could someone take a look? it's for Spinal tap case
Pritesh Gandhi
@prijuly2000
Jun 23 2016 01:10
but not in codecamp
Lauren Adam
@laurenamy
Jun 23 2016 01:11
function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins

  for (var i = 1; i < str.length; i++) {
    //if character is uppercase
    if (str.charAt(i) === str.charAt(i).toUpperCase()) {
      //slice string and add dash if uppercase with space
      if (str.charAt(i-1) === " ") {
      str = str.slice(0, i-1) + "-" + str.slice(i);
        //slice string and add dash if uppercase with underscore
      } else if (str.charAt(i-1) === "_") {
        str = str.slice(0, i-1) + "-" + str.slice(i);
      } else if (str.charAt(i-1) === str.charAt(i-1).toLowerCase()) {
        var temp = str.slice(i);
        str = str.slice(0, i) + "-" + temp;

      }

    }
  }

  //make entire string lowercase
  str = str.toLowerCase();



  return str;
}
lol I tried
Brendan Kinahan
@BKinahan
Jun 23 2016 01:11
@prijuly2000 still have an error and think your code is perfect? Did you add a section to handle the deletion of a property if value == ""?
Robin Zheng
@robinzhengxd
Jun 23 2016 01:11
Really confused with the "Stand in Line" section of Javascript. I have no idea what I'm supposed to do.. despite reading the instructions. Can anyone help out?
Diego Mayer
@Chrono79
Jun 23 2016 01:11
@prijuly2000 pm your code
pahosler
@pahosler
Jun 23 2016 01:11
@laurenamy use compose mode ctrl + /
Brendan Kinahan
@BKinahan
Jun 23 2016 01:11
@laurenamy use shift+enter to make sure both of the ``` lines are on their own lines.. And you can edit your recent messages to make that change, too :)
Joe O.
@joffenhauser
Jun 23 2016 01:12
holy shit thank god
thank @Chrono79
CamperBot
@camperbot
Jun 23 2016 01:12
joffenhauser sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1273 | @chrono79 |http://www.freecodecamp.com/chrono79
Joe O.
@joffenhauser
Jun 23 2016 01:12
lol
:)
Justin Woodward
@jwoo92
Jun 23 2016 01:12
@laurenamy put your opening and closing ``` on their own lines and place your javascript inside of them.
Lauren Adam
@laurenamy
Jun 23 2016 01:12
boom! thanks!
Brendan Kinahan
@BKinahan
Jun 23 2016 01:12
@laurenamy woo, you got it :D
Diego Mayer
@Chrono79
Jun 23 2016 01:12
@joffenhauser less writing of code and more thinking will save you a lot of time ;)
Joe O.
@joffenhauser
Jun 23 2016 01:12
ill keep that in mind
Diego Mayer
@Chrono79
Jun 23 2016 01:13
:+1:
Kevin K. Lee
@kevinkiklee
Jun 23 2016 01:13
okay. damn it. i said i'm never gonna ask for help here, but i have a problem that is driving me nuts. can anyone take a look at my wikipedia search project code? http://codepen.io/iser/pen/pbNZqo
i'm working on the button right now. the result with a predefined search parameter is supposed to display when i click the button. yet, it doesn't run.
when i have alert() in there, it works, but i can't get the function i want to execute
the function executes fine when i leave it outside the button call.
i noted those with //
can anyone help me out?
Lauren Adam
@laurenamy
Jun 23 2016 01:17
maybe everyone's quiet because they're studying our code..?
Kevin K. Lee
@kevinkiklee
Jun 23 2016 01:17
sorry if i jumped in the middle of something
Lauren Adam
@laurenamy
Jun 23 2016 01:17
noo, sorry that was a bad joke!
Kevin K. Lee
@kevinkiklee
Jun 23 2016 01:18
lol
Brendan Kinahan
@BKinahan
Jun 23 2016 01:18
@laurenamy that is sometimes an effect, probably :)
@iserbit gosh, did you hear bad things about this chatroom to decide never to ask a question here? we don't bite!
David Halls
@DavidHalls
Jun 23 2016 01:20
@laurenamy you need to get the searchTerm
Kevin K. Lee
@kevinkiklee
Jun 23 2016 01:20
it's more like i never wanted to ask for help. wanted to figure everything out myself.
Brendan Kinahan
@BKinahan
Jun 23 2016 01:21
@Byzgig I think you mean @iserbit rather than @laurenamy
Kevin K. Lee
@kevinkiklee
Jun 23 2016 01:21
i didn't get to that part yet. i'm going to put in the code to pull the searchterm from the input box. for now, i'm just working with a predefined value. i have it set to "b" right now. bc i got sick of seeing "a" on the screen.
Brendan Kinahan
@BKinahan
Jun 23 2016 01:21
@laurenamy I'd solve your spinal-tap-case but I did mine with regex and I can't go back now :P
Tamika
@tbishop225
Jun 23 2016 01:22
Hello, I am having a hard time with the Storing Values with the Assignment Value. Need some assistance please
Diego Mayer
@Chrono79
Jun 23 2016 01:22
@tbishop225 show your code
Tamika
@tbishop225
Jun 23 2016 01:23
The error keeps saying b should have a value of 7
Brendan Kinahan
@BKinahan
Jun 23 2016 01:23
@laurenamy (but really, regex is awesome and you should learn to use it and try to solve the challenge with it if at all possible :) )
Diego Mayer
@Chrono79
Jun 23 2016 01:23
maybe it hasn't a value of 7, your code please? @tbishop225
Tamika
@tbishop225
Jun 23 2016 01:23
I do not know how to copy and paste my code...
Diego Mayer
@Chrono79
Jun 23 2016 01:23
select it in the editor ctrl+c and ctrl+v here
Brendan Kinahan
@BKinahan
Jun 23 2016 01:24
bot format
CamperBot
@camperbot
Jun 23 2016 01:24

: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

Lauren Adam
@laurenamy
Jun 23 2016 01:25
@Byzgig I'm sorry, I don't really know what you mean.
Diego Mayer
@Chrono79
Jun 23 2016 01:25
@tbishop225 or just write it here, they're 2 lines after all
Tamika
@tbishop225
Jun 23 2016 01:26

var a = 7;
var b;
var b = a;
// Setup
var a;
var b = 2;

// Only change code below this line

Diego Mayer
@Chrono79
Jun 23 2016 01:27

@tbishop225 I guess your code is like this:

// Setup
var a;
var b = 2;
// Only change code below this line
var a = 7;
var b;
var b = a;

if it is, delete all var keywords below // Only change code below this line , they're already declared above, and delete this line var b;also for the same reason
if not, reset the challenge

David Halls
@DavidHalls
Jun 23 2016 01:28
@laurenamy sorry, was meant for someone else :(
Tamika
@tbishop225
Jun 23 2016 01:28
Is that what my code should look like?? @Chrono79
Dani
@danijmoss
Jun 23 2016 01:28
can i get a assist with stand in line?
Diego Mayer
@Chrono79
Jun 23 2016 01:30
@tbishop225 look at what I wrote
of your code, only keep a = 7; and b = a;
Dani
@danijmoss
Jun 23 2016 01:32

here's my code
`function nextInLine(arr, item) {
// Your code here
arr.push(item);
arr.shift([0]);

return item; // Change this line
}`

Diego Mayer
@Chrono79
Jun 23 2016 01:32
@danijmoss why the argument of shift?
And what you're returning is the thing you added at the end, not the thing you remove from the front
Dani
@danijmoss
Jun 23 2016 01:33
@Chrono79 removes the first element in the array
Dani
@danijmoss
Jun 23 2016 01:34
@Chrono79 so do i return arr.shift([0]); ?
Tamika
@tbishop225
Jun 23 2016 01:34
@Chrono79 Ok, first off I was writing the code in the wrong place. Secondly how does var b; have the value of 7? That's confusing
Thank you for your help! @Chrono79
Connor Hastey-Palindat
@cpalindat
Jun 23 2016 01:35
This message was deleted
Diego Mayer
@Chrono79
Jun 23 2016 01:35
@danijmoss you can, yes, but [0] is not needed, just shift() will work
Dani
@danijmoss
Jun 23 2016 01:35
@Chrono79 ok ill give it a try
Connor Hastey-Palindat
@cpalindat
Jun 23 2016 01:36

Can anyone tell me why this code isn't passing the tests for wherefore art thou?


function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line

  for(var propName in source) {
    if(source.hasOwnProperty(propName)) {
      var propValue = source[propName];
      for (var i = 0; i < Object.keys(collection).length; i++) {
        if (collection[i].hasOwnProperty(propName)) {
          if (collection[i][propName] === propValue) {
            arr.push(collection[i]);
          }
        }
      } // end inner for
    }
  } // end outer for

  // Only change code above this line
  console.log(arr);
  return arr;
}

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

The arr is correct when it logs at the end but its not passing for some reason

Dani
@danijmoss
Jun 23 2016 01:36
@Chrono79 that didnt work sadly
Diego Mayer
@Chrono79
Jun 23 2016 01:36
paste your code again
Alexander Køpke
@alexanderkopke
Jun 23 2016 01:36
@iserbit I think it has something to do with the form. Somehow it resets the page to blank. Remove the form tags and the result should be visible. Also you have </id> at the end of your html .But it should work anyhow
Dani
@danijmoss
Jun 23 2016 01:37

function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift([0]);

  return item;  // Change this line
}
Diego Mayer
@Chrono79
Jun 23 2016 01:37
@tbishop225 you weren't that far, reset, try again and paste your code if it doesn't work, just don't use var in your code, a and b are already declared above, just use them
@danijmoss haven't you modified that? You were going to return arr.shift();
Dani
@danijmoss
Jun 23 2016 01:38
i tried modifying it to arr.shift(); and it gave me all X's for the tests
David Halls
@DavidHalls
Jun 23 2016 01:39
@danijmoss did you what did you return and what did you alter
Diego Mayer
@Chrono79
Jun 23 2016 01:40
yes, I know @danijmoss try return arr.shift(); don't use shift twice
Dani
@danijmoss
Jun 23 2016 01:41
here is the code ive tried and it returns errors
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.shift([0]);

  return arr.shift();  // Change this line
}
Tamika
@tbishop225
Jun 23 2016 01:41
Thank You @Chrono79
CamperBot
@camperbot
Jun 23 2016 01:41
tbishop225 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1274 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 23 2016 01:41
@danijmoss I told you not to use it twice, delete arr.shift([0]);
Dani
@danijmoss
Jun 23 2016 01:42
oh i see! ok im with you now
thanks @Chrono79 appreciate it!
CamperBot
@camperbot
Jun 23 2016 01:42
danijmoss sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1275 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 23 2016 01:42
:+1:
Dani
@danijmoss
Jun 23 2016 01:43
and now its off to bed for me after i make my #100daysofcodepost
Daniel Skoglund
@Daniel-Skoglund
Jun 23 2016 01:43
Thanks ! @Chrono79
CamperBot
@camperbot
Jun 23 2016 01:43
daniel-skoglund sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1276 | @chrono79 |http://www.freecodecamp.com/chrono79
Hassan ben haj
@Hassanbhb
Jun 23 2016 01:49
guys how do i remove all non-alphanumeric characters
???
Bartek
@dyczol
Jun 23 2016 01:49
@Hassanbhb you can use regular expressions
Diego Mayer
@Chrono79
Jun 23 2016 01:49
with a proper regex, there are several can do the same and using replace
Bartek
@dyczol
Jun 23 2016 01:50
there is a nice website to learn and test them http://regexr.com/
Hassan ben haj
@Hassanbhb
Jun 23 2016 01:50
hmmm
thanks I'm going to check that out
Bartek
@dyczol
Jun 23 2016 01:51
@Hassanbhb yeah, check out the cheat-sheet section
Hassan ben haj
@Hassanbhb
Jun 23 2016 01:58
I still don't understand this but it need more time
so Many symboles with meanings
hahahaha
Bartek
@dyczol
Jun 23 2016 02:00
which challenge are you working on ?
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:00
function updateRecords(id, prop, value)
{
if(value!=="")
{
if(prop=="tracks")
{
if(!collection[id].hasOwnProperty(prop))
{
collection[id][prop]=[];
}
collection[id][prop].push(value);
}
else
{
collection[id][prop]=value;
}
}
return collection;
}
@dyczol
need help with above code
Diego Mayer
@Chrono79
Jun 23 2016 02:00
@prijuly2000 you need to do something when value === ""
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:01
i dont think that is the problem
Diego Mayer
@Chrono79
Jun 23 2016 02:01
why not?
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:02
I am working on "check for Palindromes"
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:02
cause the edit should be done when value !== ""
there is nothing to do when it is null
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:03
@dyczol I am working on check for Palindromes" challenge
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:03
and the function should return collection irrespective of change
@Chrono79
Diego Mayer
@Chrono79
Jun 23 2016 02:03
@prijuly2000 If value is blank, delete that prop.
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:03
ok
let me try that
@Chrono79 it worked . Thank you. THey need to rephrase the task
CamperBot
@camperbot
Jun 23 2016 02:04
prijuly2000 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1277 | @chrono79 |http://www.freecodecamp.com/chrono79
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:05
it says "do not set the property" but it should say remove or delete the property @Chrono79
Bartek
@dyczol
Jun 23 2016 02:05
@Hassanbhb are you familiar with .replace ?
Diego Mayer
@Chrono79
Jun 23 2016 02:06

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

For the given id in collection:

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

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

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

If value is blank, delete that prop.

Always return the entire collection object.

where does it say "do not set the property"? I'm not seeing it
Pritesh Gandhi
@prijuly2000
Jun 23 2016 02:07
After updateRecords(2548, "artist", ""), artist should not be set
in the tasks below
Bartek
@dyczol
Jun 23 2016 02:07
@Hassanbhb let me see what you got so far
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:08
@dyczol no I am reading about it, but it's alittle bit weird.
Diego Mayer
@Chrono79
Jun 23 2016 02:09
Well, you have to read both, the instructions and the tasks. Could that be rephrased? Maybe. I don't think that point in particular is the most problematic of the challenge.
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:10
@dyczol
@dyczol

function palindrome(str) {
// Good luck!
var word = str.split("").reverse().join("");
if(word === str){
return true;
}else{
return false;
}
}

palindrome("eye");

this code just checks if the word is a palindrome but it fails when there are non-alphanumeric characters
Diego Mayer
@Chrono79
Jun 23 2016 02:12
@Hassanbhb have you seen toLowerCase or toUpperCase?
Amilyn
@amilynamanilla
Jun 23 2016 02:12

hi everyone, i'm doing the Profile Lookup challenge. I am given a JSON with profiles (name, and other properties), and i have to write a code for a fucntion which takes the firstname and a property as arguments, and then return the value of that property.

I've decided to run a switch/case to see if the firstname exists, and if it does, within it, run another switch/case code to see if property exists.

am i going the right direction?

Johnny
@JohnnyBizzel
Jun 23 2016 02:12
@Hassanbhb What if you have spaces?
Diego Mayer
@Chrono79
Jun 23 2016 02:13
@amilynamanilla don't you need to use a loop?
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:14
@JohnnyBizzel it fails when there are spaces
Amilyn
@amilynamanilla
Jun 23 2016 02:14
@Chrono79 yes, i thought about that too.. since the challenge comes immediately after loops exercises
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:14
@Chrono79 I know those
Diego Mayer
@Chrono79
Jun 23 2016 02:15
@Hassanbhb use one of those 2 to level the letters first
Amilyn
@amilynamanilla
Jun 23 2016 02:15
@Chrono79 oh yes, sorry, i'll be using loops, then switch
let me show u my code (incomplete)
Johnny
@JohnnyBizzel
Jun 23 2016 02:15
@Hassanbhb Get rid of the spaces (and none alpha chars) before doing the comparison
Amilyn
@amilynamanilla
Jun 23 2016 02:15
@Chrono79
```
var firstNameInput = firstName;
var propInput = prop;
for (var i=0; i < contacts.length; i++) {
switch (firstNameInput) {
case contacts[i].firstname:
for (var j=1; j < contacts[j-1].length; j++) {
switch (propInput) {
case contacts[j-1][j]:
contacts[j-1][j];
break;
default:
return "No such property"
}
}
break;
default:
return "No such contact";
}
}
Diego Mayer
@Chrono79
Jun 23 2016 02:15
@amilynamanilla I suggest using ifs instead of switch in the challenge, you could try though
Amilyn
@amilynamanilla
Jun 23 2016 02:16
@Chrono79
var firstNameInput = firstName;
var propInput = prop;
  for (var i=0; i < contacts.length; i++) {
    switch (firstNameInput) {
      case contacts[i].firstname:
        for (var j=1; j < contacts[j-1].length; j++) {
          switch (propInput) {
            case contacts[j-1][j]:
              contacts[j-1][j];
              break;
            default:
              return "No such property"
          }
        }
        break;
      default:
        return "No such contact";
    }
  }
Johnny
@JohnnyBizzel
Jun 23 2016 02:16
@amilynamanilla I wouldn't use Switch/case. I would just use a loop
Diego Mayer
@Chrono79
Jun 23 2016 02:16
@amilynamanilla only one loop is enough
Johnny
@JohnnyBizzel
Jun 23 2016 02:16
@amilynamanilla if statement would do the same, no?
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:17
@JohnnyBizzel ok thanks
CamperBot
@camperbot
Jun 23 2016 02:17
hassanbhb sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 323 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Srinivasan
@kksrini89
Jun 23 2016 02:17
I am working on sum all odd fibonacci numbers challenge, but some reason it is hanged.. not able to change challenge too
any help what to do now?
Amilyn
@amilynamanilla
Jun 23 2016 02:18
@Chrono79 @JohnnyBizzel i think i understand why you mean.. haha.. now i am scratching my head how to access a property within a nested array if i don't know what it is called.. to iterate through and see if it == the argument
Johnny
@JohnnyBizzel
Jun 23 2016 02:18
@amilynamanilla Use switch cases when there are lots of different results you want to find.
Diego Mayer
@Chrono79
Jun 23 2016 02:18
@amilynamanilla contacts[i].firstname, should be contacts[i].firstName
Srinivasan
@kksrini89
Jun 23 2016 02:19
waiting for anyone help...
Johnny
@JohnnyBizzel
Jun 23 2016 02:19
@amilynamanilla 2 or more loops (loop within a loop)
Diego Mayer
@Chrono79
Jun 23 2016 02:20
Johnny
@JohnnyBizzel
Jun 23 2016 02:20
@kksrini89 I just did that challenge. Can paste what you did so far?
Amilyn
@amilynamanilla
Jun 23 2016 02:20
@JohnnyBizzel @Chrono79 ok i'm going to try out based on your inputs, i'll let u know if it works!
Johnny
@JohnnyBizzel
Jun 23 2016 02:21
@amilynamanilla Best of luck! ;)
Srinivasan
@kksrini89
Jun 23 2016 02:21
@Chrono79
var fib = [];
fib[0] = 0;
fib[1] = 1;
for(var i =2; i <=num; i++){
  fib[i] = fib[i-2] + fib[i-1] ;
}
return fib;
this is what I wrote inside function
@JohnnyBizzel
Diego Mayer
@Chrono79
Jun 23 2016 02:22
that only creates num+1 fibonacci numbers
Srinivasan
@kksrini89
Jun 23 2016 02:23
but it is hanged I am not able to operate on freecodecamp site itself
Diego Mayer
@Chrono79
Jun 23 2016 02:24
weird, try disabling autorun as I posted before
Johnny
@JohnnyBizzel
Jun 23 2016 02:24
@kksrini89 Just looking now...
Srinivasan
@kksrini89
Jun 23 2016 02:24
@JohnnyBizzel hmm
@Chrono79 how can we disable auto run?
Diego Mayer
@Chrono79
Jun 23 2016 02:25
Srinivasan
@kksrini89
Jun 23 2016 02:25
@Chrono79 I am doing
let me check
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:25

@Chrono79
function palindrome(str) {
var lowerCaseStr = str.toLowerCase();
var checkIfPal = lowerCaseStr.split("").reverse().join("");
if(checkIfPal === lowerCaseStr){
return true;
}else{
return false;
}
}

palindrome("racecar");

I now turn every letter to lowercase
Diego Mayer
@Chrono79
Jun 23 2016 02:26
@Hassanbhb the logic is ok, but you still need to clean all that's not a letter or a number with a regex
Hassan ben haj
@Hassanbhb
Jun 23 2016 02:27
@Chrono79 yep that's what I am trying to learn
the regex thing is new to me
Johnny
@JohnnyBizzel
Jun 23 2016 02:28
@kksrini89 I think the number you pass is the highest value allowed. It is not the number of items in the series. Your look would give 1000 numbers if you input 1000.
(i think)
...into the function
Srinivasan
@kksrini89
Jun 23 2016 02:28
@JohnnyBizzel I agree your point
actually still the logic is not done fully\
I am about to do now
Diego Mayer
@Chrono79
Jun 23 2016 02:29
better use a while loop @kksrini89
Johnny
@JohnnyBizzel
Jun 23 2016 02:30
@kksrini89 Good luck :)
Srinivasan
@kksrini89
Jun 23 2016 02:30
@Chrono79 if this is the url, how we can give run=disabled
@JohnnyBizzel fine.
Srinivasan
@kksrini89
Jun 23 2016 02:31
@Chrono79 wow
it is responded now
@Chrono79 thank you
CamperBot
@camperbot
Jun 23 2016 02:32
kksrini89 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1278 | @chrono79 |http://www.freecodecamp.com/chrono79
guapokat
@guapokat
Jun 23 2016 02:33

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

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

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

I can't get this to display No such contact; any ideas?

It is for the "Profile lookup" java script problem
Johnny
@JohnnyBizzel
Jun 23 2016 02:34
@Hassanbhb With the RegEx test, I recommend testing every letter separately using a loop.
Diego Mayer
@Chrono79
Jun 23 2016 02:35

@guapokat

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

How could it be this contacts[i].firstName === firstName and inside that if !contacts[i].hasOwnProperty(firstName) ?

Nathaniel Nasarow
@Torgian
Jun 23 2016 02:35
Allright
I think I need help with Seek and Destroy
This is what i have so far
function destroyer(arr) {
  // Remove all the values
  var arg = [];
  var filteredOut = [];

  for (i = 1; i < arguments.length; i++) {
    console.log(arguments[i]);
    arg.push(arguments[i]);
  }

   return arr.filter(function(filtered) {


    return arg[filtered];

  });



}




destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3);
guapokat
@guapokat
Jun 23 2016 02:37
@Chrono79 lol stupid mistake let me fix it
Nathaniel Nasarow
@Torgian
Jun 23 2016 02:38
I figured arg[filtered] wasn't logical, and it isn't since it takes everything out beyond 3 as well
But I'm having a hard time figuring out how to filter it correctly
Johnny
@JohnnyBizzel
Jun 23 2016 02:39
@guapokat As a general rule, if some code is not being reached, check the conditions are not preventing it.
Nathaniel Nasarow
@Torgian
Jun 23 2016 02:41
@Chrono79 Kind of, been doing this problem for the past couple of days, and reading more about filtered. I know that it iterates through each element in the array one by one while checking for what it is filtering out
Diego Mayer
@Chrono79
Jun 23 2016 02:42
if what you return inside filter is true, that value is kept, else it's discarded
Johnny
@JohnnyBizzel
Jun 23 2016 02:42
@Torgian
function removeValue(val) { if (val != this) return val; }
guapokat
@guapokat
Jun 23 2016 02:43
thank you @Chrono79 and @JohnnyBizzel I restructured to: var answer = "";
for(var i = 0; i < contacts.length; i++)
{
if(contacts[i].firstName === firstName)
{
if(contacts[i].hasOwnProperty(prop))
answer = contacts[i][prop];
else if(!contacts[i].hasOwnProperty(prop))
answer = "No such property";
}
}
if(answer === "")
answer = "No such contact";
return answer;
CamperBot
@camperbot
Jun 23 2016 02:43
guapokat sends brownie points to @chrono79 and @johnnybizzel :sparkles: :thumbsup: :sparkles:
:star2: 1279 | @chrono79 |http://www.freecodecamp.com/chrono79
:cookie: 324 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
guapokat
@guapokat
Jun 23 2016 02:43
I didn't know I could send brownie points...well ya'll deserve it!
Johnny
@JohnnyBizzel
Jun 23 2016 02:44
^_^
:)
Diego Mayer
@Chrono79
Jun 23 2016 02:44
@guapokat
just to improve your code:
if(contacts[i].hasOwnProperty(prop))
answer = contacts[i][prop];
else if(!contacts[i].hasOwnProperty(prop)) // if it isn't true, it's false, so no need for this condition
guapokat
@guapokat
Jun 23 2016 02:46
@Chrono79 thanks! I will admit my code is newbishly ugly but I enjoy this stuff :smile:
CamperBot
@camperbot
Jun 23 2016 02:46
guapokat sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: guapokat already gave chrono79 points
Diego Mayer
@Chrono79
Jun 23 2016 02:47
once it works, you can clean it and make it more efficient, by now, just focus in making it work @guapokat
guapokat
@guapokat
Jun 23 2016 02:48
ty again
3jM310
@3jM310
Jun 23 2016 02:49

guys what i have to do here? function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Johnny
@JohnnyBizzel
Jun 23 2016 02:50
@3jM310 Don't just have to return a sentence?
David Shute
@dshute
Jun 23 2016 02:50
Perhaps a stupid question. I'm working on the local weather app project. I need https to user geolocation.getCurrentPosition, but the free account with the recommended OpenWeatherAPI only supports SSL for paid accounts. I'd prefer not to hard code the location. Does anyone have any suggestions? Location workaround or free SSL API?
Diego Mayer
@Chrono79
Jun 23 2016 02:50

@Torgian
function removeValue(val) { if (val != this) return val; }

@JohnnyBizzel if you use that function to filter and one value is false, won't it be filtered too?

@dshute look at jsonp
B
@btolor
Jun 23 2016 02:51

Hello everybody Im having a problem getting pass the "Record Collection" challenge and nothing i try seems to work. This is what i've coded : // 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] = [value];
else if (value === "")
delete collection[id][prop];

return collection;
}

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

clintonjohn
@clintonjohn
Jun 23 2016 02:51
Who knew FCC could be existential philosophy too
var myStr = "I am a \"double quoted\" string inside \"double quotes\".";
David Shute
@dshute
Jun 23 2016 02:52
@Chrono79 - will do. thank you.
CamperBot
@camperbot
Jun 23 2016 02:52
dshute sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1280 | @chrono79 |http://www.freecodecamp.com/chrono79
Johnny
@JohnnyBizzel
Jun 23 2016 02:52
@Chrono79 True but in the sample tests, there were no booleans.
Diego Mayer
@Chrono79
Jun 23 2016 02:52
@JohnnyBizzel :+1:
3jM310
@3jM310
Jun 23 2016 02:52
but where i need to return a sentences? or what i need to add? @JohnnyBizzel
Johnny
@JohnnyBizzel
Jun 23 2016 02:53
@Chrono79 just numbers and strings
Diego Mayer
@Chrono79
Jun 23 2016 02:53
@JohnnyBizzel and 0 ?
Aaron Hanna
@AaronHanna
Jun 23 2016 02:54

Having trouble getting the api call through for the Media Wiki API ...

$(document).ready(function() {

  var form = document.querySelector("form");

  form.addEventListener("submit", function(event) {
    var theSearch = form.elements.search.value;
    var apiUrl = "en.wikipedia.org/w/api.php?action=query&list=search&srsearch=" + theSearch + "&utf8=";

    $.ajax({
      type: "GET",
      url: apiUrl,
      dataType: 'jsonp',
      headers: { 'Api-User-Agent': /* what goes here? */ },
      success: function(data) {
      console.log(data);
      }
    });

    event.preventDefault();
  });   
});

Trying to use ajax to make the cal because the problem seems to the "user agent". Am I even barking up the right tree? Very confused ...

Johnny
@JohnnyBizzel
Jun 23 2016 02:54
@Chrono79 noted
Diego Mayer
@Chrono79
Jun 23 2016 02:54
@btolor you need to check if tracks exists, and use push to add, because with collection[id][prop] = [value]; you're overwriting previous values (if they exist of course)
Johnny
@JohnnyBizzel
Jun 23 2016 02:55
@3jM310 Can't remember but if you create a new string and join the variables together, then return the resulting string...
Diego Mayer
@Chrono79
Jun 23 2016 02:55
@3jM310 read Mad Libs link and review this challenge too: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
Johnny
@JohnnyBizzel
Jun 23 2016 02:57
@dshute I didn't like that challenge. The browser will ask "do you want to allow the location". At which point your code has already called the API.
Then the user has to call the weather API again?
Diego Mayer
@Chrono79
Jun 23 2016 02:58
@dshute you could also use an ip location api instead of native browser geolocation
Johnny
@JohnnyBizzel
Jun 23 2016 02:59
@dshute Mine didn't use https ... http://codepen.io/JohnnyBizzel/pen/BKMPpp
clintonjohn
@clintonjohn
Jun 23 2016 02:59
Is there a casual FCC chat room. If so, could I have the link?
Diego Mayer
@Chrono79
Jun 23 2016 02:59
help rooms
CamperBot
@camperbot
Jun 23 2016 02:59

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

Chat Room Description Chat Room
HTML/CSS/Bootstrap FreeCodeCamp/Help
JavaScript/Algorithms FreeCodeCamp/HelpJavaScript
Front End FreeCodeCamp/HelpFrontEnd
Data Visualization FreeCodeCamp/HelpDataViz
Back End FreeCodeCamp/HelpBackEnd

Choose the right room for your questions!

See also: :earth_asia: Language Specific | :satellite: Technology | :crystal_ball: Miscellaneous

back to top ↑

:pencil: read more about help rooms on the FCC Wiki

Johnny
@JohnnyBizzel
Jun 23 2016 02:59
@clintonjohn Freecodecamp?
clintonjohn
@clintonjohn
Jun 23 2016 03:00
Yes. A room where we can be off topic
That room seems to have more general chat
clintonjohn
@clintonjohn
Jun 23 2016 03:01
Ok thanks.
Thanks @JohnnyBizzel
CamperBot
@camperbot
Jun 23 2016 03:01
clintonjohn sends brownie points to @johnnybizzel :sparkles: :thumbsup: :sparkles:
:cookie: 325 | @johnnybizzel |http://www.freecodecamp.com/johnnybizzel
Diego Mayer
@Chrono79
Jun 23 2016 03:04
satendra nath chowdhary
@snc1992
Jun 23 2016 03:11
can anyone help me with the card count challenge
Kyle
@joyceky
Jun 23 2016 03:13
Maybe I can help; I just completed it. Where are you stuck?
Diego Mayer
@Chrono79
Jun 23 2016 03:14
bye
Kyle
@joyceky
Jun 23 2016 03:14
@snc1992 Forgot to tag. "Maybe I can help; I just completed it. Where are you stuck?"
3jM310
@3jM310
Jun 23 2016 03:15
im really stuck in the WORD BLANK challenge i try putting words and nothing someone can give a example how is it?
Lemmy
@imnotlammy
Jun 23 2016 03:15
Still learning to use the filter method
Can someone explain why the below isn't working?
David Halls
@DavidHalls
Jun 23 2016 03:15
@3jM310 hit me up homie
Lemmy
@imnotlammy
Jun 23 2016 03:15
function diffArray(arr1, arr2) {
  var newArr = [];

  var arr3 = arr1.concat(arr2);

  function isUniq(element, index, array) {
    if (element !== array.indexOf(index)) {
      return true;
    }
    else {
      return false;
    }
  }

  newArr = arr3.filter(isUniq);

  return newArr;
David Halls
@DavidHalls
Jun 23 2016 03:16
This message was deleted
This message was deleted
Lemmy
@imnotlammy
Jun 23 2016 03:18
@Byzgig ?
3jM310
@3jM310
Jun 23 2016 03:21
ok im not from EEUU and in my contry we dont play Mad libs thats why i asking how the WORD BLANK challenge works i apologize i just learning and i dont understand how this challenge works
David Halls
@DavidHalls
Jun 23 2016 03:22
@3m just connect all of the variables in a string
@3jM310
3jM310
@3jM310
Jun 23 2016 03:27
ok thanks @Byzgig
CamperBot
@camperbot
Jun 23 2016 03:27
3jm310 sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @byzgig |http://www.freecodecamp.com/byzgig
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:27
ok
so this is where I always get stuck on Seek and Destroy
Daniel Cartín
@Danielcv93
Jun 23 2016 03:28
hi, can somenone tell me why the tweeter button doesn't works
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:28
function destroyer(arr) {
  // Remove all the values
  var arg = [];
  var filteredOut = [];

  for (i = 1; i < arguments.length; i++) {
    arg.push(arguments[i]);
};

  var filtered = arr.filter(function(value){
    return value != arg[0];
  });



  console.log(filtered);
}

destroyer([1, 2, 3, 1, 2, 4, 3], 2, 3);
David Halls
@DavidHalls
Jun 23 2016 03:29
@Danielcv93 you need _blank
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:29
I need a way to filter out the 2's and 3's; obviously I can't do this one at a time, and value != arg does not work, as it's only reading the array as a whole.
Daniel Cartín
@Danielcv93
Jun 23 2016 03:30
@Byzgig what do you mean?
Dan
@dcgoings
Jun 23 2016 03:34
@BKinahan you around?
David Halls
@DavidHalls
Jun 23 2016 03:35
@Danielcv93 in codepen you have to use target="_blank" to use links
Dan
@dcgoings
Jun 23 2016 03:35
anyone familiar with twitter web intents?
Stephen James
@sjames1958gm
Jun 23 2016 03:37
@Torgian Do you need a loop over arg?
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:38
Pretty much, yes, but a for loop doesn't seem to work inside filter. The moment you return the value of arg[i], it stops the loop
Stephen James
@sjames1958gm
Jun 23 2016 03:39
You put one return value inside the loop and one after the for loop
@Torgian The one in the for loop is the return false and the one after is return true
3jM310
@3jM310
Jun 23 2016 03:43

i think im wrong with this but im try to get an idea how works advice please! function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "cat, little, hit, quickly";
// Your code below this line
var result1 = "dog, big, ran, quickly";
var result2 = result + result1;
// Your code above this line
return result2;
}

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

Stephen James
@sjames1958gm
Jun 23 2016 03:44
@3jM310 A function is designed to be generic you should not have any of the string values inside the function - use the parameters to build the string.
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:47
@sjames1958gm I don't think that is going to help me xD because I still need to check the value against the arg array
and I cant reach that outside the for loop
Stephen James
@sjames1958gm
Jun 23 2016 03:48
@Torgian You have a for loop over the arg array, if any match the current filtered entry return false, if none do (for loop ends) return true.
Sure you can access arg outside the for loop
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:49
yes, but not the [i] or [j] out side of the loop.
3jM310
@3jM310
Jun 23 2016 03:50
ok thanks @sjames1958gm
CamperBot
@camperbot
Jun 23 2016 03:50
3jm310 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1634 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Josh
@joshweaver23
Jun 23 2016 03:50
Hey all, I know this is a little off topic, but I'm working on a conway's game of life app using AngularJS and having a bit of trouble. If anyone knows Angular and has a few minutes, I'd love some help. Right now I'm having trouble initializing my board (not building and not sure why). http://codepen.io/jweaver/pen/ZOBRpR?editors=1010
Stephen James
@sjames1958gm
Jun 23 2016 03:50
@Torgian
for (var i = 0; i < args.length; i++) {
  if (value === args[i]) return false;
}
return true;
Another option is to use array every function
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:54
ahh I see what you mean then
Stephen James
@sjames1958gm
Jun 23 2016 03:55
@Torgian This is a common pattern and why there is the every function.
Nathaniel Nasarow
@Torgian
Jun 23 2016 03:56
ok
Niush Sitaula
@Niush
Jun 23 2016 04:10

How to change the html again into"Like" - with second click. Need Help

$('.button4').click(function() {
$('.change').html('Liked');
});

David Halls
@DavidHalls
Jun 23 2016 04:12
@Niush why a second click?
Niush Sitaula
@Niush
Jun 23 2016 04:18
@Byzgig - When I click the .button4 again its HTML should change into 'Like' only. (Similar to Facebook)
Lemmy
@imnotlammy
Jun 23 2016 04:19
Looking for someone to walk me through filter() method
PM Me!
David Halls
@DavidHalls
Jun 23 2016 04:19
@Niush im thinking it should be something like $('.button4').addClass('.change')
Peter Weinberg
@no-stack-dub-sack
Jun 23 2016 04:21
Help please! I don't know if anyone can tell without seeing all the code, but is there any reason this code shouldn't work that I am missing? This for for toggle between C and F for my weather app. visit the pen if need to see all code in context (and keep in mind it's nowhere near done): http://codepen.io/no_stack_dub_sack/pen/rLMbWG?editors=1011
$("#unit").on("click", function() {
      if (document.getElementById("unit").innerHTML = "F") {
        var cel = (temp - 32) * 5/9;
        cel = Math.round(cel);
        $("#temperature").html("The temp is: " + cel + " °");
        $("#unit").html("C");
      } else if (document.getElementById("unit").innerHTML = "C") {
        $("#temperature").html("The temp is: " + temp + " °");
        $("#unit").html("F");
      }
    });
CamperBot
@camperbot
Jun 23 2016 04:21
no wiki entry for: please i dont know if anyone can tell without seeing all the code but is there any reason this code shouldnt work that i am missing this for for toggle between c and f for my weather app visit the pen if need to see all code in context and keep in mind its nowhere near done httpcodepeniono_stack_dub_sackpenrlmbwgeditors1011unitonclick function if documentgetelementbyidunitinnerhtml f var cel temp - 32 59 cel mathroundcel temperaturehtmlthe temp is cel unithtmlc else if documentgetelementbyidunitinnerhtml c temperaturehtmlthe temp is temp unithtmlf
Niush Sitaula
@Niush
Jun 23 2016 04:22
@Byzgig - But the CSS is not changing its content.
Coy Sanders
@coymeetsworld
Jun 23 2016 04:23
@no-stack-dub-sack I think you should move the click function outside of the getJSON call
Peter Weinberg
@no-stack-dub-sack
Jun 23 2016 04:24
@coymeetsworld I started with it like that, but then the temp variable would be undefined
Stephen James
@sjames1958gm
Jun 23 2016 04:26
@no-stack-dub-sack Your code needs === not = when checking innerHTML
Peter Weinberg
@no-stack-dub-sack
Jun 23 2016 04:28
@sjames1958gm that did it! thanks! I swear I tried that before and it didn't work. I must've messed it up somehow. I knew most of the code looked OK, and that it should've been as easy fix so I tried working it out for a while before asking for help. Thanks man!
CamperBot
@camperbot
Jun 23 2016 04:28
no-stack-dub-sack sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1635 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 23 2016 04:29
@no-stack-dub-sack :+1:
Stefan Bekirov
@bekir0v
Jun 23 2016 04:29
anybody has problem with Concatenating Strings with Plus Operator
```
gitSnake
@GitSnake
Jun 23 2016 04:29
I'm on exercise 162... what am I missing? var myStr = "Here is a backslash: \.\n\t\t"; // Change this line
Stefan Bekirov
@bekir0v
Jun 23 2016 04:30
// Example
var ourStr = "I come first. " + "I come second.";

// Only change code below this line

var myStr = "This is the start." + "This is the end.";
Stephen James
@sjames1958gm
Jun 23 2016 04:30
@GitSnake Did you get all of the text.
gitSnake
@GitSnake
Jun 23 2016 04:31
@sjames1958gm Here is a backslash: backslash.newline tab tab Here is a new line with two tabs.
Stefan Bekirov
@bekir0v
Jun 23 2016 04:32
I can't see what is wrong
anybody for help
Anuj Upadhyay
@anuj97
Jun 23 2016 04:32
@bekir0v take care of the space between the sentences
Stephen James
@sjames1958gm
Jun 23 2016 04:32
@GitSnake I don't see the Here is a new line with two tabs in your code.
Stefan Bekirov
@bekir0v
Jun 23 2016 04:32
I did it
it's still same
Stephen James
@sjames1958gm
Jun 23 2016 04:33
@bekir0v You added a space after the period in the first sentence?
gitSnake
@GitSnake
Jun 23 2016 04:33
@sjames1958gm maybe the new line is missing
Stefan Bekirov
@bekir0v
Jun 23 2016 04:34
@sjames1958gm yes
Praneeth
@praneethkumarpidugu
Jun 23 2016 04:34
Hello World!
CamperBot
@camperbot
Jun 23 2016 04:34

welcome to FreeCodeCamp @praneethkumarpidugu!

Anuj Upadhyay
@anuj97
Jun 23 2016 04:35
@praneethkumarpidugu Hello!
Praneeth
@praneethkumarpidugu
Jun 23 2016 04:35
I have written a quick script for "Counting cards"

var count = 0;
var Bet = null;

function cc(card) {
  // Only change code below this line
  if (card >= 2 && card <= 6) {
    count = count + 1;

  }

  if (card >=7 && card <=9) {

    count = count + 0;
  }

  if (card == 10 || card == "J" || card == "Q" || card == "K" || card == "A"){
      count = count - 1;
      }

  if (count * 1 == count && count !== 0) {
    Bet = "Bet";
  } else if (count*(-1) == count && count === 0) {
    Bet = "Hold";
  }
  return count+' '+Bet;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
//cc(2); cc(3); cc(4); cc(5); cc(6);
//cc(7); cc(8); cc(9);
//cc(10); cc('J'); cc('Q'); cc('K'); cc('A');
cc(3); cc(7); cc('Q'); cc(8); cc('A');
//cc(2); cc('J'); cc(9); cc(2); cc(7);
Stephen James
@sjames1958gm
Jun 23 2016 04:36
@bekir0v var myStr = "This is the start. " + "This is the end.";
Praneeth
@praneethkumarpidugu
Jun 23 2016 04:36
Out of 7 test cases 4 pass and 3 fail
Could anyone point me where I'm going wrong
Stefan Bekirov
@bekir0v
Jun 23 2016 04:36
@sjames1958gm let me try
Anuj Upadhyay
@anuj97
Jun 23 2016 04:37
This message was deleted
CamperBot
@camperbot
Jun 23 2016 04:37
:bulb: to format code use backticks! ``` more info
Stephen James
@sjames1958gm
Jun 23 2016 04:37
@praneethkumarpidugu how will count * -1 ever equal count? You are supposed to compare count to zero as in count < 0
@GitSnake var myStr = "Here is a backslash: \\.\n\t\tHere is a new line with two tabs.";
Stefan Bekirov
@bekir0v
Jun 23 2016 04:38
@sjames1958gm Thank you Sir
CamperBot
@camperbot
Jun 23 2016 04:38
bekir0v sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1636 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Anuj Upadhyay
@anuj97
Jun 23 2016 04:38
let me try again

' ' ' 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",

};

console.log(lookup.alpha);

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

CamperBot
@camperbot
Jun 23 2016 04:39
:bulb: to format code use backticks! ``` more info
Anuj Upadhyay
@anuj97
Jun 23 2016 04:39
why doesnt that work?
actually the formatting!!!
Praneeth
@praneethkumarpidugu
Jun 23 2016 04:39
@anuj97 yes it does work I simply passed if count > 0 and count <=0
@anuj97 I was carried thinking more than simple logic
@anuj97 Thanks :)
CamperBot
@camperbot
Jun 23 2016 04:41
praneethkumarpidugu sends brownie points to @anuj97 :sparkles: :thumbsup: :sparkles:
:cookie: 205 | @anuj97 |http://www.freecodecamp.com/anuj97
Ankur sharma
@ankur1163
Jun 23 2016 04:49
can someone tell me
how to pass value from data to table?
what should I put in place of this
{ name:'damn', content:'jert' },
        { name: 'Row two', content: 'They work like above' },
    ]} >
Rickey Olsen
@rickeyolsen
Jun 23 2016 04:58
This is "Stand In Line", I cant seem to make this code work. I'm supposed to add to the end of the array ,then remove the first element in the array.x
Anuj Upadhyay
@anuj97
Jun 23 2016 04:58
not working!!
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",
  };

  console.log(lookup.alpha);

  // Only change code above this line
  return result;
}
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:00
function nextInLine(testArr, item) {
  // Your code here
  testArr.push();
  testArr.shift();

  return testArr.unshift(); // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 10)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
bitgrower
@bitgrower
Jun 23 2016 05:00
well ... first you have to return something other than an empty value, @rickeyolsen :)
oops ... sorry wrong post ...
Anuj Upadhyay
@anuj97
Jun 23 2016 05:01
@bitgrower the console.log isn't working even
bitgrower
@bitgrower
Jun 23 2016 05:01
@rickeyolsen - you are not using the itme parameter, and you are using testArr -- you shouldn't use TestArr at all in your code ... use the item parameter instead ...
@anuj97 -- your console.log call is not referencing the object in the right way ... try using a quoted string within object bracket notation ..
Anuj Upadhyay
@anuj97
Jun 23 2016 05:03
@bitgrower already tried, no result!
bitgrower
@bitgrower
Jun 23 2016 05:04
well...you ALSO have to use the val parameter, eh ?
what's with you guys? You allergic to function parameters or something ?!?
what do you think they're provided for, LOL ?
Anuj Upadhyay
@anuj97
Jun 23 2016 05:05
@bitgrower I removed the val parameter, b'coz I thought it should have ended up adding a new property
bitgrower
@bitgrower
Jun 23 2016 05:06
@anuj97 not if you use it correctly !
Anuj Upadhyay
@anuj97
Jun 23 2016 05:06
this one is a kind of "check code"
bitgrower
@bitgrower
Jun 23 2016 05:07
if I just say return myObj[someVal]; it's going to look up the property contained in the variable someVal within the myObj object and return the value of that object's property ... does that help ?
Mark Ayoub
@mk485eg
Jun 23 2016 05:07
GM
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:07
im supposed to be pushing and shifting items to and from the testArr, how am I supposed to use "item" and do that? I'm just not seeing it
Anuj Upadhyay
@anuj97
Jun 23 2016 05:07
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;
}
This is what you are talkig about, isn't it?
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:07
@bitgrower ^^^^
bitgrower
@bitgrower
Jun 23 2016 05:08
@anuj97 a LOT closer ... yes ... now, just use bracket notation instead of dot notation and you should have it ...
@rickeyolsen hang on
okay ... wait ... I gotta look at see what's originally provided ... something is not quite right ...
Anuj Upadhyay
@anuj97
Jun 23 2016 05:09
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;
}
still doesn't work
bitgrower
@bitgrower
Jun 23 2016 05:10
@anuj97 you only need quotes for literal strings ...
val is not a literal string ...
Anuj Upadhyay
@anuj97
Jun 23 2016 05:11
@bitgrower got it!
bitgrower
@bitgrower
Jun 23 2016 05:11
:)
bitgrower @bitgrower is hungry ... cookie monster brownies ...
Mark Ayoub
@mk485eg
Jun 23 2016 05:12
blob
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:14
@mk485eg Looks like you just need to mimick the code already shown.
bitgrower
@bitgrower
Jun 23 2016 05:14

@rickeyolsen ... why did you change the parameter name ... does it say to change the name of the parameter somewhere ? No ... it says "your code here" -- go reset your code ... the answer for Stand In line can be done EASILY in 3 lines ... with a minor amount of editing 2 lines ...

Go review the previous 4 challenges and make sure you understand what all the 4 array functions do, how to use them what they return, how they affect the array (if at all) ... use Mozilla Developer Network to help you out ... and also try seeing what happens in the variables by using this site: pythontutor.com/javascript.html

Mark Ayoub
@mk485eg
Jun 23 2016 05:15

gm
function minusSeven(num) {
return num * 5;
}

// Only change code below this line
var timesFive = minusSeven(5);
var timesFive = minusSeven(2);
var timesFive = minusSeven(0);
timesFive should be a function
timesFive(5) should return 25
timesFive(2) should return 10
timesFive(0) should return 0
any idea what i makes wrong ?

Rickey Olsen
@rickeyolsen
Jun 23 2016 05:15
function timesFive(num) {
     return num*5;
};
bitgrower
@bitgrower
Jun 23 2016 05:15
@mk485eg what is the name of the challenge ?
Mark Ayoub
@mk485eg
Jun 23 2016 05:15
Return a Value from a Function with Return @bitgrower
bitgrower
@bitgrower
Jun 23 2016 05:16
thank you ..
what a weird name ...
Mark Ayoub
@mk485eg
Jun 23 2016 05:16
:)
Wang Zhe
@wangzheblue
Jun 23 2016 05:16
function destroyer(arr) {
var newArr = arguments[0].filter(function(val){
for (i = 1;i<arguments.length;i++){
if (val === arguments[i]){
return false;
}
}
return true;
}
);
return newArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Mark Ayoub
@mk485eg
Jun 23 2016 05:16
@bitgrower any idea ?
Wang Zhe
@wangzheblue
Jun 23 2016 05:17
Hi anybody knows where went wrong as I keep return the original arguments[0]
Amilyn
@amilynamanilla
Jun 23 2016 05:17
hello! anyone already done with the "Profile Lookup" challenge, or doing it now? I need help
Wang Zhe
@wangzheblue
Jun 23 2016 05:17
Appreciate your help very much!
Anuj Upadhyay
@anuj97
Jun 23 2016 05:17
@bitgrower thanks
CamperBot
@camperbot
Jun 23 2016 05:18
anuj97 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1110 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 23 2016 05:18
yep -- you need to leave the original function ALONE (reset your code if you need to) ... and create a whole new function named timesFive ... and put the code into that function that you changed for the minusSeven function ... just leave the minus7function alone ... :)
yw @anuj97
Mark Ayoub
@mk485eg
Jun 23 2016 05:19
@rickeyolsen any idea ?
bitgrower
@bitgrower
Jun 23 2016 05:19
@amilynamanilla yes hang on ...
@wangzhe4251995 Seek and Destroy is an interesting challenge and one of my favorites ... because I worked a LONG time on that one ... didin't get it, asked people for help .. .I even asked people to explain the answer when I didn't understand the answer (and they actually didn't tell me right) ... I came in here and asked them about arr & things like that and they couldn't help ... I finally figured it all out ... piece by piece ... :)
I tell you this to tell you know that the battle for understanding is often hard-fought ... but can be ultimately EXTREMELY satisfying ... :)
Amilyn
@amilynamanilla
Jun 23 2016 05:21
@bitgrower i've done up some codes.. can i PM you the code and you help me look through see where i got things wrong?
with those codes i've got 2 checks out of 5 LOL
bitgrower
@bitgrower
Jun 23 2016 05:21
nope -- sorry ... don't do pms ...
Amilyn
@amilynamanilla
Jun 23 2016 05:21
ok then shall i paste it here?
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:22
@mk485eg this is all you should need:
function timesFive(num) {
  return num*5;
}
bitgrower
@bitgrower
Jun 23 2016 05:22
yes, exactly so Amilyn
@rickeyolsen yes, good job -- keep helping him ... ;0
Amilyn
@amilynamanilla
Jun 23 2016 05:22
var firstNameInput = firstName;
var propInput = prop;
  for (var i=0; i < contacts.length; i++) {
    switch (firstNameInput) {
      case contacts[i].firstName:
        if (contacts[i].prop == propInput) {
          return contacts[i].propInput;
        }
        else return "No such property";
        break;
      default:
        return "No such contact";
    }
  }
davidrie
@davidrie
Jun 23 2016 05:23

var count = 0;

function cc(card) {
// Only change code below this line
var answer = "";
if(card == 2 ||card == 3 || card == 4 || card == 5 || card == 6){
count++;

}
else if(card == 10 ||card == 'J' || card == 'Q' || card == 'K' || card == 'A'){
count--;

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

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

Wang Zhe
@wangzheblue
Jun 23 2016 05:23
@bitgrower omg thanks haha. Can I ask if I return a false in a for loop, will the "return true" in the function after the function be executed any more?
I am also getting crazy over that lol
CamperBot
@camperbot
Jun 23 2016 05:23
wangzhe4251995 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1111 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 23 2016 05:24
a case statement ... cool, I've never seen anyone try a case statement on Profile Lookup!!! (that doesn't mean it's wrong (by any means) ...
davidrie
@davidrie
Jun 23 2016 05:24
whats the best way to upload code onto this
bitgrower
@bitgrower
Jun 23 2016 05:24
help format
CamperBot
@camperbot
Jun 23 2016 05:24

: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

bitgrower
@bitgrower
Jun 23 2016 05:24
or, the other answer is ... ask @camperbot ... the way I did ... :)
okay ... I think there are some folks here who can help other folks ... so if you can, please do! I think there's about 5 or 6 of you ... and I seem to be the only one home here ... helping one another is GREAT for your education ... trust me on that !!!
@amilynamanilla you could help @davidrie for instance ... :)
Wang Zhe
@wangzheblue
Jun 23 2016 05:26
after the for loop I mean...
davidrie
@davidrie
Jun 23 2016 05:26
@amilynamanilla how do I post code here?
hnry
@hnry
Jun 23 2016 05:26
@davidrie @bitgrower kind of answered you
read what @camperbot said
bitgrower
@bitgrower
Jun 23 2016 05:27
scroll up a bit!
Anuj Upadhyay
@anuj97
Jun 23 2016 05:27
use ```, the one below esc @davidrie
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:27
@bitgrower I'm still having trouble with this. I reset the code and edited the only two lines that should be edited..
bitgrower
@bitgrower
Jun 23 2016 05:27
@davidrie -- see where it says "multi line Code" above ?
Rickey Olsen
@rickeyolsen
Jun 23 2016 05:28
```
function nextInLine(arr, item) {
  // Your code here
  arr.push(item);
  arr.unshift();
  return item;  // Change this line
}
bitgrower
@bitgrower
Jun 23 2016 05:28
okay ... you're definitely getting closer .. and that's much improved ... did you check out what happens in pythontutor.com/javascript.html ?
hint: what you return is NOT item ... :)
CamperBot
@camperbot
Jun 23 2016 05:29
:construction: Spoilers are only in the Bonfire's Custom Room :point_right:
bitgrower
@bitgrower
Jun 23 2016 05:29
dang ... they cancelled @camperbot in the bonfire custom room months ago!!
@wangzhe4251995 -- can you post your code using the markdown formatting please ... as explained by @camperbot above ?
Beuller ?
okay all ... I'm gonna disappear like a ghost in a minute if you've all stopped talking/asking questions ... happy to answer if/when I can....
and if y'all are helping one another ... even MORE awesome !
Wang Zhe
@wangzheblue
Jun 23 2016 05:34
function destroyer(arr) {
    var newArr = arguments[0].filter(function(val){
      for (i = 1;i<arguments.length;i++){
        if (val === arguments[i]){
          return false;
        }
      }
      return true;
    }
  );
  return newArr;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Jun 23 2016 05:34
@wangzhe4251995 okay, one thing before I vanish ... it will be easier on you if you take the values in the arguments variable and put them into a local variable defined as an array ... array.filter() is also handy here ... be sure to make use of the helpful hints in the instructions ...
ahhhhh okay .. awesome ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:35
yes I finally figured out how to do markdown
Markus Kiili
@Masd925
Jun 23 2016 05:35
@wangzhe4251995 The filter callback has its own arguments object.
bitgrower
@bitgrower
Jun 23 2016 05:35
@wangzhe4251995 the arguments variable is NOT an array .. it does have some (very few) array like functions ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:35
oh ya!!!
bitgrower
@bitgrower
Jun 23 2016 05:35
here are a couple of the problems you'll run into ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:35
the filter arguments is val right?
not the ones going into destroyer
bitgrower
@bitgrower
Jun 23 2016 05:36
  1. you can't do this: arguments[0].filter
Wang Zhe
@wangzheblue
Jun 23 2016 05:36
ok
Markus Kiili
@Masd925
Jun 23 2016 05:36
@wangzhe4251995 Syntax is right but you are not accessing destroyers arguments inside callback.
bitgrower
@bitgrower
Jun 23 2016 05:36
  1. every time you create a new scope (usually what happens when you call a function) ... a new arguments object is created ... somewhat confusingly ... ALSO called arguments ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:37
@Masd925 thanks for that!
CamperBot
@camperbot
Jun 23 2016 05:37
wangzhe4251995 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1958 | @masd925 |http://www.freecodecamp.com/masd925
Wang Zhe
@wangzheblue
Jun 23 2016 05:37
@bitgrower scope?
bitgrower
@bitgrower
Jun 23 2016 05:37
scope ? you don't understand what scope is?
Wang Zhe
@wangzheblue
Jun 23 2016 05:38
@bitgrower thanks for that if you are rushing off, I am trying using the pythontutor website
CamperBot
@camperbot
Jun 23 2016 05:38
wangzhe4251995 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: wangzhe4251995 already gave bitgrower points
Wang Zhe
@wangzheblue
Jun 23 2016 05:38
I am very weak in foundation, need some time to read document
bitgrower
@bitgrower
Jun 23 2016 05:39
yeah ... that site won't quite help you as much on this one ... because you do need a little help understanding concepts ... this is a pretty concept-heavy challenge ...
you'll be able to see what's happening, but it won't tell you why ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:40
oops then it must be very helpful if I figure this challenge out?
bitgrower
@bitgrower
Jun 23 2016 05:40
anyway ... good luck!!! just reference my name and I'll see your comments when I log in next ... let me know how it goes ... :)
Wang Zhe
@wangzheblue
Jun 23 2016 05:40
np! Thanks a lot for your help!
bitgrower
@bitgrower
Jun 23 2016 05:40
like I said, it's probably my favorite challenge because I learned so much from it ...
Wang Zhe
@wangzheblue
Jun 23 2016 05:41
:smile: :smile: :smile:
bitgrower
@bitgrower
Jun 23 2016 05:41
make good use of the pages referenced in the hints in the challenge instructions ...
Markus Kiili
@Masd925
Jun 23 2016 05:43
@wangzhe4251995 To be able to use destroyers arguments inside the filter callback function, you can store arguments on a variable or pass it into the filter callback as value of this using filter syntax arr.filter(callback[, thisArg])
Wang Zhe
@wangzheblue
Jun 23 2016 05:44
@Masd925 No wonder, I did not really understand how to use "this" when I went through the lessons, thanks for the hint!
CamperBot
@camperbot
Jun 23 2016 05:44
wangzhe4251995 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: wangzhe4251995 already gave masd925 points
sherdildeveloper
@sherdildeveloper
Jun 23 2016 05:47

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

return collection;
}

please identify the mistake
Markus Kiili
@Masd925
Jun 23 2016 05:48
@sherdildeveloper Before doing collection[id][prop]=value;, you need to also check that value is not an empty string.
sherdildeveloper
@sherdildeveloper
Jun 23 2016 05:49
oh ok
thanks
Markus Kiili
@Masd925
Jun 23 2016 05:49
@sherdildeveloper This is not a proper way to test property existence if(collection[id][prop]). It is better to use .hasOwnProperty() or .propertyIsEnumerable().
Any falsy property value will fail the test.
sherdildeveloper
@sherdildeveloper
Jun 23 2016 05:50
okay thanks
anyother improvements?
Markus Kiili
@Masd925
Jun 23 2016 05:51
@sherdildeveloper It should be ok if the conditions are right.
sherdildeveloper
@sherdildeveloper
Jun 23 2016 05:51
right!
Ahmed Shaaban
@AhmedShab
Jun 23 2016 05:55
Hi everyone, I decided to move from the MEAN stack to reactjs full stack
I understand the client side of react but have't trouble building client with express using React. Can Anyone please direct me to a useful resource I can start with? Thank you, I appreciate all the support :smile:
Markus Kiili
@Masd925
Jun 23 2016 05:56
@AhmedShab Quite slow here at this hour. Try posting on the general channel https://gitter.im/FreeCodeCamp/FreeCodeCamp
Ahmed Shaaban
@AhmedShab
Jun 23 2016 05:58
@Masd925 Thanks, I appreciate it. Sorry, I live in New Zealand and it's 9 pm :P
CamperBot
@camperbot
Jun 23 2016 05:58
ahmedshab sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1959 | @masd925 |http://www.freecodecamp.com/masd925
Dan
@dcgoings
Jun 23 2016 06:03
WOOOO!!!
all done. thoughts, comments, concerns?
Jonathan Haber
@jryanhaber
Jun 23 2016 06:18
This message was deleted
This message was deleted
This message was deleted
This message was deleted
This message was deleted
also wondering how to designate all of what I am sharing as code
eeflores
@eeflores
Jun 23 2016 06:22
wiki format
CamperBot
@camperbot
Jun 23 2016 06:22

: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

Coy Sanders
@coymeetsworld
Jun 23 2016 06:23
@jryanhaber you have a space at the beginning of the string
eeflores
@eeflores
Jun 23 2016 06:23
@jryanhaber are there particular tests in the exercise that you're failing?
Coy Sanders
@coymeetsworld
Jun 23 2016 06:23
also you have quite a bit of variables you're using, you shouldn't need so many but if it works it works
eeflores
@eeflores
Jun 23 2016 06:24
yeah the space at the beginning of the string
Jonathan Haber
@jryanhaber
Jun 23 2016 06:24
This message was deleted
This message was deleted
Jonathan Haber
@jryanhaber
Jun 23 2016 06:25
This message was deleted
there that is.. .ok
eeflores
@eeflores
Jun 23 2016 06:25
@pravin07p put the hole in one test at the beginning
Jonathan Haber
@jryanhaber
Jun 23 2016 06:26
@eeflores THANK YOU!!
CamperBot
@camperbot
Jun 23 2016 06:26
jryanhaber sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 764 | @eeflores |http://www.freecodecamp.com/eeflores
Pravin
@pravin07p
Jun 23 2016 06:27
thank you @eeflores
CamperBot
@camperbot
Jun 23 2016 06:27
pravin07p sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 765 | @eeflores |http://www.freecodecamp.com/eeflores
Jonathan Haber
@jryanhaber
Jun 23 2016 06:27
@coymeetsworld - I would be very entertained to watch you refactor the code even more... would you like to show me how to eliminate some variables? ( assuming that would make it look cleaner for future employers )
Coy Sanders
@coymeetsworld
Jun 23 2016 06:28
what do you have now?
Jonathan Haber
@jryanhaber
Jun 23 2016 06:29
This message was deleted


// refactored
function titleCase(a) {
  var b, y, u, z;
  var q = "";

  b = a.toLowerCase().split(" ");
  for ( var x = 0 ; x < b.length ;  x++ ){

       y = b[x].split("");
       u = y[0].toUpperCase();
       y.splice(0,1,u).join("");
       z = y.join("");
       q = q + " " + z;

  }
         console.log(q);
         return q;


}

titleCase("I'm a little tea pot");
actually I can get rid of one... there.
eeflores
@eeflores
Jun 23 2016 06:31
@jryanhaber in your for loop, you could assign z back to the b array, then after the for loop, you could join and assign to q - this would get rid of the space at the beginning of the string
Coy Sanders
@coymeetsworld
Jun 23 2016 06:31
@jryanhaber one thing you could use would be using the Array.map function
that would replace the for loop
other things
you don't need that y variable to split b[x]
looks like you're only using it to get the capital letter for u, but you can use the charAt function to get any character from a String
Nicholas Engleman
@nicholasengleman
Jun 23 2016 06:36
Hey does anyone have a clue why this escape sequence is not working?
var myStr = "Here is a backslash: \\.\n\t\t Here is a new line with two tabs.";
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:36
hey guys, i'm on one of the intermediate algorithm challenges. The editor keeps saying i'm missing a semicolon somewhere, but I can't spot it anywhere! can anyone help me out?
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  var forRemoval = [];
  // Only change code below this line
  var keys = Object.keys(source);
  var values = Object.values(source);

  for (var i = 0; i < collection.length; i++){ // look at each object in collection
    var j = 0;
    var trueFalse = [];
    while (j < keys.length){  // checks if collection[i] contains all source's props
      var keyExists = collection[i].hasOwnProperty(keys[j]);
      trueFalse.push(keyExists);  // records the boolean values for collection[i]
      j++;
    }
    if (($.inArray(false, trueFalse)) >= -1){  // collection[i] is missing a source prop
      forRemoval.push(collections[i]);  // adds the 'incomplete' object for removal
    }
  }

  for (var k = 0; k < collection.length; k++){
    if (($.inArray(collection[k], forRemoval)) === -1){  // if object is not for removal
      arr.push(collection[k]);
    }
  }

  // Only change code above this line
  console.log(arr); // using dev tools console
  //return arr;
}
eeflores
@eeflores
Jun 23 2016 06:37
@aicccia don't put a space between \t and Here
Jonathan Haber
@jryanhaber
Jun 23 2016 06:38

// refactored
function titleCase(a) {
  var b, y, u, z;
  var q = "";

  b = a.toLowerCase().split(" ");
  for ( var x = 0 ; x < b.length ;  x++ ){

       y = b[x].split("");
       u = y[0].toUpperCase();
       y.splice(0,1,u).join("");
       z = y.join("");
       if(q == ""){ q = z ; }
       else {
       q = q + " " + z;        
       }

  }
         console.log(q);
         return q;


}
eeflores
@eeflores
Jun 23 2016 06:39
does it work?
Jonathan Haber
@jryanhaber
Jun 23 2016 06:39
Thank you guys... that fixed the space at the beginning... I will review your thoughts a bit later... I looked through them and have a mental note to check out charAt() and Array.map() further...
I was hoping to actually watch you guys refactor my code for a second, but I would rather dig into the next algorythm... had skipped that one, getting close to completion with the intermediate algorythms...
humphrey mugambi
@mugash
Jun 23 2016 06:40
Hi could someone help me with javascript on challenge 174.How can i pass an array to a function as a parameter
Jonathan Haber
@jryanhaber
Jun 23 2016 06:41
This message was deleted
This message was deleted
Nicholas Engleman
@nicholasengleman
Jun 23 2016 06:42
@eeflores No, none of the escape sequences are being recognized. The output window is not showing the string starting a new or either of the tabs.
Jonathan Haber
@jryanhaber
Jun 23 2016 06:42
thank you @coymeetsworld and @eeflores
CamperBot
@camperbot
Jun 23 2016 06:42
jryanhaber sends brownie points to @coymeetsworld and @eeflores :sparkles: :thumbsup: :sparkles:
:star2: 1187 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
:warning: jryanhaber already gave eeflores points
Coy Sanders
@coymeetsworld
Jun 23 2016 06:43
yeah keep digging @jryanhaber and going through more challenges
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:43
is anyone available to help me out a bit?
Coy Sanders
@coymeetsworld
Jun 23 2016 06:43
doesn't have to be perfect, i know alot of my early stuff wasn't good
eeflores
@eeflores
Jun 23 2016 06:45
@aicccia my solution to that problem looks almost exactly like yours, only without the space between the \t and Here
@aicccia nothing is being output to the console ... the output I'm getting is just the declaration of myStr
Jonathan Haber
@jryanhaber
Jun 23 2016 06:46
what looks better in a portfolio... should I be condensing and refactoring my code or commenting it out and including console.log()'s that show whats happening and have it make sense?
like this...
// with notes
function titleCase(str) {
  var str2, z;
  var q = "";

  console.log("1 - start with a string:" );
  str2 = str.split(" ");
  console.log("2 - split into an array:" );
  console.log("3 - for each item in the array, split into a sub-array");

  for ( var x = 0 ; x < str2.length ;  x++ ){

      var y = str2[x].split("");
      console.log("4 - capitalize the first element of each:");
      var u = y[0].toUpperCase();
      console.log("5 - replace the first cap letter in the array");
      y.splice(0,1,u);
      console.log("6 - Join each Sub Array Back together into a string:");
      z = y.join("");
      console.log("7 - push each into a return array");
      q = q + " " + z;
      console.log(q);


  }
return q;

}
or like this...


// refactored
function titleCase(a) {
  var b, y, u, z;
  var q = "";

  b = a.toLowerCase().split(" ");
  for ( var x = 0 ; x < b.length ;  x++ ){

       y = b[x].split("");
       u = y[0].toUpperCase();
       y.splice(0,1,u).join("");
       z = y.join("");
       if(q == ""){ q = z ; }
       else {
       q = q + " " + z;        
       }

  }
         console.log(q);
         return q;


}
Coy Sanders
@coymeetsworld
Jun 23 2016 06:47
you don't need to do the console.logs for documenting
Nicholas Engleman
@nicholasengleman
Jun 23 2016 06:47
@eeflores OK thanks.
CamperBot
@camperbot
Jun 23 2016 06:47
aicccia sends brownie points to @eeflores :sparkles: :thumbsup: :sparkles:
:cookie: 766 | @eeflores |http://www.freecodecamp.com/eeflores
Coy Sanders
@coymeetsworld
Jun 23 2016 06:47
if you want to document you can use comments, but for things that simple most developers will know whats going on
console.log you should just use for debugging
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:48
i'm stuck on an algorithm challenge because of a syntax error I can't find. I already posted the code above, but i'll post again because it's getting ignored. please can someone help?
function whereAreYou(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var forRemoval = [];
  var keys = Object.keys(source);
  var values = Object.values(source);

  for (var i = 0; i < collection.length; i++){ // look at each object in collection
    var j = 0;
    var trueFalse = [];
    while (j < keys.length){  // checks if collection[i] contains all source's props
      var keyExists = collection[i].hasOwnProperty(keys[j]);
      trueFalse.push(keyExists);  // records the boolean values for collection[i]
      j++;
    }
    if (($.inArray(false, trueFalse)) >= -1){  // collection[i] is missing a source prop
      forRemoval.push(collections[i]);  // adds the 'incomplete' object for removal
    }
  }

  for (var k = 0; k < collection.length; k++){
    if (($.inArray(collection[k], forRemoval)) === -1){  // if object is not for removal
      arr.push(collection[k]);
    }
  }
  console.log(arr); // using dev tools console
  // Only change code above this line
  //return arr;
}
the editor just keeps saying i'm missing a semicolon
and for the LIFE of me, i can't find it!
eeflores
@eeflores
Jun 23 2016 06:48
@jarenescueta731 missing semicolon right? I can't see anything there ... tried refreshing the browser page?
Jonathan Haber
@jryanhaber
Jun 23 2016 06:49
This message was deleted
@jarenescueta731 collections
Coy Sanders
@coymeetsworld
Jun 23 2016 06:49
yup
eeflores
@eeflores
Jun 23 2016 06:49
good spotting
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:49
im an idiot
thanks @jryanhaber
CamperBot
@camperbot
Jun 23 2016 06:50
jarenescueta731 sends brownie points to @jryanhaber :sparkles: :thumbsup: :sparkles:
:cookie: 183 | @jryanhaber |http://www.freecodecamp.com/jryanhaber
Jonathan Haber
@jryanhaber
Jun 23 2016 06:50
Thats my first points for helping out here...
feels really good...
I used http://jshint.com/ to find it
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:51
@jryanhaber you're welcome! and good to know
Jonathan Haber
@jryanhaber
Jun 23 2016 06:52
@coymeetsworld - so I can take out the console.logs()... got it...
How about the variable names... does it look more professional for them to be descriptive or a, y, z, etc
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:52
@eeflores haha when i refreshed the browser, it erased my code. good thing i still had it on the clipboard when i copied for gitter
eeflores
@eeflores
Jun 23 2016 06:52
yikes, that's not supposed to happen
Jonathan Haber
@jryanhaber
Jun 23 2016 06:52
@eeflores - I use sublime text to do all my work and then paste it in free code camp
WAY easier to be able to see what line my syntax errors are on in every page refresh...
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:53
@eeflores it had a weird popup saying the challenge couldn't be found...? anyway that was wird
....the editor is still saying i'm missing a semicolon...
eeflores
@eeflores
Jun 23 2016 06:58
@jarenescueta731 I just tried searching for that challenge - I can't find it either ..?!
Jaren Escueta
@jarenescueta731
Jun 23 2016 06:58
@eeflores "Wherefore art thou" ?
eeflores
@eeflores
Jun 23 2016 07:01
@jarenescueta731 I've copied/pasta'd your code into the challenge - I'm getting "Unexpected token {"
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:01
i smell a conspiracy
or a bug
DJ
@qualitymanifest
Jun 23 2016 07:02
@jarenescueta731 did you change the name of the function? they call it whatIsInAName stock... if you changed the name of your function the tests won't run right. thats your first issue. your second is that $.inArray is a jquery function and i don't believe that these algorithms have jquery loaded in
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:04
@qualitymanifest i noticed the function name change right when you said, and no i did not change the function name myself. which is very odd.
Pravin
@pravin07p
Jun 23 2016 07:05
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:05
@qualitymanifest second, i was able to use $.inArray for the Two Diff Arrays challenge just fine
DJ
@qualitymanifest
Jun 23 2016 07:05
@jarenescueta731 hm, okay, maybe they do have jquery loaded in, idk
Conor Thompson
@CThompson896
Jun 23 2016 07:05
Hello
I'm stuck on the 'Replacing If Else Chains with Switch' challenge and would appreciate it if someone could help me
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:06
@qualitymanifest but what's creepy is that i noticed the name change of the function even before you said so lol
Pravin
@pravin07p
Jun 23 2016 07:07
@CThompson896 are you stuck in the same thing http://awesomescreenshot.com/0b85yy7k6a
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:07
@qualitymanifest and i posted my code here using the key shortcuts without making changes
DJ
@qualitymanifest
Jun 23 2016 07:07
@jarenescueta731 i noticed it about 10 minutes ago but i misunderstood something somebody said above, and thought that you guys had already figured it out. anyway, a lot of the algorithms have had their function names changed once or twice (i think to make more sense to ESL folks), but if you just started this today or within the past couple days i would be surprised if it changed in that time span
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:08
@qualitymanifest yeah, meaning it would've changed in the space of 15 minutes
Conor Thompson
@CThompson896
Jun 23 2016 07:08
no, @pravin07p on that challenge you write the code like switch(val) {
case 1:
case 2:
case 3:
result = "1, 2, or 3";
break;
case 4:
result = "4 alone";
}
case 1, 2 and 3 all have same meaning
Pravin
@pravin07p
Jun 23 2016 07:08
Damn that was simple..Thanks a lot @CThompson896 Cheers!!
Conor Thompson
@CThompson896
Jun 23 2016 07:08
no problem
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:09
whereArtThou
CamperBot
@camperbot
Jun 23 2016 07:09
:bulb: to format code use backticks! ``` more info
Jonathan Haber
@jryanhaber
Jun 23 2016 07:09
Any thoughts? It works, but in terms of looking good to an employer? Perspectives?


function pairElement(str) {
  var array, y, z;
  var q = [];
  array = str.split("");
  for ( var i in array ){
    if( array[i] == "C" )  { y = "G" ; }  
    if( array[i] == "G" )  { y = "C" ; }  
    if( array[i] == "A" )  { y = "T" ; }  
    if( array[i] == "T" )  { y = "A" ; }  
    var r = [];
    r.push(array[i]);
    r.push(y);
    q.push(r);
  }
  return q;
}

pairElement("GCG");
Jaren Escueta
@jarenescueta731
Jun 23 2016 07:10
just testing if code formatting somehow changed the function name
Coy Sanders
@coymeetsworld
Jun 23 2016 07:13
@jryanhaber yes ideally you have more descriptive variable names
Jonathan Haber
@jryanhaber
Jun 23 2016 07:13
@coymeetsworld thanks for the guidance
CamperBot
@camperbot
Jun 23 2016 07:13
jryanhaber sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:warning: jryanhaber already gave coymeetsworld points
Coy Sanders
@coymeetsworld
Jun 23 2016 07:13
although for iterations you can use single characters like i, those are generally understood
Jonathan Haber
@jryanhaber
Jun 23 2016 07:13
of course
Coy Sanders
@coymeetsworld
Jun 23 2016 07:13
np @jryanhaber
Markus Kiili
@Masd925
Jun 23 2016 07:15
@jryanhaber Using .map() and a lookup object makes the code compact and easier to maintain (not that DNA structure would change much):
function pairElement(str){
  var pairs = {A:'T', T: 'A', C: 'G', G: 'C'};
  return Array.prototype.map.call(str, function(val){
    return [val,pairs[val]];
  });
}
Subashini
@Subakrish
Jun 23 2016 07:15
anyone help me to practice the code
devpaaji
@devpaaji
Jun 23 2016 07:32
how do i approach the random quote machine assignment
i first create array of objects
and store quotes in them
create a button in html
and empty div
that will display text
on click it should display new quote
@Masd925 when do we use .call and when not use it
here you are targeting prototype of Array
Markus Kiili
@Masd925
Jun 23 2016 07:38
@devpaaji With .call() method you can specify value for this used inside the method. That effectively sets the caller of the method. So here the method Array.prototype.map (all array methods belong to Array.prototype) is called on the passed string str. This is possible because string wrapper is an array-like object. Another way to do the same would be:
This message was deleted
function pairElement(str){
  var pairs = {A:'T', T: 'A', C: 'G', G: 'C'};
  return str.split("").map(function(val){
    return [val,pairs[val]];
  });
}
So here .call() was used only to call an array method on an array-like object. Examples of array-like objects are strings (String wrapper actually), arguments object, nodelist etc.
Jonathan Haber
@jryanhaber
Jun 23 2016 07:44
@Masd925 Thank you... any way to make that a lil bit more clear on what it is doing with more verbose variable names perhaps?
CamperBot
@camperbot
Jun 23 2016 07:44
jryanhaber sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1962 | @masd925 |http://www.freecodecamp.com/masd925
Jonathan Haber
@jryanhaber
Jun 23 2016 07:45
@Masd925 - here we go...

function pairElement(str){
  var pairsOfInitialValues = {A:'T', T: 'A', C: 'G', G: 'C'};
  return str.split("").map(function(initialValue){
    return [initialValue,pairsOfInitialValues[initialValue]];
  });
}
B
@btolor
Jun 23 2016 07:46

Hello yall.... Im having some trouble wtih the "Nesting ForLoops" challenge. Here is my code, can anyone please help me to understand what I am doing wrong. function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i= 0; i< arr.length; i ++) {
for (var j= 0; j< arr.length; j ++) {
console.log(arr[i][j]);
product= (product * [i][j]);

}

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

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

Markus Kiili
@Masd925
Jun 23 2016 07:51
@jryanhaber I think this would be better (so long names are hard to read and "initialValue" has little information on what is being done):
function pairElement(str){
  var DNApairs = {A:'T', T: 'A', C: 'G', G: 'C'};
  return str.split("").map(function(char){
    return [char,DNApairs[char]];
  });
}
Vivienne Sales
@Natto278
Jun 23 2016 07:51
@btolor The good news is that your first two lines of code are correct.
@btolor Get rid of the line of code that starts with "Console.log...."
Jonathan Haber
@jryanhaber
Jun 23 2016 07:52
This message was deleted
@Masd925 Got it... so map just iterates through an array and replace the elements with whatever the function it takes returns...
Markus Kiili
@Masd925
Jun 23 2016 07:53
@jryanhaber Yes.
Vivienne Sales
@Natto278
Jun 23 2016 07:53
@btolor The problem is with the line of code that starts with "product = ..."
Markus Kiili
@Masd925
Jun 23 2016 07:54
@jryanhaber And .filter() removes some elements, forEach just runs a function once for each element (side effects), and reduce can do anything with an array as an input. There are also many more but those are the most important ones.
Jonathan Haber
@jryanhaber
Jun 23 2016 07:54
@Masd925 brilliant... now here is an issue, I can refactor my code to improve it, but if I do so, it will be very hard to comply with the 'write your own code' mantra.. because by implementing the map() function my answer will border on plagiarism... thoughts?
Vivienne Sales
@Natto278
Jun 23 2016 07:54
@btolor Replace the equals sign with the augmented multiplication operator.
Jonathan Haber
@jryanhaber
Jun 23 2016 07:55
@Masd925 thank you again
CamperBot
@camperbot
Jun 23 2016 07:55
jryanhaber sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: jryanhaber already gave masd925 points
Markus Kiili
@Masd925
Jun 23 2016 07:55
@jryanhaber Coding is stealing, so there is no plagiarism involved.
Jonathan Haber
@jryanhaber
Jun 23 2016 07:55
@Masd925 ok, I shall get in on this asap then...
Vivienne Sales
@Natto278
Jun 23 2016 07:56
@btolor Also you need to replace the 2nd product with the word "arr" without quotes.
Vatsal Pande
@vatsalpande
Jun 23 2016 07:57
Hi All - I am stuck in this weird problem
Conor Thompson
@CThompson896
Jun 23 2016 07:57
could someone please help me with this challenge? http://www.awesomescreenshot.com/showImage?img_id=1347893
Vatsal Pande
@vatsalpande
Jun 23 2016 07:58
and as per my understanding its done and I can see it properly printing in console
not sure whats missing
Todd
@TheOnlyRealTodd
Jun 23 2016 07:58
Crap Im doing something wrong here but not sure what... Perhaps its because Im confused about the algorithm in general...

var count = 0;

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

Vatsal Pande
@vatsalpande
Jun 23 2016 07:58
can someone please help
var myStr = "Here is a backslash: \.\n\t\t Here is a new line with two tabs.";
Vivienne Sales
@Natto278
Jun 23 2016 07:58
@btolor Get rid of the mulitplication sign (*) on your last line of code that you wrote and you should be good!
B
@btolor
Jun 23 2016 08:00
@Natto278 Im lost smh.
Vivienne Sales
@Natto278
Jun 23 2016 08:00
Where are you lost @btolor
Todd
@TheOnlyRealTodd
Jun 23 2016 08:01
}

This is what I got for the card counting lesson but its not workin... Anyone know the deal with this?

```var count = 0;

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

B
@btolor
Jun 23 2016 08:06

@Natto278 Some how i ended up with this code but I have an TypeError: arr is not a function for(var i= 0; i< arr.length; i ++) {
for (var j= 0; j< arr.length; j ++) {

  product * arr([i][j]);

}

}

Vivienne Sales
@Natto278
Jun 23 2016 08:07
@btolor For the first line of code, put a space between for (...)
Stanislav Yeshenko
@syeshenko
Jun 23 2016 08:08
@vatsalpande same question ) tried different ways still doesn't work.
Jonathan Haber
@jryanhaber
Jun 23 2016 08:09
@Masd925 ok... so this answer works also... just finished it.. but I am going to try an array function on it... thinking I will try map
Vivienne Sales
@Natto278
Jun 23 2016 08:09
@btolor No, no. This is an augmented mulitplier operator ==> *=
Jonathan Haber
@jryanhaber
Jun 23 2016 08:09


function fearNotLetter(str) {
  var array, y;
  var z = [];
  for (var eachLetter in str ) { 
    var curr = str.charCodeAt(eachLetter);
    var prev;
    if( eachLetter === 0 ) { 
      prev = curr; 
    } else { 
       if ( curr - prev != 1 ) {
        return String.fromCharCode(prev + 1);    
      }
    }
  }
    return undefined;
}
Vivienne Sales
@Natto278
Jun 23 2016 08:09
@btolor Get rid if the ( ) on your line of code that starts with "product..."
B
@btolor
Jun 23 2016 08:12
@Natto278 it took the error away but the return product is null
Vivienne Sales
@Natto278
Jun 23 2016 08:15
@btolor Hhmmm. Look at the sample code given in the Nesting for Loops challenge and compare it with your code. (Hint: Your error is in your 2nd line of code.)
@btolor I did this the Nesting for Loops challenge a few weeks ago and I had the same problem you did. Post your latest code.
B
@btolor
Jun 23 2016 08:21

@Natto278 You were correct thanks for all your help. Here is the passing code for the challenge: for (var i= 0; i< arr.length; i ++) {
for (var j= 0; j< arr[i].length; j ++) {

  product *= arr[i][j];

}

}

CamperBot
@camperbot
Jun 23 2016 08:21
btolor sends brownie points to @natto278 :sparkles: :thumbsup: :sparkles:
:cookie: 248 | @natto278 |http://www.freecodecamp.com/natto278
Vivienne Sales
@Natto278
Jun 23 2016 08:22
Your welcome, @btolor! Remember to return the favor by helping other members in this group. :-)
Conor Thompson
@CThompson896
Jun 23 2016 08:23

Could someone please tell me what is wrong with this code for the 'Testing Objects for Properties' challenge? Thanks. // Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
// Your Code Here
checkObj(myObj.gift(checkProp));
checkObj(myObj.pet(checkProp));
checkObj(myObj.bed(checkProp));
checkObj(myObj.house(checkProp));
return "Change Me!";
}

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

Todd
@TheOnlyRealTodd
Jun 23 2016 08:25
Hey has anyone done the card counting challenge?? Im stuck big time. https://www.freecodecamp.com/challenges/counting-cards
Shusil Banjade
@shusil123
Jun 23 2016 08:28
@CThompson896 , you have to access the passed property by using checkProp with bracket notations , myObj[checkProp]
@TheOnlyRealTodd , you can post the code in format. That'll help
B
@btolor
Jun 23 2016 08:29
@Natto278 No Prob. Do you know of any other tutorials to that explain java script in more simpler terms? I really want to understand it.
Shusil Banjade
@shusil123
Jun 23 2016 08:30
@btolor , You can read a book 'Speaking JavaScript',
It's cool
Vivienne Sales
@Natto278
Jun 23 2016 08:30
@btolor I know a lot of FCC campers who have studied Javascript on (or have found JS better explained on ) websites such as udemy.
@shusil123 By
Conor Thompson
@CThompson896
Jun 23 2016 08:31
@shusil123 Thank you but could you please give me an example?
CamperBot
@camperbot
Jun 23 2016 08:31
cthompson896 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 514 | @shusil123 |http://www.freecodecamp.com/shusil123
Todd
@TheOnlyRealTodd
Jun 23 2016 08:31
@shusil123 ```
var count = 0;

function cc(card) {
  // Only change code below this line
  if( card >= 2 && card<=6)
    count += 1;
  if(card >= 7 && card <= 9)
    count += 0;
  else{
    switch(card){
      case 10:
        count-= 1;
        break;
      case "J":
        count-= 1;
        break;
        case "Q":
        count-= 1;
        break;
        case "K":
        count-= 1;
        break;
        case "A":
        count-= 1;
        break;
    }
  }
  if (count > 0)
    return count + "Bet";
  else
    return count + "Hold";
  // Only change code above this line
}
Vivienne Sales
@Natto278
Jun 23 2016 08:32
@shusil123 "Speaking Javascript" by Alex Rauschmayer?
Todd
@TheOnlyRealTodd
Jun 23 2016 08:32
Even if I just use ifs, which I tried, it still doesnt work like it should.
Rostyslav
@BeerDRinker
Jun 23 2016 08:33
hi
have a ptoblem
B
@btolor
Jun 23 2016 08:34
@shusil123 I get lost in some of the terminology . Is the book easy for someone with no experience to understand?
Rostyslav
@BeerDRinker
Jun 23 2016 08:34
still hard to understand
what I should to do
B
@btolor
Jun 23 2016 08:34
@Natto278 Thank You
CamperBot
@camperbot
Jun 23 2016 08:34
btolor sends brownie points to @natto278 :sparkles: :thumbsup: :sparkles:
:warning: btolor already gave natto278 points
Rostyslav
@BeerDRinker
Jun 23 2016 08:36

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

return item; // Change this line
}

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

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

Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
please help
kirbyedy
@kirbyedy
Jun 23 2016 08:36
@BeerDRinker try to use push() and shift() methods
Rostyslav
@BeerDRinker
Jun 23 2016 08:36
ok
kirbyedy
@kirbyedy
Jun 23 2016 08:37
so you have to push your item into the array, and then shift the element from it
Shusil Banjade
@shusil123
Jun 23 2016 08:37
@TheOnlyRealTodd , use if, else if, else if form. and put curly braces for the execution statements, like if(....) {} else if (.....) {}
@btolor , yes, It's easy to understand.
B
@btolor
Jun 23 2016 08:38
@shusil123 ok Thanks
CamperBot
@camperbot
Jun 23 2016 08:38
btolor sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 515 | @shusil123 |http://www.freecodecamp.com/shusil123
hnry
@hnry
Jun 23 2016 08:38
@TheOnlyRealTodd return count + " Hold"; return count + " Bet";
note the space in between " and H and " and B
Todd
@TheOnlyRealTodd
Jun 23 2016 08:41
@hnry zomg thx I love you
CamperBot
@camperbot
Jun 23 2016 08:41
theonlyrealtodd sends brownie points to @hnry :sparkles: :thumbsup: :sparkles:
:cookie: 317 | @hnry |http://www.freecodecamp.com/hnry
Todd
@TheOnlyRealTodd
Jun 23 2016 08:41
I was working on that for like 30 mins and failed to notice that. LOL.
Bubicica
@Bubicica
Jun 23 2016 08:41
hey guys, I'm having problems understanding instructions for one the JS challenges
hnry
@hnry
Jun 23 2016 08:41
:P
Todd
@TheOnlyRealTodd
Jun 23 2016 08:41
@shusil123 thank you too because I ended up entering just ifs for my solution so it was probably a combo of the two. But I definitely forgot those spaces
CamperBot
@camperbot
Jun 23 2016 08:41
theonlyrealtodd sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 516 | @shusil123 |http://www.freecodecamp.com/shusil123
Bubicica
@Bubicica
Jun 23 2016 08:42

To be exact:

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

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

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

Todd
@TheOnlyRealTodd
Jun 23 2016 08:43
@hnry this is what happens when youre used to using Visual Studio and the IDE does everything for you and you get spoiled.. You start neglecting to pay attention to detail lol!
Bubicica
@Bubicica
Jun 23 2016 08:43
not sure if that means prop != "tracks" or id.prop.hasOwnProperty("tracks")
Rostyslav
@BeerDRinker
Jun 23 2016 08:43
still can not to done this lesson
Shusil Banjade
@shusil123
Jun 23 2016 08:44
@BeerDRinker , What challenge ?
Markus Kiili
@Masd925
Jun 23 2016 08:44
@Bubicica If prop==="tracks" you have to make a .hasOwnProperty() check on collection[id]
Rostyslav
@BeerDRinker
Jun 23 2016 08:44
184
kirbyedy
@kirbyedy
Jun 23 2016 08:44
did you read the documentation on push() and shift() methods ? @BeerDRinker
Rostyslav
@BeerDRinker
Jun 23 2016 08:45
yes
kirbyedy
@kirbyedy
Jun 23 2016 08:45
ok, so how does push works ?
Bubicica
@Bubicica
Jun 23 2016 08:46
@Masd925 Ah I see, but Istill don't getthis one: If prop does not contain the key "tracks" before you update it, create an empty array before pushing a track to it.
Todd
@TheOnlyRealTodd
Jun 23 2016 08:46
Push adds whatever you enter into the parentheses to the end of the array as an item
@kirbyedy
Rostyslav
@BeerDRinker
Jun 23 2016 08:47
inserts in array value
Markus Kiili
@Masd925
Jun 23 2016 08:47
@Bubicica If prop is tracks and hasOwnProperty tells that tracks property is absent, you can assign [value].
kirbyedy
@kirbyedy
Jun 23 2016 08:47
there you go, so if you push your item into an array, you are almost there
Markus Kiili
@Masd925
Jun 23 2016 08:47
or assign [ ] and push(value).
Todd
@TheOnlyRealTodd
Jun 23 2016 08:47
@kirbyedy if you have myArray = [5, 4, 3] and then you do myArray.push(2), now myArray is [5, 4, 3, 2]
Rostyslav
@BeerDRinker
Jun 23 2016 08:48
yes. I understend this
kirbyedy
@kirbyedy
Jun 23 2016 08:48
@TheOnlyRealTodd I dont know why are you referring to me, I am trying to help @BeerDRinker
Bubicica
@Bubicica
Jun 23 2016 08:48
@Masd925 Hm but shouldn't it say then "If prop does contain" instead of "If prop does not contain"?
kirbyedy
@kirbyedy
Jun 23 2016 08:48
@BeerDRinker ok, so try now to write the code which pushes your element to your array
Todd
@TheOnlyRealTodd
Jun 23 2016 08:49
@kirbyedy my mistake, got mixed up. Must be bed time soon lol
Markus Kiili
@Masd925
Jun 23 2016 08:50
@Bubicica It should say, if the record does not contain key "tracks" you should assign a new array to property key "tracks"
Bubicica
@Bubicica
Jun 23 2016 08:50
ah okay
I get it now
@Masd925 thanks
CamperBot
@camperbot
Jun 23 2016 08:50
bubicica sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1963 | @masd925 |http://www.freecodecamp.com/masd925
Conor Thompson
@CThompson896
Jun 23 2016 08:51
Has anyone done the 'Testing Objects for Properties' challenge? smh
kirbyedy
@kirbyedy
Jun 23 2016 08:51
most probably yes
Krishna Sai Gullapalli
@Krish2704
Jun 23 2016 08:54
@CThompson896 what's your issue?
Conor Thompson
@CThompson896
Jun 23 2016 08:55

I'm trying

function checkObj(checkProp) {
// Your Code Here
myObj.checkObj("gift");
myObj.checkObj("pet");
myObj.checkObj("kitten");
myObj.checkObj("bed");

return "Not Found";
}
but I can't see any other way of doing this

Markus Kiili
@Masd925
Jun 23 2016 08:56
@CThompson896 You should use .hasOwnProperty() method to test existence of property key stored in checkProp parameter.
Then access the object with property key using syntax obj[key]and return property value.
Conor Thompson
@CThompson896
Jun 23 2016 08:57
could you please give me an example of how I would do this?
trying myObj.hasOwnProperty("gift"); but does not work
Markus Kiili
@Masd925
Jun 23 2016 08:59
@CThompson896 myObj.hasOwnProperty("cat") would return a boolean indicating if myObj has a property key "cat". Here you have to use checkProp as the key, because it holds the key string passed into the function when it is invoked.
frantech
@toutli
Jun 23 2016 09:00
Hi all, how are you
I am stuck
I am trying to write a backslash in js
but I only get errors
anyone can advice?
Todd
@TheOnlyRealTodd
Jun 23 2016 09:01
@toutli you need to do \
double backslash to escape
frantech
@toutli
Jun 23 2016 09:02
so in total 3 \
Conor Thompson
@CThompson896
Jun 23 2016 09:02
@Masd925 Thanks but could you please write an example answer?
CamperBot
@camperbot
Jun 23 2016 09:02
cthompson896 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1964 | @masd925 |http://www.freecodecamp.com/masd925
frantech
@toutli
Jun 23 2016 09:03
@TheOnlyRealTodd it is not working
Dany Din
@danydin
Jun 23 2016 09:03
hey, i've a general question, why do we need to learn those alogrithams and so on in js .. where/when we can apply it on? thanks.
frantech
@toutli
Jun 23 2016 09:03
tried everything: 3 \ or 4\ or just 1\
with or without quotes
Todd
@TheOnlyRealTodd
Jun 23 2016 09:03
@toutli did you try 2?
Markus Kiili
@Masd925
Jun 23 2016 09:03
@CThompson896 Make an if that tests if myObj has the property key stored in checkProp. Use the syntax I posted above. Post your code here after you do that.
frantech
@toutli
Jun 23 2016 09:03
yep @TheOnlyRealTodd
I am with the exercise "escape sequences in strings"
and have 3 red crosses
Rostyslav
@BeerDRinker
Jun 23 2016 09:04
sorry, have a conecction problem
frantech
@toutli
Jun 23 2016 09:04
the first and last are crossed red
Markus Kiili
@Masd925
Jun 23 2016 09:04
@toutli console.log("\\"); // prints: \
So backslash inside a string is denoted with "\ \"
Todd
@TheOnlyRealTodd
Jun 23 2016 09:05
Yeah you should only need 2
are you not inside a string @toutli ?
frantech
@toutli
Jun 23 2016 09:06
yes tried that too: unexpected error
Markus Kiili
@Masd925
Jun 23 2016 09:06
@toutli There is some other problem then.
Conor Thompson
@CThompson896
Jun 23 2016 09:06

@Masd925
function checkObj(checkProp) {
// Your Code Here
if(myObj.hasOwnProperty) {
checkObj("gift");
checkObj("pet");
checkObj("bed");
checkObj("house");
}

return "Not Found";
}
Is this correct?

frantech
@toutli
Jun 23 2016 09:06
right: so where is the error?
can't figure it out
Todd
@TheOnlyRealTodd
Jun 23 2016 09:07
@toutli paste the code in here
frantech
@toutli
Jun 23 2016 09:07
is there anywhere i can send this?
ok
Todd
@TheOnlyRealTodd
Jun 23 2016 09:07
Use the code format
frantech
@toutli
Jun 23 2016 09:07
so how was it? 3enters or something?
hold on
Todd
@TheOnlyRealTodd
Jun 23 2016 09:07
its ```
Markus Kiili
@Masd925
Jun 23 2016 09:07
@CThompson896 Remove those four lines inside if block, and put an argument (checkProp) after the hasOwnProperty.
kirbyedy
@kirbyedy
Jun 23 2016 09:07
help format
CamperBot
@camperbot
Jun 23 2016 09:07

: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

I have tried everything but still cant figure it out
kirbyedy
@kirbyedy
Jun 23 2016 09:08
@Ash0907 what you have until now
paste it here
Ash0907
@Ash0907
Jun 23 2016 09:09
var myStr = "Here is a backslash: \. \n \t \t Here is a new line with two tabs.";
Conor Thompson
@CThompson896
Jun 23 2016 09:09

@Masd925
if(myObj.hasOwnProperty(checkProp)) {

}
like this? it still does not work

Wang Zhe
@wangzheblue
Jun 23 2016 09:09
@Masd925 Hi thank you for your help on Seek and Destroy just now:) I have another problem on Caesars Cipher now, do you have any idea what \u0013 is? I got this among the array of characters instead of regular spaces.
CamperBot
@camperbot
Jun 23 2016 09:09
wangzhe4251995 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1965 | @masd925 |http://www.freecodecamp.com/masd925
Ash0907
@Ash0907
Jun 23 2016 09:09
thats what I have till now
but the console wont accept it
frantech
@toutli
Jun 23 2016 09:10
This message was deleted
Markus Kiili
@Masd925
Jun 23 2016 09:10
@CThompson896 Then inside if block access the property value with syntax obj[key] and return it (now that you have checked that the property exists).
Vatsal Pande
@vatsalpande
Jun 23 2016 09:11
@syeshenko true. I have also tried it in multiple ways..even console logs works fine. Your solution is also the same?
frantech
@toutli
Jun 23 2016 09:11
This message was deleted
guiguivey
@guiguivey
Jun 23 2016 09:12

Hi everyone, I'm stuck at the course n°152 :
<
// Setup
var myStr = "Jello World";

// Only change code below this line

myStr[0] = "H"; // Fix Me
>

I've tried to turn the "H" into a "J", but it didn't work. I tried to change myStr = "Hello World";, but it didn't work neither. I've been stuck since yesterday, so I'm asking your help.
Thank you all in advance.

CamperBot
@camperbot
Jun 23 2016 09:12

welcome to FreeCodeCamp @guiguivey!

Ash0907
@Ash0907
Jun 23 2016 09:12
any help?
frantech
@toutli
Jun 23 2016 09:12
@Ash0907 have the same problem here...
kirbyedy
@kirbyedy
Jun 23 2016 09:12
@Ash0907 yea, I dont think you understood the question
frantech
@toutli
Jun 23 2016 09:12
trying now to use the code formatting
Markus Kiili
@Masd925
Jun 23 2016 09:12
@guiguivey Strings are immutable, so you need to make a new string and assign it back to same variable.
kirbyedy
@kirbyedy
Jun 23 2016 09:12
there are two sentences there
Markus Kiili
@Masd925
Jun 23 2016 09:13
@guiguivey There are no problem numbers, only names.
frantech
@toutli
Jun 23 2016 09:13
really don't understand this: i have sent before with success
kirbyedy
@kirbyedy