These are chat archives for FreeCodeCamp/HelpJavaScript

2nd
Jun 2016
Joseph
@revisualize
Jun 02 2016 00:00
Let me know what you find.
hjernefrys
@hjernefrys
Jun 02 2016 00:01
I need some help with Where art thou, it has been driving me nuts, but I think I make it too complicated. What I have so far:

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


  for(var x = 0; x < collection.length; x++){
    console.log(collection[x]);
    console.log(source);
    var keys = Object.keys(source);
    //console.log(source.hasOwnProperty(collection[x])); 

    for(var i = 0; i < keys.length; i++){
      var mykey = keys[i];
      console.log(collection[x].hasOwnProperty(source[mykey]));
    }
  }

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

whereAreYou([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Coy Sanders
@coymeetsworld
Jun 02 2016 00:01
@asma8867 you can only determine no contact exists with the firstname you're looking for if you've checked all objects in the array first
also think your nested if statements aren't right
double check where your brackets are all at
Joseph
@revisualize
Jun 02 2016 00:04
Thanks @coymeetsworld
CamperBot
@camperbot
Jun 02 2016 00:04
revisualize sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1010 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 02 2016 00:04
figured that would hard for you to read on the phone :)
Joseph
@revisualize
Jun 02 2016 00:04
:D
Coy Sanders
@coymeetsworld
Jun 02 2016 00:04
hey look I have 10 brownie points
in binary
Joseph
@revisualize
Jun 02 2016 00:05
Dork.
:heart:
Coy Sanders
@coymeetsworld
Jun 02 2016 00:06
:)
Joseph
@revisualize
Jun 02 2016 00:06
:P
Coy Sanders
@coymeetsworld
Jun 02 2016 00:06
if i was a dork i'd point out it its 4112 in hex
Asma
@asma8867
Jun 02 2016 00:09
@coymeetsworld sorry could you please give me more direct hint?
Coy Sanders
@coymeetsworld
Jun 02 2016 00:09
with the way your code is setup @asma8867, you're only checking the first contact to see if the name matches
then if you don't find it you're returning No Such Contact
but you're doing that before you check the entire array
so no matter what happens you're only checking the first contact
Xavier Velez
@JonSnow08
Jun 02 2016 00:10
I'm completely lost on the Falsy Bouncer bonfire...anybody got an idea that can help but not give me the answer?
Coy Sanders
@coymeetsworld
Jun 02 2016 00:11
what do you have so far @JonSnow08 ?
Xavier Velez
@JonSnow08
Jun 02 2016 00:12
i think what i've written is pointless but ill post it lol

function bouncer(arr) {
  // Don't show a false ID to this bouncer.
  var a = Boolean(false);
  var b = Boolean(null);
  var c = Boolean (0);
  var d = Boolean("");
  var e = Boolean(undefined);
  var f = Boolean(NaN);

  arr.filter(function(a {} ))
  return arr;
}

bouncer([7, "ate", "", false, 9]);
Coy Sanders
@coymeetsworld
Jun 02 2016 00:13
hmm well your filter function has some problems for one
arr.filter(function(item) {
   return true;
});
that would be the syntax for an array that doesn't filter anything
Michael
@michaeldiegogil
Jun 02 2016 00:15
Anybody got help for me on these switch statements? I cant seem to understand.
``j
``javascript
Coy Sanders
@coymeetsworld
Jun 02 2016 00:15
or you could just call another function:
function someFunction(item) {
  return true;
}

arr.filter(someFunction);
Michael
@michaeldiegogil
Jun 02 2016 00:16

``javascript

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

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

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

Coy Sanders
@coymeetsworld
Jun 02 2016 00:16
the first example is just using an anonymous function, since it has no name.
Michael
@michaeldiegogil
Jun 02 2016 00:16
?
Christinazheng1
@Christinazheng1
Jun 02 2016 00:16
can i get help "constructing strings with variable" challenge.
Michael
@michaeldiegogil
Jun 02 2016 00:16
dammit how do i post my code on here again
Coy Sanders
@coymeetsworld
Jun 02 2016 00:16
@michaeldiegogil you got your variables mixed
you should be switching on val, not on 1
1 is one of your cases
Nick LaBelle
@dogwaddle
Jun 02 2016 00:17
I'm havin trouble with the Steamroller challenge. I somewhat understand how to solve it, meaning you have to do it recursively. But I'm having a hard time implementing it. Anyone know of a good resource that explains writing recursive functions well?
Xavier Velez
@JonSnow08
Jun 02 2016 00:17
@michaeldiegogil three '```js'
Coy Sanders
@coymeetsworld
Jun 02 2016 00:17
help format
CamperBot
@camperbot
Jun 02 2016 00:17
no wiki entry for: format
Xavier Velez
@JonSnow08
Jun 02 2016 00:17
shift enter
Coy Sanders
@coymeetsworld
Jun 02 2016 00:17
wiki format
CamperBot
@camperbot
Jun 02 2016 00:17

: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

Michael
@michaeldiegogil
Jun 02 2016 00:18
function caseInSwitch(val) {
  var answer = "";
  // Only change code below this line
 switch (val) {
  case 1:
    console.log("alpha");
    break;
  }


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

// Change this value to test
caseInSwitch(1);
Diego Mayer
@Chrono79
Jun 02 2016 00:18
@michaeldiegogil you should use answer not console.log
Coy Sanders
@coymeetsworld
Jun 02 2016 00:19
@Christinazheng1 what do you need help with?
Michael
@michaeldiegogil
Jun 02 2016 00:20
it just says "answer is not a function"
Diego Mayer
@Chrono79
Jun 02 2016 00:20
@michaeldiegogil i didn't mean use it like a function, use it as a var
like answer = ...
Michael
@michaeldiegogil
Jun 02 2016 00:21
Holy smokes man!!! @Chrono79 You're the best
Xavier Velez
@JonSnow08
Jun 02 2016 00:22
@coymeetsworld i'm still lost for some reason, I have no idea why I would call a function inside of the function or why the return true is there
Coy Sanders
@coymeetsworld
Jun 02 2016 00:22
return true needs to be replaced @JonSnow08, im just pointing out that the function needs to return a true or false value
Xavier Velez
@JonSnow08
Jun 02 2016 00:22
ah ok
i think i may have it
Coy Sanders
@coymeetsworld
Jun 02 2016 00:22
when you use Array.filter, the function you pass in needs to return true or false statements
Xavier Velez
@JonSnow08
Jun 02 2016 00:22
just to see if im on the right track
Coy Sanders
@coymeetsworld
Jun 02 2016 00:23
filter goes through the entire array and runs that function, if the function evaluates to true that item will be part of the new array.
If its false it gets removed
if you look at the MDN documentation it has a pretty good example on it https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
with the isBigEnough function as the callback
Xavier Velez
@JonSnow08
Jun 02 2016 00:24
so i can do an if statement that checks through the array, for example if (arr[0] === false){return true;}
or well return false because i want it removed
Coy Sanders
@coymeetsworld
Jun 02 2016 00:25
right
Xavier Velez
@JonSnow08
Jun 02 2016 00:26
awesome ok let me see where I get
@coymeetsworld thank you
CamperBot
@camperbot
Jun 02 2016 00:26
jonsnow08 sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1011 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 02 2016 00:27
np @JonSnow08
Chris
@email362
Jun 02 2016 00:27
\j

\j

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

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

}
// Only change code above this line
}

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

waoh sorry guys
im trying to make it it look like code
how do i do that?
Coy Sanders
@coymeetsworld
Jun 02 2016 00:28
help format
CamperBot
@camperbot
Jun 02 2016 00:28

: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 02 2016 00:28
wiki format
CamperBot
@camperbot
Jun 02 2016 00:28

: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

Josh
@joshweaver23
Jun 02 2016 00:28
back tics
Chris
@email362
Jun 02 2016 00:30

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


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

  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
ok so im stuck
the function wont go through every contact
it only works on the first two
if anyone could help that would be great
Diego Mayer
@Chrono79
Jun 02 2016 00:31
@email362 return no such contact outside the loop, you have to check all the contacts before you can say that
the if condition of no such property is also wrong
Coy Sanders
@coymeetsworld
Jun 02 2016 00:31
@email362 yes with your if statements like that you'll only ever go through the first contact, never the 2nd or later
either the firstName matches or it doesn't, either way you're returning something
Chris
@email362
Jun 02 2016 00:32
sorry im still having a hard time wrapping my head around that.
Diego Mayer
@Chrono79
Jun 02 2016 00:33
@email362 try dividing your first if in 2 nested ifs
Chris
@email362
Jun 02 2016 00:33
wont the if statement not work outside of the for loop because it uses local varialbles?
variables
Diego Mayer
@Chrono79
Jun 02 2016 00:33
@email362 they are local in your function, outside the loop is still inside your function scope
Chris
@email362
Jun 02 2016 00:34
@Chrono79 ohhh, i thought it was only local to the loop. ok
thanks
Diego Mayer
@Chrono79
Jun 02 2016 00:35
@email362 you don't need an if outside your loop, if it reaches that line it's because neither of the other 2 returns have triggered
Coy Sanders
@coymeetsworld
Jun 02 2016 00:35
you don't need the variables outside of the loop
Xavier Velez
@JonSnow08
Jun 02 2016 00:36

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  function checkArr (word){
    if (word === 0 || word === false|| word === null || word === "" || word === undefined || word === isNaN){

          return false;
    } else{
      return true; 
    }
  } 

  for(var i = 0; i < arr.length; i++){
  arr.filter(checkArr(arr[i]));

  }


}

bouncer([7, "ate", "", false, 9]);
this is what I have so far
Diego Mayer
@Chrono79
Jun 02 2016 00:36
@JonSnow08 word === isNaN isn't right
Xavier Velez
@JonSnow08
Jun 02 2016 00:37
@Chrono79 it told me to use isNaN when comparing NaN
Diego Mayer
@Chrono79
Jun 02 2016 00:37
@JonSnow08 isNaN is a function
Xavier Velez
@JonSnow08
Jun 02 2016 00:37
do i removed the === then?
Diego Mayer
@Chrono79
Jun 02 2016 00:38
@JonSnow08 use word != word
Xavier Velez
@JonSnow08
Jun 02 2016 00:38
okay I did but can you explain why?
sorry I like to understand the code that way I don't get stuck later
Diego Mayer
@Chrono79
Jun 02 2016 00:39
isNaN([1,2]) is true, amongst a lot of other things
Coy Sanders
@coymeetsworld
Jun 02 2016 00:39
you cant use either equals operators to evaluate NaN
Jake Caswell
@jakefromstatefarm512
Jun 02 2016 00:39
can someone give me the code to this lesson Word Blanks
Xavier Velez
@JonSnow08
Jun 02 2016 00:41
okay I've changed that the console log is telling me true is not a function
bitgrower
@bitgrower
Jun 02 2016 00:41
@jakefromstatefarm512 -- mock horror you want someone to GIVE YOU THE CODE ?
Diego Mayer
@Chrono79
Jun 02 2016 00:41
no, but you can show what you have and we can guide you from there @jakefromstatefarm512
Xavier Velez
@JonSnow08
Jun 02 2016 00:42
@jakefromstatefarm512 you'll regret it later when you do that, then you don't learn from it. Worst case I can help you work through the logic...but it's best when you understand what is happening or you'll get stuck exponentially as time goes on
Diego Mayer
@Chrono79
Jun 02 2016 00:42
@JonSnow08 you don't need the loop
bitgrower
@bitgrower
Jun 02 2016 00:43
understanding what's needed in Word Blanks seems to be the big stumbling block ... as is being a non-native speaker of English in understanding it -- since it talks about the names of the parts of speech ... which may be confusing ... I know a LOT of folks have trouble with it -- even I, a native speaker, had trouble quite understanding what was wanted ...
@JonSnow08 - can you post your current code ?
Xavier Velez
@JonSnow08
Jun 02 2016 00:43
sure

function bouncer(arr) {
  // Don't show a false ID to this bouncer.

  function checkArr (word){
    if (word === 0 || word === false|| word === null || word === "" || word === undefined || word != word){

          return false;
    } else{
      return true; 
    }
  } 


  arr.filter(checkArr(arr));




}

bouncer([7, "ate", "", false, 9]);
Diego Mayer
@Chrono79
Jun 02 2016 00:44
word blanks, you should read mad libs and review this challenge: https://www.freecodecamp.com/challenges/constructing-strings-with-variables
@JonSnow08 you have to return arr.filter, and the call to the filter function goes without params, just the function name
Xavier Velez
@JonSnow08
Jun 02 2016 00:45
@Chrono79 how will it get to my checkArr function if I don't call it then?
haha just when I think i'm getting somewhere i'm even more lost now
Diego Mayer
@Chrono79
Jun 02 2016 00:46
@JonSnow08 did I say you don't have to call it? checkArr IS your filter function, the other filter is a method
Xavier Velez
@JonSnow08
Jun 02 2016 00:47
no but you said without params
bitgrower
@bitgrower
Jun 02 2016 00:47
@JonSnow08 -- I spent HOURS on bouncer -- and then I read the page on false values recommended in the challenge ... and solved in it about 5 minutes ... (yes, I'm saying there might be a "trick" -- although you will learn quite a bit doing what I did -- as I know I learned a lot ... but it was a bit painful ...
Xavier Velez
@JonSnow08
Jun 02 2016 00:48
@bitgrower the boolean objects page?
Diego Mayer
@Chrono79
Jun 02 2016 00:48
try to call checkArr without params (even without parentheses)
Blair Yacishyn
@YacYac
Jun 02 2016 00:48
I'm doing "Make A Person" and can't get the instanceof bob to return true.
function Person(firstAndLast) {
  var nameArr = firstAndLast.split(' ');
  this.firstName = nameArr[0];
  this.lastName = nameArr[1];
  this.fullName = firstAndLast;

  return function() {
    getFirstName: function () {

    },
    getLastName: function () {

    },
    getFullName: function() {

    },
    setFirstName: function(first) {

    },
    setLastName: function(last) {

    },
    setFullName: function(firstAndLast) {

    }
  };
}

var bob = new Person('Bob Ross');
console.log(Object.keys(bob).length);
console.log(bob instanceof Person);
Xavier Velez
@JonSnow08
Jun 02 2016 00:49
@Chrono79 thank you @bitgrower thank you as well
CamperBot
@camperbot
Jun 02 2016 00:49
jonsnow08 sends brownie points to @chrono79 and @bitgrower :sparkles: :thumbsup: :sparkles:
:cookie: 994 | @chrono79 |http://www.freecodecamp.com/chrono79
:star2: 1074 | @bitgrower |http://www.freecodecamp.com/bitgrower
Diego Mayer
@Chrono79
Jun 02 2016 00:49
@YacYac all your methods are empty, no surprise it doesn't work
bitgrower
@bitgrower
Jun 02 2016 00:49
@JonSnow08 -- yep, that's the one
Xavier Velez
@JonSnow08
Jun 02 2016 00:50
@bitgrower i'll go read it now so I have a solid footing although I passed the bonfire
Josh
@joshweaver23
Jun 02 2016 00:50
var symDiff = args.reduce(function(a, b) {
    a.map(function(e) {
      if (b.indexOf(e) >= 0) {
        console.log(e);
        return e;
      }
    });
  });
I keep getting "a.map is not a function" but cannot quite figure out what the issue is.
are prototype functions not nestable?
does the product of array.map need to be set to a var?
Diego Mayer
@Chrono79
Jun 02 2016 00:51
@joshweaver23 are you sure a is an array?
Josh
@joshweaver23
Jun 02 2016 00:52
pretty sure...
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 00:52
can anyone tell me how to Generate Random Fractions with JavaScript
Diego Mayer
@Chrono79
Jun 02 2016 00:52
paste your full code
Josh
@joshweaver23
Jun 02 2016 00:52
function sym(args) {

  var symDiff = args.reduce(function(a, b) {
    a.map(function(e) {
      if (b.indexOf(e) >= 0) {
        console.log(e);
        return e;
      }
    });
  });

  return symDiff;
}

sym([1, 2, 3], [5, 2, 1, 4]);
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 00:53

this is my code
function randomFraction() {

// Only change code below this line.
var x;
Math.floor(Math.random()*x);
return 0;

// Only change code above this line.
}

Josh
@joshweaver23
Jun 02 2016 00:53
every example is an array
Blair Yacishyn
@YacYac
Jun 02 2016 00:53
@Chrono79 sorry, I've been fiddling. it still fails with the methods filled in. IE:
function Person(firstAndLast) {
  var nameArr = firstAndLast.split(' ');
  this.firstName = nameArr[0];
  this.lastName = nameArr[1];
  this.fullName = firstAndLast;

  return {
    getFirstName: function () {
      return firstName;
    },
    getLastName: function () {
      return lastName;
    },
    getFullName: function() {
      return fullName;
    },
    setFirstName: function(first) {
      firstName = first;
    },
    setLastName: function(last) {
      lastName = last;
    },
    setFullName: function(firstAndLast) {
      fullName = firstAndLast;
    }
  };
}

var bob = new Person('Bob Ross');
Diego Mayer
@Chrono79
Jun 02 2016 00:53
@joshweaver23 args isn't an array, is it?
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 00:53
I am getting error The number returned by randomFraction should be a decimal.
bitgrower
@bitgrower
Jun 02 2016 00:54
by the time you to this challenge (I think, there are 2 similar challenges) ... you should understand the arguments object ... the lack of use of the AO in your code is tripping you up @joshweaver23
Diego Mayer
@Chrono79
Jun 02 2016 00:54
@Santosh456 you have to return Math.random()
Josh
@joshweaver23
Jun 02 2016 00:54
@Chrono79 oh crap, i didn't realize it was actually dealing with arguments object... i didn't really pay attn to that
nevermind
Diego Mayer
@Chrono79
Jun 02 2016 00:56
@YacYac that return { isn't right, you have to make 6 public methods
bitgrower
@bitgrower
Jun 02 2016 00:56

bitgrower's valuable programming tips:

  1. be sure you know and identify what you are being given...
  2. be sure you know and identify what it expected of you (what you need to return)...

Do this upfront, and it will save you a lot of time, grief, heartache, etc ...

(For instance, many folks come in here and don't recognize what the data structure is they are being handed in Profile Lookup -- they go straight for object property access, when they need to use array indexing first ... :)

mcorby17
@mcorby17
Jun 02 2016 00:56
Does any one know how I can pass more than one argument to a filter? Kinda like this...
function equal(val, arg){
  return val === arg;
}
document.write([1,2,3,2,1].filter(equal,2))
Diego Mayer
@Chrono79
Jun 02 2016 00:57

@YacYac
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
setFullName(firstAndLast)
instead of using more vars, use nameArr in these methods:

    getFirstName: function () {
      return firstName;
    },
    getLastName: function () {
      return lastName;
    },
    getFullName: function() {
      return fullName;
    },

and make them public, not private (my bad)

mcorby17
@mcorby17
Jun 02 2016 00:57
I want to be able to choose what value i'm filtering out
Moisés Man
@moigithub
Jun 02 2016 00:58
var arg = 2;
function equal(val){
  return val === arg;
}
document.write([1,2,3,2,1].filter(equal))
@mcorby17
mcorby17
@mcorby17
Jun 02 2016 00:58
@moigithub Ohh ok I think I can make this work
Thanks!
Jake Caswell
@jakefromstatefarm512
Jun 02 2016 00:59
is this corect
// Example
var ourArray = [1,2,3];
ourArray[1] = 3; // ourArray now equals [1,3,3].

// Setup
var myArray = [1,2,3];

// Only change code below this line.
var myArray = [3,3,3];
myArray[1] = 2;
bitgrower
@bitgrower
Jun 02 2016 01:00
does it pass all the tests ?
Moisés Man
@moigithub
Jun 02 2016 01:00
@jakefromstatefarm512 var myArray = [1,2,3]; is already provided
u dont need to create another one
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 01:00

function randomFraction() {

// Only change code below this line.
Math.random();
return 0;

// Only change code above this line.
}

bitgrower
@bitgrower
Jun 02 2016 01:00
good point, @moigithub
Moisés Man
@moigithub
Jun 02 2016 01:01
:D
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 01:01
my error is The number returned by randomFraction should be a decimal.
Moisés Man
@moigithub
Jun 02 2016 01:01
@Santosh456 u need to return a random number
put ur 2 lines in 1
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 01:01
what should i do into my code
how
Blair Yacishyn
@YacYac
Jun 02 2016 01:02
@Chrono79 I tried setting them as private functions, but then the key length returns as 3, when it needs to be 6
Moisés Man
@moigithub
Jun 02 2016 01:02
return (a random number) ??
Diego Mayer
@Chrono79
Jun 02 2016 01:02
@Santosh456 return 0; does exactly that
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 01:03
no
Moisés Man
@moigithub
Jun 02 2016 01:03
what instruction/command generates a random number ?
Diego Mayer
@Chrono79
Jun 02 2016 01:03
@YacYac see above, I was mistaken, they should be public
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 01:05
can u tell me exactly what should i write there
I am trying but its not coming
DoctorSmiles
@DoctorSmiles
Jun 02 2016 01:06
Having some issues with the "Slasher Flick" challenge. What I've got seems to fail when it reaches elements that contain strings.
function slasher(arr, howMany) {
  // it doesn't always pay to be first
  if (howMany === 0) {
    return arr;
  } else if (howMany > 0) {
      for (i = 0; i < howMany; i++) {
     arr2 = arr.splice(i, 1);
  }
  }
  return arr2;
}

slasher(["burgers", "fries", "shake"], 1);
Diego Mayer
@Chrono79
Jun 02 2016 01:09
@DoctorSmiles The head means the beginning of the array, or the zeroth index. Why using a for loop?
DoctorSmiles
@DoctorSmiles
Jun 02 2016 01:10
... I don't know.
It seemed like it made sense at the time?
Diego Mayer
@Chrono79
Jun 02 2016 01:11
refactor
DoctorSmiles
@DoctorSmiles
Jun 02 2016 01:11
Refactor?
Michael
@michaeldiegogil
Jun 02 2016 01:11
// Setup
function abTest(a, b) {
  // Only change code below this line

  console.log(a, b < 0);
  return ;



  // 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);
cant seem to get this right
"Return Early Pattern for Functions"
can someone help
Diego Mayer
@Chrono79
Jun 02 2016 01:12
@DoctorSmiles yes, fix the code, maybe refactor wasn't the word I should have used
DoctorSmiles
@DoctorSmiles
Jun 02 2016 01:12
Ah okay I see what you mean by refactor
Just needed to do a quick google search, it's alright
Diego Mayer
@Chrono79
Jun 02 2016 01:14
@DoctorSmiles no need to check for 0, but you have to check if howMany is greater than your array
Chris
@email362
Jun 02 2016 01:15
GUYS I figured it out!!! WooHoo!!!
DoctorSmiles
@DoctorSmiles
Jun 02 2016 01:15
Awesome!
Chris
@email362
Jun 02 2016 01:15
ive been stuck on that problem for like 3 days haha
Kleineken
@Kleineken
Jun 02 2016 01:17

Hello Everyone! I have been having an issue with an api call and I am wondering if anyone may have some experience in pointing me in the right direction to find a solution.
I am calling an api with $.getJSON, I get a 200 OK in the log from the server so the get request is being sent. But my function is not running within the .get, The only cause I can find for this is that the browser is seeing bad JSON object, but when I put the url in my browser i get a perfectly good json object back. If anyone has any ideas I would really appreciate it .
Here is my code:

$(document).ready(function() {
$("#getQuote").on("click", function() {
console.log('before'); $.getJSON("http://quotes.stormconsultancy.co.uk/random.json", function(json) {
console.log(json);
console.log('during');
});
console.log('after');

Michael
@michaeldiegogil
Jun 02 2016 01:18

// Setup
function abTest(a, b) {
  // Only change code below this line

  console.log(a, b < 0);



  // 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);
i feel like i am getting closer but i dont know what i am doing wrong
Diego Mayer
@Chrono79
Jun 02 2016 01:19
@michaeldiegogil how is the challenge name?
Michael
@michaeldiegogil
Jun 02 2016 01:19
Return Early Pattern for Functions
Moisés Man
@moigithub
Jun 02 2016 01:19
@michaeldiegogil console.log is used to output data to the "console" mostly used for debuggin purposes
Diego Mayer
@Chrono79
Jun 02 2016 01:19
@michaeldiegogil Return Early Pattern for Functions and you're using console.log
you have to make an if and use this condition (a, b < 0) but fixed because it's wrong. You need 2 conditions and join them with a logical operator
they ask you to return undefined if the if is true
Aryan
@aryandua
Jun 02 2016 01:20
This message was deleted
This message was deleted
This message was deleted
Nvm got it::)
Michael
@michaeldiegogil
Jun 02 2016 01:21
so it is not console.log
Moisés Man
@moigithub
Jun 02 2016 01:22
re-read the instructions again.. u need to use an IF condition.. and check if a OR b is < 0
and return something if they do (think was undefined?? dont recall )
@michaeldiegogil
Josh
@joshweaver23
Jun 02 2016 01:25
function sym(args) {

  function argsDisect () {
    return Array.prototype.slice.call(args);
  }
  var argsArr = argsDisect();
  console.log(argsArr);

}

sym([1, 2, 3], [5, 2, 1, 4]);
so I'm just trying to gather my arrays at this point, but this code is only returning the first argument to my argsArr array.
bitgrower
@bitgrower
Jun 02 2016 01:26
@joshweaver23 -- the minute you call another function, you have a new arguments object ... you need to take what you are using in the return statement, and put it OUTSIDE of the argsDisect function (inside of the sym function, because you want the sym functions's arguments object, not that of argsDisect...
Josh
@joshweaver23
Jun 02 2016 01:27
@bitgrower ah
function sym(args) {

  var argsArr = Array.prototype.slice.call(args);
  console.log(argsArr);

}

sym([1, 2, 3], [5, 2, 1, 4]);
so I thought this would fix it, but nope. same thing.
Ken Haduch
@khaduch
Jun 02 2016 01:29
@Kleineken - do you have a URL that you can post for this - is it a CodePen project? Being able to look at it in context would be helpful.
bitgrower
@bitgrower
Jun 02 2016 01:30
This message was deleted
Kleineken
@Kleineken
Jun 02 2016 01:31
Sure Ken! I havent given up on it yet, haha I didnt really want to bother you though. Thanks for helping though.
http://codepen.io/Kleineken/pen/dMBaER?editors=0011
Blair Yacishyn
@YacYac
Jun 02 2016 01:31
@Chrono79 Thanks. Got it working!
CamperBot
@camperbot
Jun 02 2016 01:31
yacyac sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 995 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 02 2016 01:31
@YacYac :+1:
GHC
@mr-ghc
Jun 02 2016 01:32
What am I doing wrong here on #152?
var myStr; "I am a \"double quoted\" string inside \"double quotes\";
DaPrKid
@DaPrKid
Jun 02 2016 01:32
hello everybody
Kleineken
@Kleineken
Jun 02 2016 01:33
@khaduch I had considered attempting an .ajax call because Ive read that will kick an error message if something is wrong? Where .getJSON will fail silent. But the only thing I can find that will cause the function not to run with a successful server response is a bad object
Diego Mayer
@Chrono79
Jun 02 2016 01:33
@mr-ghc did you miss a " at the end?
var myStr; <- fix this too
Luis Cabrera
@loudigi
Jun 02 2016 01:34
@mr-ghc You also missed the = sign for your var
Ken Haduch
@khaduch
Jun 02 2016 01:34

@Kleineken @Kleineken - you are getting an error, which can be seen in the developer's console:

XMLHttpRequest cannot load http://quotes.stormconsultancy.co.uk/random.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://s.codepen.io' is therefore not allowed access.

So it is failing to respond to your request.

bitgrower
@bitgrower
Jun 02 2016 01:35

@joshweaver23 -- args is not the same as your arguments object ... sorry ... I wasn't paying careful attention ...

The way which has been recommended to me to use it is by looping thru the arguments object using a for loop with arguments.length giving you the loop delimiter

Kleineken
@Kleineken
Jun 02 2016 01:35
I wasnt getting that error? @khaduch . This si the same console pulled up with ctrl+shift+J?
GHC
@mr-ghc
Jun 02 2016 01:35
Yeah I dont know why it starts you with a semicolon. Thats kinda weird. I even restarted it.
Ken Haduch
@khaduch
Jun 02 2016 01:36
@Kleineken - hmmmm - it is the developer's console - I think usually ctrl + shift + I. I'm using Chrome on windows - what browser / platform are you using?
Kleineken
@Kleineken
Jun 02 2016 01:36
@khaduch I can load a successful object by directly accessing the link in a browser. How can I capture that object then?
Firefox sorry i meant to metnion that
Ken Haduch
@khaduch
Jun 02 2016 01:37
@Kleineken - it is different doing things from a browser compared to a JSON request. I have some notes on a way to make this site work, I was helping someone and researching it. But let me look in firefox first.
bitgrower
@bitgrower
Jun 02 2016 01:38

args refers ONLY to the first parameter ...

...think of it this way ...

...a javascript function can have ANY number of parameters passed to it ...unlike other programming languages, you do not have to "name" all the parameters passed ...

the key here is "named" parameters ... so, if there is one name in the parameter list, that's going to be the same as arguments[0] -- but if 2 arguments are passed, you need to use the arguments object to access the second argument -- like so ... myVar[1] = arguments[1];

Kleineken
@Kleineken
Jun 02 2016 01:39
@khaduch I guess the main thing throwing me was the api documentation (what was available) said this was a json request so I thought i could use the Jquery wrapper on it
Ken Haduch
@khaduch
Jun 02 2016 01:40

@Kleineken - I see a similar error in the firebug console: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://quotes.stormconsultancy.co.uk/random.json. (Reason: CORS header 'Access-Control-Allow-Origin' missing).

The method that works is to use a proxy site that properly sets this up - I'll paste a URL here for the request:

https://jsonp.afeld.me/?callback=?&url=http://quotes.stormconsultancy.co.uk/random.json
using that a response comes back.
Josh
@joshweaver23
Jun 02 2016 01:42
@bitgrower Got it.
var argsArr = Array.prototype.slice.call(arguments);
is giving me the arrays I expect... I wasn't appreciating the differentiation between args and arguments
Kleineken
@Kleineken
Jun 02 2016 01:42
@khaduch You dont happen to know any links that I could read about why this needs to happen by chance? Im afraid I don't entirely understand what is happening behond the scenes here, In my firefox console I see a:
GET
XHR
http://quotes.stormconsultancy.co.uk/random.json [HTTP/1.1 200 OK 108ms
Josh
@joshweaver23
Jun 02 2016 01:42
@bitgrower thank you!
CamperBot
@camperbot
Jun 02 2016 01:42
joshweaver23 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1075 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 02 2016 01:43
YAY !!!!
Kleineken
@Kleineken
Jun 02 2016 01:45
@khaduch I do have a successful response now though, that in itself is incredibly relieving. It has been burning me up for a couple days now. Thank you so much
CamperBot
@camperbot
Jun 02 2016 01:45
kleineken sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1245 | @khaduch |http://www.freecodecamp.com/khaduch
Luis Cabrera
@loudigi
Jun 02 2016 01:47
I find the instructions for 163 escape sequence very unclear. Any ideas on what this should look like?
bitgrower
@bitgrower
Jun 02 2016 01:48
@Kleineken - search out "CORS" ... it's a security feature
Diego Mayer
@Chrono79
Jun 02 2016 01:48
you have to translate what they told you with the table provided @loudigi
Kleineken
@Kleineken
Jun 02 2016 01:49
@bitgrower Ok I'll start there. I appreciate it.
bitgrower
@bitgrower
Jun 02 2016 01:49
@Kleineken -- GET is a standard http request, XHR is an abbreviation for XMLHttpRequest ...
Ken Haduch
@khaduch
Jun 02 2016 01:50

@Kleineken in the Firebug console, I see that, but it is colored in red with a big (well, a small) red X. So it is failing. I haven't directly tried the Firefox debug console... I just did - I see the same error information there.

You can google for that problem and read about it - in some places it says that you can modify the setup of your server (which you cannot do for CodePen) I don't remember finding another solution that you could use from the client-side, but I could be wrong?

bitgrower
@bitgrower
Jun 02 2016 01:51
@khaduch -- I think there are some other sites mentioned on either/or StackExchange (StackOverflow), MDN, etc ...
pretty sure googling CORS will get you there ... or the full Cross-Origin-...whatever the rest of it stands for ... :)
Ken Haduch
@khaduch
Jun 02 2016 01:51

@Kleineken - you can read about it here. https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

@bitgrower - thanks - I do have one other site that I saw mentioned. That one that I gave worked out...

CamperBot
@camperbot
Jun 02 2016 01:51
khaduch sends brownie points to @kleineken and @bitgrower :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @kleineken |http://www.freecodecamp.com/kleineken
:star2: 1076 | @bitgrower |http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Jun 02 2016 01:52
(Request-Specification perhaps?)
Kleineken
@Kleineken
Jun 02 2016 01:52
@khaduch @bitgrower I will make a note of the keywords and try to branch out from there. Thanks again. I already have http access control docs up from mozilla Ill follow that rabbit hole for a while
CamperBot
@camperbot
Jun 02 2016 01:52
:star2: 1077 | @bitgrower |http://www.freecodecamp.com/bitgrower
:warning: kleineken already gave khaduch points
kleineken sends brownie points to @khaduch and @bitgrower :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Jun 02 2016 01:57

personally, I wouldn't spend a HUGE amount of time on it if you have something which works -- I don't think there are a lot of variations once you get it to work on one API ...

It's kinda like me and making the arguments object arguments usable ... I've seen a couple of different solutions (outside of just using a loop) .. but I don't fully understand them (yet) ... however, it's been highly recommended because of issues of "V8" (js used in chrome browser) to use the loop method ...

marcelpirata
@marcelpirata
Jun 02 2016 01:59
Hey guys, I need you guys opinion... it has been a little over a week since I started at freecodecamp... and I am still in the assignment "Stand in line" of JavaScript. I practice around 2 to 4 hours per day. I feel that I am struggling a lot, getting stuck; and sometimes I don't even know how to start the assignment, and I end up hating myself for my failure ... this is my first time ever trying any programing... but still... any advice please?
Harvey Le
@Jurkel
Jun 02 2016 01:59
I'm on the same problem and I can't get it to work
Kleineken
@Kleineken
Jun 02 2016 01:59
I won't, I just feel like this is probably not the last time I will run into this if I keep up with it so I wanted to at least have a vague idea of the problem @bitgrower
Diego Mayer
@Chrono79
Jun 02 2016 02:00
review previous challenges that are related
@Jurkel @marcelpirata
@marcelpirata it's normal to get stuck if you never programmed before
Joseph
@revisualize
Jun 02 2016 02:02
@marcelpirata I, and a bunch of people, replied to you in main chat.
Kleineken
@Kleineken
Jun 02 2016 02:03
I listened to a codenewbie podcast the other day and heard something there really insightful that helps me when i get stuck:
"One of the really important things about starting a new job or
project that is outside of our development, is to not be intimidated.
As engineers and as developers, we are paid to be frustrated. It
doesn't mean you're stupid or you're not good enough to be a
developer, part of your job is to be frustrated. It isn't that the
frustration goes away as you get more experienced, you just learn that
you will get better at understanding what that level of stress is and
to be ok with that frustration. Just be consistent, get through it,
you're going to get better, it takes time."
Joseph
@revisualize
Jun 02 2016 02:03
@marcelpirata --^^
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:04
i have a doubt

This is my code function randomFraction() {

// Only change code below this line.
return Math.random();

// Only change code above this line.
}

bitgrower
@bitgrower
Jun 02 2016 02:05

well -- the problems you deal with get more interesting (and more complex) ... but the problems which are frustrating are usually the interesting ones, as well -- they challenge us ... and from what I hear, help grow new neurons ...

...think of the problems you solved as like levels of scaffolding ... your expertise the scaffold you're standing on now, the problem is the scaffolding you are building ...

Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:05
can anyone tell me where i had done wrong
Harvey Le
@Jurkel
Jun 02 2016 02:05
@Chrono79 Thanks man, I'll do that. I have most of it figured out, I just can't get one out of the four requirements.
CamperBot
@camperbot
Jun 02 2016 02:05
jurkel sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 996 | @chrono79 |http://www.freecodecamp.com/chrono79
Diego Mayer
@Chrono79
Jun 02 2016 02:05
@Jurkel which one? paste your code
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:05

function randomFraction() {

// Only change code below this line.
return Math.random();

// Only change code above this line.
}

Harvey Le
@Jurkel
Jun 02 2016 02:06

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

return first; // Change this line
}

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

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

Ken Haduch
@khaduch
Jun 02 2016 02:06
@Jurkel - I'll bet it's the one with the argument ([],1)
Harvey Le
@Jurkel
Jun 02 2016 02:06
It is!!
Diego Mayer
@Chrono79
Jun 02 2016 02:06
@Jurkel that's because the order matters
first you add the item at the end
then you remove the first element and return it
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:07
i am trying to solve from last one hour bit i am not getting the solutions
Ken Haduch
@khaduch
Jun 02 2016 02:07
@Jurkel - you have to get in line before you get out of the line... since they have it based on a line ....
Diego Mayer
@Chrono79
Jun 02 2016 02:08
@Santosh456 your code looks ok, try refreshing your browser
Joseph
@revisualize
Jun 02 2016 02:09
@Jurkel can I make a suggestion?
via PM?
Harvey Le
@Jurkel
Jun 02 2016 02:09
Sure.
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:09
@Chrono79 thanks
CamperBot
@camperbot
Jun 02 2016 02:09
santosh456 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:cookie: 997 | @chrono79 |http://www.freecodecamp.com/chrono79
Ken Haduch
@khaduch
Jun 02 2016 02:10
@Jurkel - in other words - you cannot do this: var first = arr[0]; first, and you should not use that method to get the first element from the queue (array, line) whatever you want to call it.
Xavier Velez
@JonSnow08
Jun 02 2016 02:11
function destroyer(arr) {
  // Remove all the values
  var args = Array.prototype.slice.call(arguments);
  var answerFig = 0;     
        function arrayCheck (argu){
          for (var i = 1; i < argu[0].length; i++){
            answerFig = argu[0][0].indexOf(argu[0][i],[0]);
            if (answerFig === -1){return false;
                                 } 
          }
                  return true;

        }

  args.filter(arrayCheck);      





  return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I know my code is all over the place at the moment but I am at least going in the right direction?
Diego Mayer
@Chrono79
Jun 02 2016 02:14
@JonSnow08 do a console.log with argu
*cough*
Harvey Le
@Jurkel
Jun 02 2016 02:15
@revisualize Thanks
CamperBot
@camperbot
Jun 02 2016 02:15
jurkel sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1206 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Jun 02 2016 02:15
@Jurkel :D Glad I could help.
Xavier Velez
@JonSnow08
Jun 02 2016 02:16
@Chrono79 how do I do that? sorry I don't use that command often
Diego Mayer
@Chrono79
Jun 02 2016 02:17
@JonSnow08 console.log(argu); and you have to check your browser console or use what @revisualize suggested
Xavier Velez
@JonSnow08
Jun 02 2016 02:18
i use pythontutor all the time am I missing something I should be seeing from that?
ah I didn't get that far my .length isnt reading
Diego Mayer
@Chrono79
Jun 02 2016 02:20
@JonSnow08 that's because argu is a 1d array of numbers, so argu[0].length doesn't exist
Ken Haduch
@khaduch
Jun 02 2016 02:22

@marcelpirata - Hello there. Don't get too upset about it, especially if you are just starting out. There are concepts that are not that easy to grasp, and this problem "Stand In Line" seems to challenge a lot of people. I think that it is one of the first challenges (or at least one of the earliest ones) that require you to synthesize a few concepts that were presented a few lessons before, particularly (for this one) in the Array manipulations with push, pop, shift, and unshift. They also throw a little computer science terminology in there with "queue". Again, if you haven't really studied computer science or any programming, it might be a foreign concept. This is one thing that the forums are good for - you can come and ask questions and there are a lot of good people here to help out. One thing that you don't want to do is ask for the answer - that might seem like an attractive option, but you want to learn how to think about some of these problems, especially these earlier and more basic ones. But you can ask questions about "what does this mean", get some added explanations about what the problem / question is about. It is good to spend time struggling with it on your own, because that is where your learning and understanding will come from - even if you do not get the answer, if you have thought about it a lot, when you get the answer you might have a better understanding, rather than if someone just said - "hey, here's the answer..."

There is even extended help on these lessons on the wiki, including the solutions (they warn you "spoiler ahead") but if you look at the hints, at least after you've worked honestly on it for a long time, it can guide you in the right direction, or at least help to make you think about it differently. You definitely have to build up to the more challenging problems, so take the steps slowly, make sure you learn the concepts (like for this one - go back and review those Array push, pop, etc. lessons) Google the "computer science queue" and read what it says. Read, Search, Ask - as they say! Good luck, stay calm, we all get stumped now and then!

Xavier Velez
@JonSnow08
Jun 02 2016 02:24
@Chrono79 so where are the other two numbers going when I slice?
@Chrono79 i would have thought the first array would be nested into an array with them
not become it's own separate array
Diego Mayer
@Chrono79
Jun 02 2016 02:26
@JonSnow08 argu is arguments[0] the first time, the second time it's 2 and the third it's 3
Xavier Velez
@JonSnow08
Jun 02 2016 02:27
so confused. so I have to call it 3 different times you're saying?
Diego Mayer
@Chrono79
Jun 02 2016 02:28
@JonSnow08 no, it is called 3 times by the filter method, each time passing a different element of args array
marcelpirata
@marcelpirata
Jun 02 2016 02:29
@khaduch thank you so much ken... I really appreciated it!
CamperBot
@camperbot
Jun 02 2016 02:29
marcelpirata sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star2: 1246 | @khaduch |http://www.freecodecamp.com/khaduch
marcelpirata
@marcelpirata
Jun 02 2016 02:30
@khaduch I have few more questions on this learning topic...
bitgrower
@bitgrower
Jun 02 2016 02:30
I admit ... I did not solve seek and destroy on my own ... but even though I looked at the solution ... I also made sure to understand every piece of the solution ... and yes, before I "peaked' -- I did my best to read, search and ask ... in fact, I asked an experienced programmer I know to tell me how the solution worked ... and she gave me a wrong answer (I discovered later, because I would not leave it alone until I understood it) ... I didn't keep track of how many hours I spent on Seek and Destroy -- but it was a LOT ... my first hurdle was in really understanding the arguments object,, and then how to get an actual local variable (array) containing all the arguments ... as a consequence, it's actually one of my favorite challenges ...
Jose
@Jjmaster2010
Jun 02 2016 02:31
inthe convert celsius to fahrenheit everytime i put the code i get the greeen checkmark
but then it tell me to change it and when i do the green checkmark before the one i get gets erased and turns red. has anyone been thru this before?
Xavier Velez
@JonSnow08
Jun 02 2016 02:32
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:32
Hello guys, quick question...I am getting TypeError true is not a function on this code.. I'm trying to solve the Diff Two Arrays thingy. I'm not even exiting the function I'm calling..I'm stuck :)
function diffArray(arr1, arr2) {
  var newArr = [];
  var temp1 = [];
  var temp2 = [];
  // Same, same; but different.
  function customFilter(obj,index,arr){
      return (arr.indexOf(obj) === -1);  
  }

  for(var i = 0; i < arr1.length;i++){
  temp1.push(arr1.filter(customFilter(arr1[i],i,arr2)));

  }

  for(var j = 0;j < arr2.length;j++){
  temp2.push(arr2.filter(customFilter(arr2[j],j,arr1)));

  }

  newArr = temp1.concat(temp2);
  return newArr;
}

diffArray([1, 2, 3, 5], [0, 0, 0, 0,]);
bitgrower
@bitgrower
Jun 02 2016 02:32
note that, for some crazy reason, when I asked the same question about the args parameter in these chats that many other people have -- I could not, at the time, find someone who helped me understand it ... I finally "kind of" figured it out based on a few things I knew about javascript ... which was further confirmed and cemented by subsequent knowledge ...
marcelpirata
@marcelpirata
Jun 02 2016 02:33
@khaduch I was granted a scholarship to attend a Code boot camp here in Seattle... it is 12 weeks of .NET, which will start around july 5th... do you have any advice for someone like me who is very green?
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:33
are we talking about seek and destroy? I have a question about it but don't want the answer... is it going to be revealed in this conversation or can i jump in without worrying?
bitgrower
@bitgrower
Jun 02 2016 02:34
you can jump in without worrying ... most of us are NOT interested in providing answers ... (they can be had, for those desparate enough) in the wiki ...
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:34
@marcelpirata Advice is grasp the fundamentals.
bitgrower
@bitgrower
Jun 02 2016 02:34
@marcelpirata -- hmm ... is that bootcamp especially oriented toward web dev or app dev ?
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:34
Well I just meant getting the answer because maybe someone else was on it too and was getting advice which would thereby give the answer... but cool
can anyone help me on this?
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:35
@marcelpirata .NET is very different to javascript, C# syntax is close, but the strictness of C# forces you to do things differently :)
JongWoo Ha
@jongwooha98
Jun 02 2016 02:35
I feel stupid not knowing how to do this
marcelpirata
@marcelpirata
Jun 02 2016 02:35
@AIRyndon such? can you say more about that?
Jose
@Jjmaster2010
Jun 02 2016 02:35
inthe convert celsius to fahrenheit everytime i put the code i get the greeen checkmark
but then it tell me to change it and when i do the green checkmark before the one i get gets erased and turns red. has anyone been thru this before?
marcelpirata
@marcelpirata
Jun 02 2016 02:35
@bitgrower web dev
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:36
@marcelpirata data structures, flow control, c# web dev is prolly ASP.NET MVC, using C#
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:36
can anyone tell me what i had done wrong into my code

var Car = function() {
this.wheels = 4;
this.engines = 1;
this.seats = 1;
};

// Only change code below this line.

var myCar = new Car();
myCar.turboType = "twin";

Angelo Ryndon
@AIRyndon
Jun 02 2016 02:36
touch of javascript html css front end, c# and linq backend to talk with the database..I'm guessing they will want to expose you to the full stack there :)
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 02:37
I am getting the error The property nickname of myCar should be a string.
marcelpirata
@marcelpirata
Jun 02 2016 02:37
@AIRyndon yes they will...
Ken Haduch
@khaduch
Jun 02 2016 02:37
@marcelpirata - well, it depends on how the advertise the course / boot camp. If they say "no experience necessary", it could be a totally different experience being in a classroom situation and having people around to help when you have questions. Someone watching over your shoulder to guide you more closely can be a big help. Also, as @bitgrower asked - what is the purpose of the course? And will .NET be helpful / useful to you? (For example, is this scholarship from someone who has jobs to fill?) It isn't a bad idea to have different experiences of different languages - all can be used for something, and you can learn the basic concepts in many different ways.
bitgrower
@bitgrower
Jun 02 2016 02:37

@marcelpirata -- there are competing technologies ... .net is very windows/MSFT centric ... but has the potential to grow wildly with the purchase of xamarin ..

Hmm .... interesting ... .NET is not currently the foremost technology in web dev (in terms of people learning it, knowing it) ... but .NET can be extremely powerful ... and has some good potential for the reason I mentioned ... (that is, they are really working on taking .NET to be a cross-platform technoloy

Angelo Ryndon
@AIRyndon
Jun 02 2016 02:38
@marcelpirata that's why fundamentals is key..know data structures, OOP concepts, don't mind the languages first. Syntax just changes but the concept stays :)
Norvin Burrus
@ndburrus
Jun 02 2016 02:38
@Santosh456 which challenge?
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:38
@marcelpirata functional programming is also very strong especially for LINQ :)
bitgrower
@bitgrower
Jun 02 2016 02:38
I mean...some schools (not just in coding) ... are designed to fill a special market -- and there are a LOT of windows machines & servers out there ...
for instance, one school was started in order for there to be a bigger supply of copywriters ... with a lot of encouragement and influence by one of the top direct mail companies (Agora) ... who needed more copywriters ...
Norvin Burrus
@ndburrus
Jun 02 2016 02:40
@Santosh456 review/check this line myCar.turboType = "twin"; carefully review the instructions: Then give myCar a nickname property with a string value. did you get it?
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:40
For those who have an idea why I'm getting TypeError true is not a function. Help is much appreciated :)
function diffArray(arr1, arr2) {
  var newArr = [];
  var temp1 = [];
  var temp2 = [];
  // Same, same; but different.
  function customFilter(obj,index,arr){
      return (arr.indexOf(obj) === -1);  
  }

  for(var i = 0; i < arr1.length;i++){
  temp1.push(arr1.filter(customFilter(arr1[i],i,arr2)));

  }

  for(var j = 0;j < arr2.length;j++){
  temp2.push(arr2.filter(customFilter(arr2[j],j,arr1)));

  }

  newArr = temp1.concat(temp2);
  return newArr;
}

diffArray([1, 2, 3, 5], [0, 0, 0, 0,]);
Josh
@joshweaver23
Jun 02 2016 02:41
@bitgrower Finished the Symmetric Difference bonfire. Thanks again for your help with the arguments object stuff. :)
CamperBot
@camperbot
Jun 02 2016 02:41
joshweaver23 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: joshweaver23 already gave bitgrower points
Ken Haduch
@khaduch
Jun 02 2016 02:41
@jongwooha98 - taking a look at your link.
bitgrower
@bitgrower
Jun 02 2016 02:42
I'm not sure if I totally agree with concepts staying the same ... I mean ... just having programming languages was a new concept ... then structured programming was the hot thing ... and about 30-40 years, OOP started becoming popular ... the idea of frameworks really didn't exist when I started out ... I think the next wave/current/hot wave is functional programming, though ...
congrats, @joshweaver23 ... I need to go look at my solution again at some point ...
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:43
@bitgrower it does...the computer still sees 010101 :)
@bitgrower all we do is manage complexity...that's why we have frameworks
bitgrower
@bitgrower
Jun 02 2016 02:44
yeah ... but tell me how many programmers even know ANY assembly language any more :)
bitgrower @bitgrower programmed in assembly for a good long time ...
bitgrower
@bitgrower
Jun 02 2016 02:45
MANY assembly languages ...
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:45
@bitgrower directing this towards you since I saw from your earlier comment that you've been through this, so here goes... this is what I have so far. My logic so far has been to use the argument object to create an array from the original arguments, then use slice and push to create a multidimensional array with both the original arguments since the last ones are just hanging out as individual elements. Then using nested for loops to iterate through to find out if the elements in the second array are indexes of the first. This all seems to be working and the console.log() statement logs all of the elements in the second array and shows that the loop is working... from there, I figure use filter to filter out 'args1[1][j]- this is where the function is getting tripped up. This is all hard to put into words but if you get where I'm going with this, will I be able to solve it going down this road? With this logic, if I can get the return insecondArg` to return all of the values in the second array it should work, no? for some reason, it's currently only filtering out the second element of the array... why? Does any of this make sense?
function destroyer(arr) {
  var filtered;
  var args = Array.prototype.slice.call(arguments);
  var args1 = args.slice(0, 1);
  var args2 = args.slice(1);
  args1.push(args2);


for (var i = 0; i < args1.length; i++) {
    for (var j = 0; j < args1[1].length; j++) {
      if (args1[0].indexOf(args1[1][j]) !== -1) {
        filtered = args1[0].filter(secondArg);
        console.log(args1[1][j]);
      } 
    }
  }

  function secondArg(val) {
    return val !== args1[1][j];
  }

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
bitgrower
@bitgrower
Jun 02 2016 02:47
@no-stack-dub-sack -- I would recommend considering how you might use indexOf in your answer, and also, possibly, splice ... I'd recommend splice anyway, because it's such a cool, neat and powerful function ...
Ken Haduch
@khaduch
Jun 02 2016 02:47
@jongwooha98 - you should reset your code - and all they want you to do is follow the pattern that they showed in the example.
myVar = myVar + 5; adds 5 to the value that is stored in the variable myVar, and replaces it into the variable. The "shortcut" is to use the += operator because it is a commonly-used operation, so you would convert myVar = myVar + 5; to be written as myVar += 5. Just follow that pattern on the variables a, b, and c - do not re-declare the variables, as in do not use the var keyword below the line
Nick Ang
@nickangtc
Jun 02 2016 02:47

Hey, I need help figuring out how to get through this challenge: https://www.freecodecamp.com/challenges/seek-and-destroy

Specifically, I'm wondering whether array.filter() can take in an array as the callback function. My guess is that it can, but I'll need to do a loop inside the callback function?

bitgrower
@bitgrower
Jun 02 2016 02:47
must be seek and destroy night ...
Nick Ang
@nickangtc
Jun 02 2016 02:47
Oh hahah did someone just ask the same question?
khaduch @khaduch - also used assembly language in the distant past... :)
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:47
haha
bitgrower
@bitgrower
Jun 02 2016 02:48
uh ... the callback function is a function ...not an array ?
Nick Ang
@nickangtc
Jun 02 2016 02:48
Tell me if I can just review the answers given above...
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:48
no but I'm seeking some help too because this challenge is destroying me
bitgrower
@bitgrower
Jun 02 2016 02:48
not the same question, but about the same challenge ...
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:48
@bitgrower ok... I'll think about that. Am I at least on the right path or do I have to rethink everything?
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:49
@no-stack-dub-sack Hint..you can you the Array.from in Javascript on that arguments obj :)
you can use i mean
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:50
@bitgrower because I do have indexOf in use currently, you're just saying I need to rethink how I'm using it?
shaunski11
@shaunski11
Jun 02 2016 02:50
Does anyone know how to use an API key in CodePen? Is it even possible? I'm working on the weather app project and I'm having a hard time finding a keyless API.
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:50
@shaun yeah it is bro
@shaunski11 like this $.getJSON("http://api.openweathermap.org/data/2.5/
openweather just wants you to sign up for their api
bitgrower
@bitgrower
Jun 02 2016 02:51

well ... there are often many ways of solving a problem ... and I fully advocate doing inelegant solutions if that gets you the answer, rather than worrying about elegance .. (and, in fact, that is kinda how it works in industry, as well) ...

@no-stack-dub-sack -- sorry, I missed it ...

What I'm trying to say is, once you see an elegant solution, helping someone with a less elegant solution can be harder ...so there's kind of a trade off ...

Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:51
@AIRyndon you mean instead of using Array.prototype.slice.call? I'd get the same result in the end right - that would just be to turn the arguments object into an array?
Nick Ang
@nickangtc
Jun 02 2016 02:51

Right. I know the callback function is a function... (though I don't think I've wrapped my head around the whole filter by a function thing).

So what I've done so far is create an arguments object from the argument 'arr', break that into two parts (1st part holds the array to be cleansed; 2nd part holds the target values to destroy).

I'm trying to use this 2nd part as arguments to filter the 1st part, using array.filter() - but it's not working

Angelo Ryndon
@AIRyndon
Jun 02 2016 02:51
@no-stack-dub-sack yes. it turns that arguments to an array :)
@no-stack-dub-sack next step is creating the function to feed to .filter
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:52
@AIRyndon that's what this part is:
function secondArg(val) {
    return val !== args1[1][j];
  }

  return filtered;
bitgrower
@bitgrower
Jun 02 2016 02:53
@nickangtc you should probably post your code ... though I actually suspect you and @no-stack-dub-sack might want to get together and pair program S&D ... by the questions you both have, I think you might get value from each other's insight into the problem ... :)
Nick Ang
@nickangtc
Jun 02 2016 02:53

Another way I can think of is to use a 'for' loop. But it told me not to use a function in a loop. So that's out.

I think I'm misunderstanding either the arguments object or the .filter() method

bitgrower
@bitgrower
Jun 02 2016 02:54
and @no-stack-dub-sack -- I'm not saying your angle is inelegant ... it's just less elegant than the solution "I know" ... (as well as nested loops with functional programming calls in them hurt my head a bit ... lot a looping going on ... )
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:54
@no-stack-dub-sack you can do all that in 1 for loop.nested for loops are a no-no and should be done last result since they are uber slow
bitgrower
@bitgrower
Jun 02 2016 02:55
Seriously -- I think both you two should create a gitter room and pair program ... it can be really fun ...
Angelo Ryndon
@AIRyndon
Jun 02 2016 02:55
seek and destroy
function destroyer(arr) {
  // Remove all the values
  var optionalArgs = Array.from(arguments);
  optionalArgs.shift();

  function removeCopies(value)
  {
    for(var i = 0; i < optionalArgs.length;i++)
    {
      if (value === optionalArgs[i])
        return false;
    }
    return true; 
  }  
  return arr.filter(removeCopies);
}

destroyer([1,2,3,1,2,3],1,2);
Nick Ang
@nickangtc
Jun 02 2016 02:55
I'm up for it but don't know how to set that up
bitgrower
@bitgrower
Jun 02 2016 02:55
...and it's heavily encouraged, I gather, in industry currently along with the agile/scrum methodologies
Nick Ang
@nickangtc
Jun 02 2016 02:55
@bitgrower thanks for your help so far
CamperBot
@camperbot
Jun 02 2016 02:55
:star2: 1078 | @bitgrower |http://www.freecodecamp.com/bitgrower
nickangtc sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:56
@AIRyndon problem I was having without nesting the loops was that I wasn't getting it looping through the second array right, but that would only be beneficial if the function I was feeding to the filter was working the way I intended, but its now
*not
@nickangtc I'll PM you
Nick Ang
@nickangtc
Jun 02 2016 02:57
Ok
bitgrower
@bitgrower
Jun 02 2016 02:57

I'm up for it but don't know how to set that up

... I don't either actually,, I just know it's not hard and it's possible and that you can find out how to do it with google ... :)

@khaduch -- which assy languages ?
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 02:58
@bitgrower per your previous comment, not really worried about elegance at this point - just curious if I am even on the right track
bitgrower
@bitgrower
Jun 02 2016 02:59
it looks like it could be workable, yes ... you both might like sticking your code in this site (which, btw, you can also invite people in on): pythontutor.com/javascript.html (don't let the domain name fool you) ... people tend to love this site, because you can actually see a visualization of your code as you step thru it ...
Ken Haduch
@khaduch
Jun 02 2016 03:00
@bitgrower - PDP-8, PDP-11, Vax, all Digital Equipment Corporation - those were the main ones. I've probably dabbled in a couple others, but never to the extent that I used those. Then I moved on to C, for a long time... now I'm wandering in the desert, learning javascript... :)
shaunski11
@shaunski11
Jun 02 2016 03:00
@AIRyndon I was using that API until I realized that they wanted me to sign up for it. I'll sign up and give it another try.
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 03:00
Yeah @revisualize turned me on to that, it can be helpful but slightly confusing at times to newbies
bitgrower
@bitgrower
Jun 02 2016 03:01
oh PDP-8 -- that is quite a while back ... I remember about 30 years ago one of my friends was thinking about buying a used PDP-8 machine (in fact, I think he DID buy one...)
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 03:01
does anyone know how the heck to start a private conversation? I have several going but I didn't start any of them!
bitgrower
@bitgrower
Jun 02 2016 03:02
-- @no-stack-dub-sack -- with one other person -- you just click on their name in here, respond to the appropriate button in the popup
Ken Haduch
@khaduch
Jun 02 2016 03:02
@no-stack-dub-sack - right click (or hover) on the person's profile picture and click "Chat Privately"
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 03:02
ha! of course. Thanks
bitgrower
@bitgrower
Jun 02 2016 03:02
LOL ... the difference between an inelegant answer (mine) ... and @khaduch 's .. (elegant)
shaunski11
@shaunski11
Jun 02 2016 03:03
@AIRyndon I signed up but how do I use that key within CodePen?
bitgrower
@bitgrower
Jun 02 2016 03:03
esp since it's hovering, and over their @ name ...
mariomendes
@mariomendes
Jun 02 2016 03:04
hey guys i was wondering if someone could help me out with a javascript issue im having plz pm me :)
Angelo Ryndon
@AIRyndon
Jun 02 2016 03:04

@shaunski11

$.getJSON("http://ipinfo.io/json",function(response){
     var api = ;
     var tempUnit = "&units=metric&type=accurate"
     var myCity = "response.city";

     $.getJSON("http://api.openweathermap.org/data/2.5/weather?q="              + myCity + tempUnit + api,function(data){

just plug your api at the end

bitgrower
@bitgrower
Jun 02 2016 03:05
@khaduch -- I learned a tiny bit of IBM 360, then got a job doing assy language using their own mini-computers (16 general purpose registers, not unlike mc680x0)
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 03:05
@AIRyndon Wait was that the solution you posted before? I didn't look at it if so...
Angelo Ryndon
@AIRyndon
Jun 02 2016 03:05
@no-stack-dub-sack yeah the seek and destroy thingy...
I hate how javascript types are IMPLIED hahaha
Peter Weinberg
@no-stack-dub-sack
Jun 02 2016 03:05
Ahh, I didn't look at it thankfully. too soon, I'd like to figure it out on my own ideally
bitgrower
@bitgrower
Jun 02 2016 03:06
@no-stack-dub-sack even if someone did post a solution --it's a gnarly enough program you aren't gotten be able to solve it without thinking through the other solution ... :)
Ken Haduch
@khaduch
Jun 02 2016 03:06
@bitgrower - I see... I never did have access to any IBM systems... That's interesting about your friend and the PDP-8. I learned my initial programming skills on a first-generation PDP-8.
Nick LaBelle
@dogwaddle
Jun 02 2016 03:07
Anyone around that could help me wrap my mind around the steamroller challenge and recursion?
Angelo Ryndon
@AIRyndon
Jun 02 2016 03:07
@no-stack-dub-sack that's good.hehehe..
shaunski11
@shaunski11
Jun 02 2016 03:07
@AIRyndon Thanks!
CamperBot
@camperbot
Jun 02 2016 03:07
shaunski11 sends brownie points to @airyndon :sparkles: :thumbsup: :sparkles:
:cookie: 287 | @airyndon |http://www.freecodecamp.com/airyndon
bitgrower
@bitgrower
Jun 02 2016 03:07
@dogwaddle -- first things first ... how comfortable are you with recursion ... ?
Nick LaBelle
@dogwaddle
Jun 02 2016 03:07
@bitgrower I understand the concept, it just implementing it that is hard
bitgrower
@bitgrower
Jun 02 2016 03:08
I would say the #1 helpful thing I learned about doing recursion is to start your function with the code which determines if it's time to exit (aka, return) ...
yeah .. the IBM 360 was a community college class ... since I changed jobs, where I was working swing to where I became a 9-5er (doing the assy language I mentioned) ... I didn't complete the class ...
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:12
can anyone tell me what i had done wrong in this code

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function()
{

// Only change code below this line.
var gear = 5;

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

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

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

};

var myCar = new Car();

var myBike = new Bike();

my error is myBike.getGear() should return 1 after calling myBike.setGear(1).
bitgrower
@bitgrower
Jun 02 2016 03:13

@dogwaddle -- the SIMPLEST recursion challenge is doing factorials ... whenever I get stuck with recursion, I visit my recursive solution to finding factorials ... it's by no means something completely automatic for me ...

I would also say that, while it can be a common interview question (apparently) ...because recursion can have a lot of overhead, it's often NOT the preferred solution in industry (again, from what I understand ... I don't recall doing a lot of it when I was in industry ...

Asma
@asma8867
Jun 02 2016 03:14

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


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



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

    var result=contacts[i].hasOwnProperty(prop);

      if (contacts[i].firstName===firstName){

        if (result===true){

          return contacts[i][prop];
        }
      else 
      {
        return "No such property";
      }

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

  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
please someone help me :(
so frustrated..
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:15
what is the challenge number
@asma8867
Asma
@asma8867
Jun 02 2016 03:15
231
profile lookup
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:15
just wait a min
Asma
@asma8867
Jun 02 2016 03:16
ok
bitgrower
@bitgrower
Jun 02 2016 03:16
@asma8867 looks like you've got a good start on it ...
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:16

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

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

// Change these values to test your function
lookUpProfile("Kristian", "lastName");

Norvin Burrus
@ndburrus
Jun 02 2016 03:17
@asma8867 after the firstName check, the code also needs to check (for firstName matches) if the property exists... :) ok, you have that... does it work? if not, should there be an else?
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:18

@ndburrus @Santosh456
can anyone tell me what i had done wrong in this code

var Car = function() {
// this is a private variable
var speed = 10;

// these are public methods
this.accelerate = function(change) {
speed += change;
};

this.decelerate = function() {
speed -= 5;
};

this.getSpeed = function() {
return speed;
};
};

var Bike = function()
{

// Only change code below this line.
var gear = 5;

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

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

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

};

var myCar = new Car();

var myBike = new Bike();
my error is myBike.getGear() should return 1 after calling myBike.setGear(1).

Norvin Burrus
@ndburrus
Jun 02 2016 03:22
@Santosh456 it looks like myBike.setGear(1) returns 6? if you want a 1 return value - pass the value straight through.... don't modify it at the gear assignment... gear += change;
Ken Haduch
@khaduch
Jun 02 2016 03:22
or 4
sorry, I read that wrong...
time for this old man to get offline for a while... ;)
khaduch @khaduch - this old man says "good night all" - happy coding!
Asma
@asma8867
Jun 02 2016 03:25
@ndburrus I can not meet the "No such contact" condition yet :(
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:27
blob
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:27
@asma8867 u got the solution
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:27
i am struck can anyone point out what am i doing wrong ?
first two testcases passed ..
Norvin Burrus
@ndburrus
Jun 02 2016 03:27
@asma8867 it looks like it does meet this condition: lookUpProfile("Bob", "number"); return => 'No such contact'
Asma
@asma8867
Jun 02 2016 03:28
@Santosh456 I am not looking for some one else solution, I want to learn how to deal with my own code.
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 03:28
ok
Asma
@asma8867
Jun 02 2016 03:29
@ndburrus is it possible for you to give me more clear clue?
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:29
somebody help me
Norvin Burrus
@ndburrus
Jun 02 2016 03:29
@asma8867 oops, checked wrong code... moment...
Shusil Banjade
@shusil123
Jun 02 2016 03:29
@keshav929 , See .Boolean in MDN. The simple solution for that problem would be : return arr(Boolean);
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:31
ok ..
Shusil Banjade
@shusil123
Jun 02 2016 03:32
@keshav929 , arr.filter(Boolean); , would do the work
bitgrower
@bitgrower
Jun 02 2016 03:33
@asma8867 -- no such contact is not going to work until you take it out of your loop -- your loop must examine all the elements of the array before you actually know if there is "no such contact" ...
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:33
@asma8867 see for first iteration suppose your result variable is false , it will check the if condition and enters the else block and return the false. it will never be able to traverse the whole set of values .. to determine the solution.
Norvin Burrus
@ndburrus
Jun 02 2016 03:34
This message was deleted
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:34
thanks @shusil123
CamperBot
@camperbot
Jun 02 2016 03:34
keshav929 sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles:
:cookie: 308 | @shusil123 |http://www.freecodecamp.com/shusil123
Alexander Køpke
@alexanderkopke
Jun 02 2016 03:34
@keshav929 the filter function won't return falsies. So if you make a simple callback and return the value it will work out I think
Shusil Banjade
@shusil123
Jun 02 2016 03:34
Anytime , @keshav929
Norvin Burrus
@ndburrus
Jun 02 2016 03:37
@asma8867 ok, 3rd times a charm... :) the prop check should follow the firstName check. the if result===true){ can be removed. go straight into a check for prop... if prop does exist, retur firstName & prop... can you get there?
KESHAV KUNDAL
@keshav929
Jun 02 2016 03:37
ok @alexanderkopke let me try and will let you know
Xavier Velez
@JonSnow08
Jun 02 2016 03:41
@ndburrus hey man, how are you tonight?
Norvin Burrus
@ndburrus
Jun 02 2016 03:42
@JonSnow08 i'm doing good :+1: , and you??
Xavier Velez
@JonSnow08
Jun 02 2016 03:42
i'm good thanks
Norvin Burrus
@ndburrus
Jun 02 2016 03:43
@JonSnow08 i think you made some good progress the last couple of days?
Xavier Velez
@JonSnow08
Jun 02 2016 03:43
just struggled my way through seek and destroy, got it done with some help but I'm still trying to figure out if I can understand it
haha thank you I got through like 3 bonfires without asking for help but this last one destroyed my confidence
Norvin Burrus
@ndburrus
Jun 02 2016 03:45
you're a bit ahead of me. i need to put some work in tomorrow... that's great - 3 challenges in a short period of time... :)
Xavier Velez
@JonSnow08
Jun 02 2016 03:47
@ndburrus I had today off so I got to spend the whole day on here
Norvin Burrus
@ndburrus
Jun 02 2016 03:47
@JonSnow08 ...lol - that helps... i barely kept my streak alive today.... had to jump ahead to some other challenges...
Alexander Køpke
@alexanderkopke
Jun 02 2016 03:47
@keshav929 Shusil's method will work too. The filter method only passes the elements to the returned array if the code inside the parenthesis is true:
arr.filter(returns element if code inside here evaluates to true); It can be done with the Boolean method as Shusil suggests or it can be done by a simple function that returns the value it has as a parameter. return arr.filter(function(value){ return value;} This will confront the filter method directly with was it passed to it and in case of falsies it is rejected.
Marco Novaes
@marco-novaes
Jun 02 2016 03:48
Hello everyone i get stuck on the using objects for lookups

Here is my code // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
var lookup = {
"alpha":
result = "Adams",
"bravo":
result = "Boston",

 "charlie": 
  result = "Chicago",  

 "delta": 
  result = "Denver",

 "echo": 
  result = "Easy",

 "foxtrot": 
  result = "Frank"

};

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

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

Angelo Ryndon
@AIRyndon
Jun 02 2016 03:49

Hello Everyone! Does someone have a better solution for Diff Two Arrays? Here's mine -

function diffArray(arr1, arr2) {
  var newArr = [];
  var temp1 = [];
  var temp2 = [];
  // Same, same; but different.
   function removeCopiesOne(value,index,arr)
  {
    for(var i = 0; i < arr2.length;i++)
    {
      if (value === arr2[i])
        return false;
    }
    return true; 
  }

  function removeCopiesTwo(value)
  {
    for(var i = 0; i < arr1.length;i++)
    {
      if (value === arr1[i])
        return false;
    }
    return true; 
  }

   temp1 = arr1.filter(removeCopiesOne);
   temp2 = arr2.filter(removeCopiesTwo);
   newArr = temp1.concat(temp2);

  return newArr;
}

diffArray([1, 2, 3, 5], [0, 0, 0, 0,]);

Basically I'm looking for a way to have the filter function more generic...I keep getting type errors..Insight is much appreciated

Norvin Burrus
@ndburrus
Jun 02 2016 03:50
@marco-novaes ...follow thr example code format. hint: why are there result assignments in var lookup? :)
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 03:50

function rot13(str) 
{ // LBH QVQ VG!

  var arr =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  arr=arr.join("");
  var str1=[];
  var ctr=0;

  for(i=0;i<str.length;i++)
  {
    //console.log("str[i] is "+str[i]);
    for(j=0;j<arr.length;j++)
    {  
    if (str.charCodeAt(i)===arr.charCodeAt(j) && str.charCodeAt(i)<=77 && str.charCodeAt(i)>=65)
    {
        //str1[ctr]=(str.charCodeAt(i+13)).fromCharCode();
      console.log("arr[j]="+arr[j]);
      console.log("arr[j+13]="+arr[j+13]);
       str1[ctr]=arr[j+13];
       ctr++;

    }
    else if (str.charCodeAt(i)===arr.charCodeAt(j)&& str.charCodeAt(i)>77 && str.charCodeAt(i)<=90)
    {
      console.log("arr[j]="+arr[j]);
      console.log("arr[j-13]="+arr[j-13]);
      str1[ctr]=arr[j-13];
      ctr++;
    }       
    else
    {
      console.log("str[i]="+str[i]);
      console.log("str[i]="+str[i]);
      str1[ctr]=str[i];
      ctr++;     
    }        
    }
  }  
  str1=str1.join("");  
  return str1;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Hello everyone
Xavier Velez
@JonSnow08
Jun 02 2016 03:51
hey @sudeepnarkar
tommy
@tommygebru
Jun 02 2016 03:51
This message was deleted
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 03:51
Can anyone take a look at my code? This is Caeser Cipher
Angelo Ryndon
@AIRyndon
Jun 02 2016 03:51
No one has done Diff Array here :(
Xavier Velez
@JonSnow08
Jun 02 2016 03:52
@AIRyndon I'm sorry I'm not that far yet
tommy
@tommygebru
Jun 02 2016 03:52

http://codepen.io/gebrutommy/pen/xVZOgg?editors=0010

Please leave a comment and feedback :smile:

Angelo Ryndon
@AIRyndon
Jun 02 2016 03:52
@sudeepnarkar I have done that too few weeks ago..is it working?
@tommygebru looks very nice tommy...mine is very bland..I just wanted it to work. hahaha..I truly am not a designer
Stevie Jay
@stephenhuh
Jun 02 2016 03:54

var digits = "B2";
var re = new RegExp("/\d+/");
console.log(/\d+/.test("123"));
console.log("digits matches to :", digits.match(re));

why does digits.match(re) return NULL whereas the .test returns true?

Sudeep Narkar
@sudeepnarkar
Jun 02 2016 03:54
@AIRyndon Hi. No, it is not working. It is matching all the characters. It is working for characters except special characters.
Angelo Ryndon
@AIRyndon
Jun 02 2016 03:55
@sudeepnarkar I see...Are you ok with me posting my solution here?
@sudeepnarkar Try to use .fromCharCode
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 04:01
@AIRyndon Hmm. Let me give it a try.
I will PM you if I RUN INTI ANY ISSUES.
Michael J Cooper
@ballermjc
Jun 02 2016 04:01

anyone have an idea of how to get this loop to actually loop. I know the problem is that it is returning after only checking the first element...

for (var i = 0; i < second.length; i++) {
if (first.indexOf(second[i]) == -1) {

  return false;
}
return true;

}

Sudeep Narkar
@sudeepnarkar
Jun 02 2016 04:01
*run into any issues. Sorry for caps.
Marco Novaes
@marco-novaes
Jun 02 2016 04:04
@ndburrus Thanks
CamperBot
@camperbot
Jun 02 2016 04:04
marco-novaes sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:cookie: 481 | @ndburrus |http://www.freecodecamp.com/ndburrus
Sanzhar Askaruly
@askaruly
Jun 02 2016 04:05
in Record Collection need help.
My code is:

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

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

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

Andrew Johnston
@puchamungee
Jun 02 2016 04:06
hi all, I’m working on the wikipedia viewer and I’m transitioning the buttons to the top of the screen when text is entered, and looking to move it back to normal if the next is removed. I tried using .removeData() but it looks like it’s not working. Any thoughts?
https://codepen.io/puchamungee/pen/PzwWbj/
tommy
@tommygebru
Jun 02 2016 04:10

@askaruly
For the given id parameter, which is associated to the collection object:

If the value parameter isn't an empty string, update (or set) the value parameter for the prop parameter

If the prop parameter is equal to "tracks" and the value isn't an empty string, push the value parameter onto the end of the tracks array within the collection object

If value is an empty string, delete that prop from the object

Finally, return the collection object

@AIRyndon thanks it didnt take too much time, just try to have fun with it.... Rick & Morty is one of my favorite shows! so I it didnt feel like work :wink2:
Ogundele Olumide
@Lumexralph
Jun 02 2016 04:26
This message was deleted
Asma
@asma8867
Jun 02 2016 04:29
@Santosh456 sorry are you there? I have just checked your code, and I can not figure it out. I think for "No such contact" condition, your response does not even iterate through the array. Could you please explain it more for me ?
David
@davidmichaelhale
Jun 02 2016 04:33
Hey guys, I'm doing the Random Quote Machine exercise and cant seem to figure out why my getQuote() function is returning the same quote each time.
Chase
@Belax8
Jun 02 2016 04:34
@davidmichaelhale what does your code look like? can you share the codepen link?
When I put "http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=" into my browsers address bar each time I refresh a new quote shows up, but when I run it on codepen it just shows the same quote each time.
Chase
@Belax8
Jun 02 2016 04:39
I'm not even seeing a quote. . .
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:39
@davidmichaelhale cache?
Michael
@michaeldiegogil
Jun 02 2016 04:40
someone please help
Return Early Pattern for Functions
``js

// Setup
function abTest(a, b) {
  // Only change code below this line

    if (a, b < 0) {
  return ;
}


  // 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);
idk what im dooing wrong.
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:40
@davidmichaelhale $.ajaxSetup({cache:false}); before calling getJSON?
SirSpectre22
@SirSpectre22
Jun 02 2016 04:41
@davidmichaelhale I looked at the request in dev tools and its being cached so it isn't returning any new quotes
David
@davidmichaelhale
Jun 02 2016 04:42
@kutsuya1 That did it! I didn't realize it was caching it.
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:43
@michaeldiegogil `if (a,b < 0) looks strange ... you may have to check a and then b
@davidmichaelhale yep, took a bit of research. heh
David
@davidmichaelhale
Jun 02 2016 04:44
First time I've used ajax and getJSON, spent a few hours rewriting it over and over thinking I must have done something wrong. Thanks again @kutsuya1 @SirSpectre22
CamperBot
@camperbot
Jun 02 2016 04:44
davidmichaelhale sends brownie points to @kutsuya1 and @sirspectre22 :sparkles: :thumbsup: :sparkles:
:cookie: 374 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
:cookie: 208 | @sirspectre22 |http://www.freecodecamp.com/sirspectre22
Alexander Køpke
@alexanderkopke
Jun 02 2016 04:44
@AIRyndon been some time since I did it the last time. It did take some time to figure it out again. I don't think I used this method that last time. I will post the solution I came up with. I don't know if it is better. If something works I think that is the most important thing.
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:44
@davidmichaelhale same here. Glad to help
Alexander Køpke
@alexanderkopke
Jun 02 2016 04:44
function diffArray(arr1, arr2) {
  var newArr = [];
  // Same, same; but different.
  var merged=arr1.concat(arr2);


 merged.map(function(value){
   if(arr1.indexOf(value) === -1 ){
     newArr.push(value);
   }
   if(arr2.indexOf(value) === -1 ){
     newArr.push(value);
   }

 });

  return newArr;
}
SirSpectre22
@SirSpectre22
Jun 02 2016 04:46
@davidmichaelhale or you can just have
$.ajax( { url: "your url", cache: false, success: function(data) {} });
for single requests
And I am glad to help
Ogundele Olumide
@Lumexralph
Jun 02 2016 04:47

Record Collection
`// 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) {
for(var i in collection) {
if (collection[id] !== "tracks" && collection[id][prop] !== "") {
collection[id][prop] = value;
}

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

return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "");`
please what am am getting wrong here, i got the desired result but the test is not passing

Jason Shoemaker
@kutsuya1
Jun 02 2016 04:49
@Lumexralph for (var i in collection) then you use collection[id] id and not i?
Ogundele Olumide
@Lumexralph
Jun 02 2016 04:50
okay @kutsuya1 let me try that out
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:52
@Lumexralph maybe you don't need a for loop?
Ogundele Olumide
@Lumexralph
Jun 02 2016 04:52
i thought so too @kutsuya1
just trying to see what works
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:53
@Lumexralph When you didn't have the for loop, what was the problem?
Ogundele Olumide
@Lumexralph
Jun 02 2016 04: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 (collection[id] !== "tracks" && collection[id][prop] !== "") {
collection[id][prop] = value;
}

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

return collection;
}

// Alter values below to test your code
updateRecords(2548, "tracks", "");
`

this is without the for loop, still not getting it passed @kutsuya1
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:55
@Lumexralph check first if value !== ''
@Lumexralph otherwise it could save an empty value
Ogundele Olumide
@Lumexralph
Jun 02 2016 04:56
should " " and ' ' be different ? I thought they do same thing except used together @kutsuya1
i will try it
Jason Shoemaker
@kutsuya1
Jun 02 2016 04:57
@Lumexralph they are basically the same.... "" can process escapes and '' can not
Sanzhar Askaruly
@askaruly
Jun 02 2016 04:59
@Lumexralph
try if instead of else if
Ogundele Olumide
@Lumexralph
Jun 02 2016 05:00
okay @askaruly
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:00
also
Xander Apponi
@xapponi
Jun 02 2016 05:00

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

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

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

Sanzhar Askaruly
@askaruly
Jun 02 2016 05:00
instead of collection[id].tracks.push(value); try collection[id]["tracks"].push(value);
@Lumexralph
Xander Apponi
@xapponi
Jun 02 2016 05:01

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

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

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

GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:01
Hey..
Maybe I'm being stupid, but I can't seem to figure this out
Xander Apponi
@xapponi
Jun 02 2016 05:01
whoops sorry
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:01
@xapponi
have a look for @Lumexralph code
above
Ogundele Olumide
@Lumexralph
Jun 02 2016 05:02
okay, working on it but why did you suggest that way? @askaruly
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:02

var myStr = '<a href="http://www.example.com" target="_blank">Link</a>"'

I have to remove all backslashes, have two single quotes, and four double quotes, and only remove the backslashes that escape quotes. It's making me upset.

oh whoops, not that one
var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:02
if (value !== '') {
} else {
  delete collection[id][prop];
}
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:02
@Lumexralph i also had that problem
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:02
This one, I'm trying to figure out what I did wrong. I removed all the backslashes that were used to escape the quotes, being the ones aroudn the URL, replaced them with a single quote,
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:03
do not use else
@GlitterFairyLilo
just use if everywhere
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:03
I did, and it didn't work
Says I need to have two single quotes, and four double quotes
meaning I have to do it in one place only
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:03
@askaruly I did
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:04
if (value !== '') {
  delete collection[id][prop];
}
@kutsuya1
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:04
@askaruly so if you have a value, delete it?
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:04
what's that?
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
}
if (prop === "tracks" && value !== "") {
collection[id]["tracks"].push(value);
}
if (value === "") {
delete collection[id][prop];
}
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:05
@askaruly what do you mean use it everywhere when I did do that and it did nothing
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:05
this worked fine for me
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:05
function updateRecords(id, prop, value) {
  if (value !== '') {
    if (prop !== "tracks") {
      collection[id][prop] = value;
    } else {
       collection[id][prop].push(value);
    }
  } else {
    delete collection[id][prop];
  }

  return collection;
}
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:06
function updateRecords(id, prop, value) {
  if (value !== "" && prop !== "tracks") {
    collection[id][prop] = value;
  }
  if (prop === "tracks" && value !== "") {
    collection[id]["tracks"].push(value);
  }
  if (value === "") {
    delete collection[id][prop];
  }
  return collection;
}
@kutsuya1 @xapponi @GlitterFairyLilo @Lumexralph
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:07
many ways to do it, yes?
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:07
yes, but you cannot use 'else' two times
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:07
totally different thing from what I was doing
nevermind
David
@davidmichaelhale
Jun 02 2016 05:08
@askaruly the elses are part of different if statements
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:08
:)
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:08
so.. yeah. so different problem.
Sanzhar Askaruly
@askaruly
Jun 02 2016 05:08
oh yeah
sorry
Ogundele Olumide
@Lumexralph
Jun 02 2016 05:08
thanks guys, pretty close, passed all except one
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:08

var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";

it's telling me to remove all the backslashes, have two single quotes and four double quotes, and only remove the backslashes that are used to escape the quotes

Now, I'm removing all the backslashes, right, and they're all used to escape the quotes, so I should at least get two out of three passed, but it's not doing that
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:09
@askaruly No problems... The test is true or false..... if true, else false
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:10
...
Could someone help me out? ;c
David
@davidmichaelhale
Jun 02 2016 05:13
@GlitterFairyLilo
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:13
oh my god.
I did that too, and it didnt work
like at all
So single quotes can be used to start a string too?
I'm really mad.
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:14
@GlitterFairyLilo why, you learned something you probably won't forget soon.
GlitterFairyLilo
@GlitterFairyLilo
Jun 02 2016 05:15
because I did that earlier and it didn't work.
And yeah, I probably wont forget that at all, actually
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:16
I spent a couple of days trying to figure out why I couldn't use an api... I decided to use https://codepen.io thought it more secure. heh
one little letter.. 's' caused two days of pain
but I learned
David
@davidmichaelhale
Jun 02 2016 05:17

var myStr = '<a href="http://www.example.com" target="_blank">Link</a>"'

I have to remove all backslashes, have two single quotes, and four double quotes, and only remove the backslashes that escape quotes. It's making me upset.
looks like you have an extra double quote in there before the final single quote

Sudeep Narkar
@sudeepnarkar
Jun 02 2016 05:17

function rot13(str) 
{ // LBH QVQ VG!

  var arr =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  arr=arr.join("");
  var str1=[];
  var ctr=0;
  var ctr1;

  for(i=0;i<str.length;i++)
  {
    //console.log("str[i] is "+str[i]);


    for(j=0;j<arr.length;j++)
    {  
    if (str.charCodeAt(i)===arr.charCodeAt(j) && str.charCodeAt(i)<=77 && str.charCodeAt(i)>=65)
    {
        //str1[ctr]=(str.charCodeAt(i+13)).fromCharCode();
      console.log("arr[j]="+arr[j]);
      console.log("arr[j+13]="+arr[j+13]);
       str1[ctr]=arr[j+13];
       ctr++;

    }
    else if (str.charCodeAt(i)===arr.charCodeAt(j)&& str.charCodeAt(i)>77 && str.charCodeAt(i)<=90)
    {
      console.log("arr[j]="+arr[j]);
      console.log("arr[j-13]="+arr[j-13]);
      str1[ctr]=arr[j-13];
      ctr++;
    }       
    else if(str.charCodeAt(i)<65 && str.charCodeAt(i)>90)
    {

      console.log("str[i]="+str[i]);
      console.log("str[i]="+str[i]);
      str1[ctr]=str[i];
      ctr++;   
    }        
    }
  }  
  str1=str1.join("");  
  return str1;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Can anyone take a look?
This is Caeser Cipher.
It is converting properly but not printing special characters
like whitespace,? etc
Markus Kiili
@Masd925
Jun 02 2016 05:20
@sudeepnarkar You can do it without listing all the mapped characters. Loop the characters of the string, check if the charcode is on the range A-Z, and do the mapping if it is.
David
@davidmichaelhale
Jun 02 2016 05:20
@sudeepnarkar
first thing i noticed is should be str[i].charCodeAt(), not str.charCodeAt(i), etc.
Markus Kiili
@Masd925
Jun 02 2016 05:22
@davidmichaelhale Both work if str is a string.
David
@davidmichaelhale
Jun 02 2016 05:22
ah, i didn't know that
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 05:24

function rot13(str) 
{ // LBH QVQ VG!

  var arr =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  arr=arr.join("");
  var str1=[];
  var ctr=0;
  var ctr1;

  for(i=0;i<str.length;i++)
  {
    //console.log("str[i] is "+str[i]);


    for(j=0;j<arr.length;j++)
    {  
    if (str.charCodeAt(i)===arr.charCodeAt(j) && str.charCodeAt(i)<=77 && str.charCodeAt(i)>=65)
    {
        //str1[ctr]=(str.charCodeAt(i+13)).fromCharCode();
      console.log("arr[j]="+arr[j]);
      console.log("arr[j+13]="+arr[j+13]);
       str1[ctr]=arr[j+13];
       ctr++;
       break; 
    }
    else if (str.charCodeAt(i)===arr.charCodeAt(j)&& str.charCodeAt(i)>77 && str.charCodeAt(i)<=90)
    {
      console.log("arr[j]="+arr[j]);
      console.log("arr[j-13]="+arr[j-13]);
      str1[ctr]=arr[j-13];
      ctr++;
      break;
    }       
    else if(arr.indexOf(str[i])===-1)
    {

      console.log("str[i]="+str[i]);
      console.log("str[i]="+str[i]);
      str1[ctr]=str[i];
      ctr++;
      break;
    }        
    }
  }  
  str1=str1.join("");  
  return str1;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Thanks guys
It worked.
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:25
@sudeepnarkar might look at String.fromCharCode() sometime
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 05:25
Just had to another condition to check of the character i s not in the array
Not the best of solutions but I did not use String.fromCharCode()
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:26
@sudeepnarkar here is what I ended up with:
function rot13(str) { // LBH QVQ VG!
  var decoded = "";
  for (var i in str) {
    if (str[i] < 'A' || str[i] > 'Z') {
      decoded += str[i];
      continue;
    }

    var charCode = str.charCodeAt(i) - 13;
    // wrap around
    if (charCode < 'A'.charCodeAt(0)) {
      charCode = 'Z'.charCodeAt(0) - ('A'.charCodeAt(0) - charCode - 1) ;
    }
    decoded += String.fromCharCode(charCode);
  }
  return decoded;
}
Markus Kiili
@Masd925
Jun 02 2016 05:28
@sudeepnarkar There is even a one-liner solution, meaning you have too much code there. You don't need the array of A-Z, because you can and do check the charcode ranges.
Sudeep Narkar
@sudeepnarkar
Jun 02 2016 05:28
@kutsuya1 That's an elegant solution
David
@davidmichaelhale
Jun 02 2016 05:28

silly question, how are you posting code to chat like that as opposed to
function rot13(str) {

}
etc etc

Sudeep Narkar
@sudeepnarkar
Jun 02 2016 05:28
explain format
CamperBot
@camperbot
Jun 02 2016 05:28

: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

Jason Shoemaker
@kutsuya1
Jun 02 2016 05:28
@sudeepnarkar There is probably shorter ones, but I can follow it by eye. Thanks
CamperBot
@camperbot
Jun 02 2016 05:28
kutsuya1 sends brownie points to @sudeepnarkar :sparkles: :thumbsup: :sparkles:
:cookie: 267 | @sudeepnarkar |http://www.freecodecamp.com/sudeepnarkar
Markus Kiili
@Masd925
Jun 02 2016 05:29
@kutsuya1 for...in loop is not meant for looping over array or string indices. Simple for loop is better.
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:30
@Masd925 Have an example?
David
@davidmichaelhale
Jun 02 2016 05:30
function rot13(str) { // LBH QVQ VG!
  str=str.split('');
  for (var i = 0; i < str.length; i++) {
    if (str[i].charCodeAt() >= 65 && str[i].charCodeAt() <= 91) {
      if (str[i].charCodeAt() <= 77)
        str[i]=String.fromCharCode(str[i].charCodeAt()+13);
      else
        str[i]=String.fromCharCode(str[i].charCodeAt()-13);
    }
  }
  return str.join('');
}
Markus Kiili
@Masd925
Jun 02 2016 05:30
@kutsuya1 Of the problems?
David
@davidmichaelhale
Jun 02 2016 05:30
ah, i figured out how to post code to chat. thanks @camperbot
CamperBot
@camperbot
Jun 02 2016 05:30
davidmichaelhale sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star2: 1821 | @camperbot |http://www.freecodecamp.com/camperbot
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:31
@Masd925 for loop
@davidmichaelhale too many 'magic' numbers
Markus Kiili
@Masd925
Jun 02 2016 05:31
@kutsuya1 for(var i=0;i<str.length;i++){...}
David
@davidmichaelhale
Jun 02 2016 05:32
was mainly for the purpose of figuring out how to post code to chat correctly
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:33
@davidmichaelhale opps, sorry
Michael
@michaeldiegogil
Jun 02 2016 05:33
Help, counting cards is kicking my butt! please
CamperBot
@camperbot
Jun 02 2016 05:33
no wiki entry for: counting cards is kicking my butt please
David
@davidmichaelhale
Jun 02 2016 05:33
lol its k, i did that exercise rather quickly and could have made it more readable
Michael
@michaeldiegogil
Jun 02 2016 05:33

var count = 0;

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

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

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(7); cc('Q'); cc(8); cc('A');
Markus Kiili
@Masd925
Jun 02 2016 05:34
@sudeepnarkar You can do the mapping with one remainder operation:
function rot13(str) {
  return str.split("").map(function(char){
      var cc=char.charCodeAt(0);
      return (cc>64 && cc<91) ? String.fromCharCode(cc%26+65) : char;
  }).join("");
}
@michaeldiegogil You should change count based on the passed card. Then figure out the return value based on count.
@michaeldiegogil You cannot figure out the return value from the card.
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:36
@Masd925 Thanks for bringing up the problem of for-in. I see that for-of is better.
CamperBot
@camperbot
Jun 02 2016 05:36
kutsuya1 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1686 | @masd925 |http://www.freecodecamp.com/masd925
Michael
@michaeldiegogil
Jun 02 2016 05:36
whats the passed card
Markus Kiili
@Masd925
Jun 02 2016 05:36
@michaeldiegogil card
Vinay Jaju
@vinay-jaju
Jun 02 2016 05:37

Help in seek and destroy

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

Please give me an idea how to proceed

CamperBot
@camperbot
Jun 02 2016 05:37
no wiki entry for: in seek and destroy destroyer1 2 3 1 2 3 2 3please give me an idea how to proceed
Michael
@michaeldiegogil
Jun 02 2016 05:37
@vinay-jaju make another array
Vinay Jaju
@vinay-jaju
Jun 02 2016 05:38
and
?
David
@davidmichaelhale
Jun 02 2016 05:38

```js

var count = 0;

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

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

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

Jason Shoemaker
@kutsuya1
Jun 02 2016 05:38
@vinay-jaju look at the helpful links on that task...: Arguments object, & Array.filter()
Michael
@michaeldiegogil
Jun 02 2016 05:39
@Masd925 okay so is the cases correct, or do i need to add if statments
Markus Kiili
@Masd925
Jun 02 2016 05:39
@kutsuya1 for...of is ES6 and you probably cannot use it in any production code yet, because people use old browsers a lot. Depends on the sector and in couple of years it might be usable.
Ankur sharma
@ankur1163
Jun 02 2016 05:39
guys I did it. I got front end certificate . I am very happy
David
@davidmichaelhale
Jun 02 2016 05:39
@michaeldiegogil
I kind of hit enter prematurely there, but you get the idea.
Ankur sharma
@ankur1163
Jun 02 2016 05:39
I want to thank you all of you. Random people helped me in my journey
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:39
@Masd925 ah... the page I'm reading didn't mention that. <sigh>
Ankur sharma
@ankur1163
Jun 02 2016 05:40
special thanks to @sjames1958gm @Masd925
CamperBot
@camperbot
Jun 02 2016 05:40
ankur1163 sends brownie points to @sjames1958gm and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1422 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1687 | @masd925 |http://www.freecodecamp.com/masd925
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:40
@ankur1163 congrats! :+1:
David
@davidmichaelhale
Jun 02 2016 05:40
@ankur1163 congrats :clap:
Ankur sharma
@ankur1163
Jun 02 2016 05:40
I am pretty sure, i am forgetting lot of ids.
But, thansk for supporting me. :)
now on to sass, react , d3 part
I am so happy. this channel is amazing. you guys are amazing
Markus Kiili
@Masd925
Jun 02 2016 05:41
@ankur1163 Great!
Ankur sharma
@ankur1163
Jun 02 2016 05:41
thanks @kutsuya1 and @davidmichaelhale
CamperBot
@camperbot
Jun 02 2016 05:41
ankur1163 sends brownie points to @kutsuya1 and @davidmichaelhale :sparkles: :thumbsup: :sparkles:
:cookie: 275 | @davidmichaelhale |http://www.freecodecamp.com/davidmichaelhale
:cookie: 375 | @kutsuya1 |http://www.freecodecamp.com/kutsuya1
Michael
@michaeldiegogil
Jun 02 2016 05:42
@davidmichaelhale what about "bet" and "hold"
David
@davidmichaelhale
Jun 02 2016 05:42
@michaeldiegogil
if statement after the switch
Jason Shoemaker
@kutsuya1
Jun 02 2016 05:43
@ankur1163 Just keep at it. :)
David
@davidmichaelhale
Jun 02 2016 05:43
@michaeldiegogil
if count is positive return bet, if count is negative or zero return hold
Ankur sharma
@ankur1163
Jun 02 2016 05:43
yes sir @kutsuya1 :)
Michael
@michaeldiegogil
Jun 02 2016 05:46
  count++;
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
     card = ("Bet");
      break;
like this?
Santosh Kumar Toleti
@Santosh456
Jun 02 2016 05:46
@asma8867 yeh sure
u there
Michael
@michaeldiegogil
Jun 02 2016 05:50
how do i write an if statment for this
the replacement if statment or the regualr one
David
@davidmichaelhale
Jun 02 2016 05:51
function cc(card) {
  // Only change code below this line
  switch (card) {
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      count++;
      break;
    case 7:
    case 8:
    case 9:
      break;
    case 10:
    case 'J':
    case 'Q':
    case 'K':
    case 'A':
      count--;
      break;
  }

  if (count > 0)
    return count+" Bet";
  else
    return count+" Hold";
  // Only change code above this line
}
Vinay Jaju
@vinay-jaju
Jun 02 2016 05:54
@kutsuya1 I looked onto the links..but couldnt make anything out of it!
Markus Kiili
@Masd925
Jun 02 2016 05:56
@vinay-jaju arr is the passed array. arguments[1], arguments[2]... are the extra arguments that you need to remove from arr. Make a result array and loops (you can use arguments.length), or use methods like .filter().
Angelo Ryndon
@AIRyndon
Jun 02 2016 06:06
@alexanderkopke I just came home from work. Your solution looks cleaner :). I was trying to parameratize a function generically in C#..I'm guessing javascript hates that, I keep getting type errors and stuff
Rajat Kumar Sinha
@sinharajatit
Jun 02 2016 06:23
@jedpimentel if you can see, the last three conditions are similar. My code is working for the first of last three condition: myBike.getGear() should return 4 after calling myBike.setGear(4). but it is not working for the last two.
Vivek
@vivek28111992
Jun 02 2016 06:26
@Masd925
I want to loop through array, such that it should check first condition and push the true elements in new array first and later second condition and push other elements , can I do this looping once or I will have to loop twice?
Rajat Kumar Sinha
@sinharajatit
Jun 02 2016 06:28
@Masd925 you can use two if condition(nested if) inside your single for loop.
@vivek28111992 you can use two if condition(nested if) inside your single for loop.
Elias Lawson-Fox
@eliaslfox
Jun 02 2016 06:33
I'm trying to solve truncate a string in the algorathem challenges section, my code is as follows...
function truncateString(str, num) {
  if (num <= 3) num+=3;
  return str.split('').map((v, i) => {
    if (i >= num-3) return '';
    return v;
  }).join('') + '...';
}
Which works except it fails on two tests, which seem functionally identical to the other ones
Any help would be greatly appreciated
Oh it fails on tests 3 and 4
Rajat Kumar Sinha
@sinharajatit
Jun 02 2016 06:41
@jedpimentel thanks sir. :thumbsup:
CamperBot
@camperbot
Jun 02 2016 06:41
sinharajatit sends brownie points to @jedpimentel :sparkles: :thumbsup: :sparkles:
:star2: 1026 | @jedpimentel |http://www.freecodecamp.com/jedpimentel
Dan
@dcgoings
Jun 02 2016 06:49

hey guys. just had a quick question regarding the Stand In Line challenge.

function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}

this appears to be the simplest way to do it. but now im wondering.. what if i instead did

var removed = arr.shift();

and then returned remove? there are no issues here, right?

reason im asking is because when i first tried, i was attempting to do:

arr.push(item);
arr.shift();
return arr.shift();

but i guess that means it's shifting twice instead of once. just want to make sure im understanding all of this correctly. i think im good, just want another to confirm. :)

Vivek
@vivek28111992
Jun 02 2016 06:50
@sinharajatit if else won't work in single loop
Rajat Kumar Sinha
@sinharajatit
Jun 02 2016 06:51
@vivek28111992 use nested if only. No need of else condition.
Vivek
@vivek28111992
Jun 02 2016 07:00
@sinharajatit ok
Joseph
@revisualize
Jun 02 2016 07:05
@dcgoings The function code is how you do that challenge.
Markus Kiili
@Masd925
Jun 02 2016 07:14
@dcgoings You can store the removed item and then return it if you like.
Dan
@dcgoings
Jun 02 2016 07:17

@Masd925 which would be:

var removed = arr.shift();
return removed;

right?

Markus Kiili
@Masd925
Jun 02 2016 07:17
@dcgoings Yes.
Dan
@dcgoings
Jun 02 2016 07:17
perfect. just wanted to make sure i was on the right track :)
thanks
Joseph
@revisualize
Jun 02 2016 07:19
Don't do that though. That's silly.
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}
That is the solution that I have.
It's silly to set a variable to just return the variable.
Markus Kiili
@Masd925
Jun 02 2016 07:21
@revisualize He was asking if that can be done, or are there issues. No issues, but better without extra variables.
Joseph
@revisualize
Jun 02 2016 07:22
Okay, I misread. Please disregard.
Ahmad Jamaly Rabib
@rabibsust
Jun 02 2016 07:27
Slasher Flick problem:
My code is working but I am confused about it
function slasher(arr, howMany) {
// it doesn't always pay to be first
var newarr = arr.slice(0,howMany);
var newarrlen = newarr.length;
var retarr;
if(newarrlen !== 0) {
retarr = arr.splice(newarrlen, howMany+1);
}
else {
retarr = arr;
}
return retarr;
}
Markus Kiili
@Masd925
Jun 02 2016 07:28
@rabibsust You only need to return the result of one array method call, if you choose the right method. You have the right method there ;)
Ahmad Jamaly Rabib
@rabibsust
Jun 02 2016 07:29
@Masd925 Yeah code is working.But I am confused how the array.splice is working here.
Markus Kiili
@Masd925
Jun 02 2016 07:31
@rabibsust Your first line of code is enough if you change it a little bit and return it.
Ahmad Jamaly Rabib
@rabibsust
Jun 02 2016 07:31
@Masd925 Okay I am checking. Thanks :)
Chris Cullen
@123xylem
Jun 02 2016 07:35
Quick Question: Can someone tell me what my error is?
function translatePigLatin(str) {
  str.split("");
  for(i=0;i<str.length;i++){
    if(str[i]!= /^[aeiou]/i){
   str=   str.split(str[i]).join("")+"ay" ;

    }
    else if (str.charAt(0)==/[aeiou]/i){
    str=  str.split().join("")  +"way";
    }

  return str;}
}

translatePigLatin("aonsonant");
Sarkunan V (Rax)
@raxIsBlur
Jun 02 2016 07:38
@123xylem hmm the str.split("") results are not being saved anywhere?
Chris Cullen
@123xylem
Jun 02 2016 07:39
@raxIsBlur what do u mean? Is .split removing the relevant data and Im forgetting to get the bit it splits out?
Sarkunan V (Rax)
@raxIsBlur
Jun 02 2016 07:39
try var arr = str.split(""); then iterating through arr
split returns a new array, but its not being saved anywhere according to the code
Markus Kiili
@Masd925
Jun 02 2016 07:41
@123xylem You can just do: str=str.split(""); , although str is not a very good name for an array.
Chris Cullen
@123xylem
Jun 02 2016 07:41
@raxIsBlur @Masd925 ye
hmm now it sats str.split is not a function
says
Sarkunan V (Rax)
@raxIsBlur
Jun 02 2016 07:48
at which line does it say so ?
@123xylem
Chris Cullen
@123xylem
Jun 02 2016 07:49
first
Sarkunan V (Rax)
@raxIsBlur
Jun 02 2016 07:49
if you did str = str.split(""), possibly at line 5 and 9 it might cause an error but not entirely sure
cause str wouldn't be a string at this point and .split can't be applied there
Chris Cullen
@123xylem
Jun 02 2016 07:49
I guess 5 and 9 then as ive redid the code and it str=str.split works
Sarkunan V (Rax)
@raxIsBlur
Jun 02 2016 07:50
well test it out :P trying using a different variable name for results after you split the string
try using*
Rahul Nayak
@pragyes31
Jun 02 2016 07:51
Hello Campers, ran into an interesting problem.
```
var kuch = +"dude";
undefined
kuch;
NaN
typeof kuch;
"number"
why typeof kuch is returning number ?
I was trying these in chrome console
Ade
@hello-ade
Jun 02 2016 07:54
@asma8867
96street
@96street
Jun 02 2016 07:56
does anyone have a good quotes API?
Ade
@hello-ade
Jun 02 2016 07:57
@asma8867
 var result ='';

    for (var i = 0; i < contacts.length; i++) {
     if(contacts[i].firstName === firstName){

            if(contacts[i].hasOwnProperty(prop)){
                return contacts[i][prop];
            }else {
                return'No such property';
            }

        }else {
            result = 'No such contact';
        }
    }
DJ
@qualitymanifest
Jun 02 2016 07:57
@pragyes31 type of NaN is number. why'd you put the + in there? im not positive but i'm guessing it sees the + and tries to do an equation.
Asma
@asma8867
Jun 02 2016 07:59
@hello-ade thanks
CamperBot
@camperbot
Jun 02 2016 07:59
asma8867 sends brownie points to @hello-ade :sparkles: :thumbsup: :sparkles:
:cookie: 238 | @hello-ade |http://www.freecodecamp.com/hello-ade
Chris Cullen
@123xylem
Jun 02 2016 08:04
function translatePigLatin(str) {
  str=str.split("");
  for (i=0;i<str.length;i++){

    if (str[0]!= "a" || str[0]== "e"|| str[0]== "i" || str[0]== "o"|| str[0]== "u"){

      while (str[i]!= /[aeiou]/){ str.push(str[i]);
      str.shift(); }
      str.push("a","y");
     str= str.join(" ");}


    else if(str[0]== "a" || str[0]== "e"|| str[0]== "i" || str[0]== "o"|| str[0]== "u")

    {     str= str.push("w","a","y");
      str.shift(); 
     str= str.join(" ");
      }

  }return str;


}

translatePigLatin("econsonant");
Where is the infinite loop here?
It says line 5
Chris Cullen
@123xylem
Jun 02 2016 08:13
 for(i=0;i<str.length;i++){
    while (str[i]!= /[aeiou]/){ 
                               str.push(str[i]);
      str.shift(); }
Eliza
@elizasj
Jun 02 2016 08:13
hey guys!I'm working on nesting for loops, and I was doing some tests ... I think I must be missunderstanding something because I don't get why I'm getting these results. Can anyone explain this output ?
Chris Cullen
@123xylem
Jun 02 2016 08:13
if str i is a consonant it stops the loop right?
Eliza
@elizasj
Jun 02 2016 08:13
> function mult(arr) {
... var product = 1;
... for (i = 0; i < arr.length; i++) {
..... for (j = 0; j < arr[i].length; j++) {
....... console.log(j);
....... }
..... }
... }
undefined
> mult([[1,2], [3,4], [5,6,7]]);
0
1
0
1
0
1
2
how is it spitting out 0 1 0 1 0 1 2?
kirbyedy
@kirbyedy
Jun 02 2016 08:15
and what should be the output ?
Eliza
@elizasj
Jun 02 2016 08:17
@kirbyedy I was trying to get the contents of each of the sub arrays :)
so 1 2 3 4 5 6 7
greg
@wearenotgroot
Jun 02 2016 08:17
@elizasj well you are trying to output the index
kirbyedy
@kirbyedy
Jun 02 2016 08:17
+1
Coy Sanders
@coymeetsworld
Jun 02 2016 08:17
yep
greg
@wearenotgroot
Jun 02 2016 08:17
@elizasj indexes of arr[]
Eliza
@elizasj
Jun 02 2016 08:18
@wearenotgroot oh ! so console.log(arr[i][j]) ?
@kirbyedy @coymeetsworld ^^
Coy Sanders
@coymeetsworld
Jun 02 2016 08:18
yep
Eliza
@elizasj
Jun 02 2016 08:19
omg @coymeetsworld thank you !
Coy Sanders
@coymeetsworld
Jun 02 2016 08:19
not sure what that undefined thing is in your code though
CamperBot
@camperbot
Jun 02 2016 08:19
elizasj sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star2: 1013 | @coymeetsworld |http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Jun 02 2016 08:19
but yeah your for loops are all good
Eliza
@elizasj
Jun 02 2016 08:19
@kirbyedy @wearenotgroot thank you guys✌
CamperBot
@camperbot
Jun 02 2016 08:19
elizasj sends brownie points to @kirbyedy and @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1048 | @kirbyedy |http://www.freecodecamp.com/kirbyedy
:star2: 1070 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Jun 02 2016 08:19
@coymeetsworld probably lines from the console :smile:
@elizasj :+1:
Coy Sanders
@coymeetsworld
Jun 02 2016 08:20
yeah just wondering where that came from
Eliza
@elizasj
Jun 02 2016 08:20
@coymeetsworld :smile:
yea I was diddling my tests in node!
Coy Sanders
@coymeetsworld
Jun 02 2016 08:20
never used a CLI to write JS though
oh ok interesting haven't worked with node at all yet
Eliza
@elizasj
Jun 02 2016 08:20
@coymeetsworld no ofc, just for testing outside the excercises cuz the FCC tests won't run my random code hah
Coy Sanders
@coymeetsworld
Jun 02 2016 08:21
I see @elizasj, I used codepen to test out the more complicated JavaScript exercises
but node looks better :)
Eliza
@elizasj
Jun 02 2016 08:22
@coymeetsworld I use codepen to store my css stuff haha ^^I like node for quick stuff
Coy Sanders
@coymeetsworld
Jun 02 2016 08:22
right, good to know thanks for that @elizasj
CamperBot
@camperbot
Jun 02 2016 08:22
coymeetsworld sends brownie points to @elizasj :sparkles: :thumbsup: :sparkles:
:cookie: 235 | @elizasj |http://www.freecodecamp.com/elizasj
Coy Sanders
@coymeetsworld
Jun 02 2016 08:22
one thing i liked about ruby was they had something similar with irb so you can quickly test things out
Jonathan Mitchell
@Vanhealen
Jun 02 2016 08:26
nice
Eliza
@elizasj
Jun 02 2016 08:26
@coymeetsworld love rubyyyyy (hate rails... but thats another story...) what do you use it for ? I only ever made little CLI games.
Coy Sanders
@coymeetsworld
Jun 02 2016 08:27
was one of the first languages I tried learning after coming back to coding @elizasj
didn't build anything great project with it or anything, just did things like Code Academy and Odin Project
Eliza
@elizasj
Jun 02 2016 08:28
@coymeetsworld same ! ha :) I managed a hangman game but then switched to js to play around with stuff in the browser.
Jonathan Mitchell
@Vanhealen
Jun 02 2016 08:28
Ruby seems like a neat language
Eliza