These are chat archives for FreeCodeCamp/HelpJavaScript

14th
Apr 2016
Diego Mayer
@Chrono79
Apr 14 2016 00:00
@Key-Banger read the helpful links, you have to use closure in that challenge
bitgrower
@bitgrower
Apr 14 2016 00:00

@Key-Banger -- fwiw the way I approached doing this was coding everything I knew how to do first ...

eg ... what if I have no arguments? 2 arguments? what if neither of the 2 arguments are numbers ...

after that I CAREFULLY followed the instructions ...

...for what to do when you have just 1 argument ...
what's not necessarily completely clear is that the code which calls your function will then run your function ...
Dustin
@Key-Banger
Apr 14 2016 00:01
I tried reading about closures. (Over head.....woosh.)
bitgrower
@bitgrower
Apr 14 2016 00:01
eh ... they tend to make it sound more difficult than it is, imo
Dustin
@Key-Banger
Apr 14 2016 00:02
I mean, Ive been writing functions inside functions using arguments. Just cant wrap my head around this problem.
Diego Mayer
@Chrono79
Apr 14 2016 00:02
@Key-Banger not mentioned there but you should use typeof too to check if the arguments are numbers
bitgrower
@bitgrower
Apr 14 2016 00:02
basically, closures means that you can have a local variable stick around after the function in which it was defined exits ... because you defined another function within it
@Key-Banger -- just imagine that you can run the inner function "later" and still access any local variables in the outer function that the inner function references ...
...some closure training also discusses the fact that you can pass around functions within variables ... that variables can contain functions
bitgrower
@bitgrower
Apr 14 2016 00:08
if you haven't seen this, maybe it will help: http://eloquentjavascript.net/03_functions.html#h_hOd+yVxaku
Diego Mayer
@Chrono79
Apr 14 2016 00:12
@bitgrower thanks for the link
CamperBot
@camperbot
Apr 14 2016 00:12
chrono79 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 986 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Apr 14 2016 00:14
yw !
Dustin
@Key-Banger
Apr 14 2016 00:14
Thanks @bitgrower @Chrono79 I'm trying to read and understand. Tough sledding right now.
CamperBot
@camperbot
Apr 14 2016 00:14
key-banger sends brownie points to @bitgrower and @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 388 | @chrono79 | http://www.freecodecamp.com/chrono79
:star: 987 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Apr 14 2016 00:16
just break it down, step by step ...

before taking calculus at one college, I had to take Algebra II -- and OH MY ... the kinds of problems these were ... but our instructor really showed how to approach them with the right mindset ...

kinda ... okay, you get to kinda be initially shocked ... but then you would just break the problem down bit by bit ...

class was probably better for learning an approach to solving problems than the content itself (although learning about series'n'things was fun...)

Dustin
@Key-Banger
Apr 14 2016 00:19
Here is going where I "want" to go.... I don't think its the right direction.
function addTogether() {
  var args = Array.prototype.slice.call(arguments);
  console.log(args);
  args.forEach(function(val){
  if (args.length < 2){
    return undefined;
  }
  else if(typeof(val) !== Number){
    return undefined;
  }
  return args.reduce(function(a,b){
    return a + b;
  });
  });

}

addTogether(2,3);
bitgrower
@bitgrower
Apr 14 2016 00:20
what's val ?
Dustin
@Key-Banger
Apr 14 2016 00:20
each element in the args array.
bitgrower
@bitgrower
Apr 14 2016 00:20
ahh ... okay ... yeah, now I see ...
Diego Mayer
@Chrono79
Apr 14 2016 00:21
@Key-Banger notice this: there is always 1 or 2 arguments, so no need to use var args = Array.prototype.slice.call(arguments); you can refer to them as arguments[0] and arguments[1], but if you want to use arrays functions it's ok to use var args...
bitgrower
@bitgrower
Apr 14 2016 00:21
your return statement is within the forEach callback, then ?

actually, @Chrono79 -- I like it when people use a more generalized approach ... yes, it's true the problem statement says there are only 1 or 2 arguments .. but what if something changes, or someone screws up ...

...not assuming that caller to your function (or your code) is doing the right thing and coding to that is something called "defensive programming"... it's a good practice ... esp when you move into production code

Dustin
@Key-Banger
Apr 14 2016 00:24
@Chrono79 yea, I've run into this before. Is there an inherent way that Js knows how many arguments there are? I've used argument[0] and argument[1] but what if the number of arguments change?
bkd705
@bkd705
Apr 14 2016 00:24
i had a buddy in here that i raced with, but now i forget his name... i feel bad.
Dustin
@Key-Banger
Apr 14 2016 00:24
@bkd705 me too :worried:
bitgrower
@bitgrower
Apr 14 2016 00:24
@Key-Banger arguments.length
bkd705
@bkd705
Apr 14 2016 00:25
@Key-Banger aha, i would remember if i saw his name, but i cant think of it to @ him lmfao
Diego Mayer
@Chrono79
Apr 14 2016 00:31
@bitgrower I know, but sometimes it's easier to do not the general case, instead a simpler one, when you understand how it works (and it works ;)) generalize
Tyler
@tylergross
Apr 14 2016 00:35
having trouble with javascript switch's

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
case 1 :
answer = "alpha";
break;
case 2 :
answer = "beta";
break;
case 3 :
answer = "gamma";
break;
case 4 :
answer= "delta";
break;

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

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

getting error that says: expected } but saw case instead
is my syntax wrong around line 4?
Diego Mayer
@Chrono79
Apr 14 2016 00:35
@tylergross you're missing switch (val) { and the ending }
switch (val) {
  case 1:
  ...
}
Tyler
@tylergross
Apr 14 2016 00:37
appreciate the help
thought the caseInSwitch(val) was the function
Diego Mayer
@Chrono79
Apr 14 2016 00:37
np
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:37

hello everyone
I have a small query regarding using hasOwnProperty for javascript objects
Here is the question
Instructions
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
My solution:
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};

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

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

Dustin
@Key-Banger
Apr 14 2016 00:38
Still plugging... No movement.
function addTogether() { 
  var sumTwoAnd = arguments[0];
  if (arguments.length !== 2){
    return undefined;
  }
  return sumTwoAnd+arguments[arguments.length-1];
}

addTogether(2,3);
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:38
is something wrong with my solution?
Diego Mayer
@Chrono79
Apr 14 2016 00:38
@SreekarJammula please use this
help format
CamperBot
@camperbot
Apr 14 2016 00:38

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

Diego Mayer
@Chrono79
Apr 14 2016 00:39
to paste your code
bitgrower
@bitgrower
Apr 14 2016 00:39

@bitgrower I know, but sometimes it's easier to do not the general case, instead a simpler one, when you understand how it works (and it works ;)) generalize

I would say that sometimes thinking about the general solution can tip you to easier approaches to the specific ones ... but it can go either way ... in this case ... handling a variable number of arguments is an important skill to know in js ... :)

Diego Mayer
@Chrono79
Apr 14 2016 00:39
@SreekarJammula use the param when you use hasOwnProperty
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:40
js
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Diego Mayer
@Chrono79
Apr 14 2016 00:40
@SreekarJammula good, you are hardcoding the property name
instead of "gift" use checkProp
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:40
im sorry... i sent the wrong solution....ill send the updated one
bitgrower
@bitgrower
Apr 14 2016 00:41

Still plugging... No movement.

you need to return a function ... you're on the right track ...

just put that addition into a function that you return ...

one other thing, though, you can't use the arguments object as something you return ...

@SreekarJammula -- you need to review the difference between dot & bracket notation in objects ...
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:51
@bitgrower is it wrong to use dot notation to access the values? i have some confusion regarding this
also, please note that i am using checkProp in my hasOwnProperty function
Diego Mayer
@Chrono79
Apr 14 2016 00:51
@SreekarJammula dot notation can't be used with var names
myObj.checkProp <- myObj has a property whose name is checkProp
if checkProp is a var name it doesn't work
with bracket notation you can use var names to identify object properties
myObj[checkProp] <- let's say checkProp is a var whose value is "gift", then it works
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:52
@Chrono79 can u please elaborate?
bitgrower
@bitgrower
Apr 14 2016 00:55

what he means is ...

the only way this would work: myObj.checkProp

is if myObj had a property named "checkProp" ...

...but it doesn't

it's a variable containing the name of a property ...

so you have to use bracket notation ...

Jas
@JB2016
Apr 14 2016 00:55
@SreekarJammula you can also just use a boolean function rather than @SreekarJammula .hasOwnProperty
Diego Mayer
@Chrono79
Apr 14 2016 00:55
@bitgrower bracket notation
bitgrower
@bitgrower
Apr 14 2016 00:56
oops ... sorry ...
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:56
i tried bracket notation too
it isnt working
Diego Mayer
@Chrono79
Apr 14 2016 00:56
@SreekarJammula paste your corrected code
bitgrower
@bitgrower
Apr 14 2016 00:56
well ... let's see your code with bracket notation and let's see what else might be going on ...
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:56
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
bitgrower
@bitgrower
Apr 14 2016 00:57
@SreekarJammula -- no quotes
Diego Mayer
@Chrono79
Apr 14 2016 00:57
@SreekarJammula "checkProp" is a string
bitgrower
@bitgrower
Apr 14 2016 00:57
don't use quote characters in your hasOwnProperty or your return statement
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:57
doesnt help!
bitgrower
@bitgrower
Apr 14 2016 00:58
stop it!
show us what isn't working ... we'll help you fix it
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:58
okay
got it
it was my mistake to use quotes while passing parameter to hasOwnProperty
bitgrower
@bitgrower
Apr 14 2016 00:59
paste your code and show us what's not working .. :)
Diego Mayer
@Chrono79
Apr 14 2016 00:59
I think it works now
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 00:59
i did that because it was the same way in the tutorial
bitgrower
@bitgrower
Apr 14 2016 00:59
that's only when you are having to use the exact property name ... that's when you use the quotes ...
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 01:00
this is the correct code :
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Diego Mayer
@Chrono79
Apr 14 2016 01:00
it works, right?
bitgrower
@bitgrower
Apr 14 2016 01:04
YAY ... so, now reward yourself ... take a break ... congratulations, @SreekarJammula
Dustin
@Key-Banger
Apr 14 2016 01:04
Still same results.... Insanity here. ha ha ha
function addTogether() { 
  var first = arguments[0];
  var second = arguments[arguments.length-1];
  if (arguments.length !== 2){
    return undefined;
  }
  function addArgs(a,b){
    a=first;
    console.log(a);
    b=second;
    console.log(b);
    return a+b;
  }
  return addArgs();
}

addTogether(2,3);
Tyler
@tylergross
Apr 14 2016 01:06
you have the function addTogether(2,3) but when the function is declared there is nothing inbetween addTogether()
not sure if this is the problem I think you're way ahead of me in lessons
Sreekar Reddy jammula
@SreekarJammula
Apr 14 2016 01:06
hehe thank you @bitgrower @Chrono79
CamperBot
@camperbot
Apr 14 2016 01:06
sreekarjammula sends brownie points to @bitgrower and @chrono79 :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Apr 14 2016 01:06

if you do this

return addArgs(); ... it's going to execute the function and return the results of returning the function ...

you are going to return undefined if there is only one argument

CamperBot
@camperbot
Apr 14 2016 01:06
:star: 988 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 389 | @chrono79 | http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
Apr 14 2016 01:07
so ... even assuming your inner function was right, you'd already have returned from the function ...
Dustin
@Key-Banger
Apr 14 2016 01:10
@bitgrower this is the part that is over my head. I guess its the async functionality of javascript.
bitgrower
@bitgrower
Apr 14 2016 01:11
so ... in programming there's a concept called functional decomposition ... while it tends to be used for problems far more complex ... it's useful here ... because you have 3 major cases your code needs to handle ...
  1. if there is 2 argument
  2. if there is 1 argument
  3. if there is some other number of arguments ... 0 arguments, more than 2 arguments ...
bkd705
@bkd705
Apr 14 2016 01:11
blob
frig i did it again
woops
Iterate Through an Array with a For Loop
can someone help me with that one?
help Iterate Through an Array with a For Loop
CamperBot
@camperbot
Apr 14 2016 01:11

:point_right: challenge iterate through an array with a for loop [wiki]

Challenge: Iterate Through an Array with a For Loop

A common task in Javascript is to iterate through the contents of an array. One way to do that is with a for loop. This code will output each element of the array arr to the console:

    var arr = [10,9,8,7,6];
    for (var i=0; i < arr.length; i++) {
       console.log(arr[i]);
    }

Remember that Arrays have zero-based numbering, which means the last index of the array is length - 1. Our condition for this loop is i < arr.length, which stops when i is at length - 1.

:pencil: read more about challenge iterate through an array with a for loop on the FCC Wiki

bitgrower
@bitgrower
Apr 14 2016 01:11
case #1 and case #3 should be easy to handle ... I recommend coding those first ...
Dustin
@Key-Banger
Apr 14 2016 01:13
@bitgrower this not grab those? arguments.length !== 2
bitgrower
@bitgrower
Apr 14 2016 01:13
what happens if 1 argument is passed, @Key-Banger ?
@bkd705 -- sorry, need to go look up the challenge ... it's not immediately in the wiki ...
henrywashere
@henrywashere
Apr 14 2016 01:15

need help wiith this exercise:

One way to think of a multi-dimensional array, is as an array of arrays. When you use brackets to access your array, the first set of bracket refers to the entries in the outer-most array, and each subsequent level of brackets refers to the next level of entries inside.

Example

var arr = [
[1,2,3],
[4,5,6],
[7,8,9],
[[10,11,12], 13, 14]
];
arr[0]; // equals [1,2,3]
arr1; // equals 6
arr[3]0; // equals 11

Instructions
Read from myArray using bracket notation so that myData is equal to 8

bkd705
@bkd705
Apr 14 2016 01:15
i figured it out @bitgrower
henrywashere
@henrywashere
Apr 14 2016 01:15
i have no idea what im suppose to do
bkd705
@bkd705
Apr 14 2016 01:15
i was using p as my variable, but when i wrote the code i did i++ and i >
Diego Mayer
@Chrono79
Apr 14 2016 01:16

@henrywashere

var arr = [
[1,2,3], [4,5,6], [7,8,9], [ [10,11,12], 13, 14] ];

in which of the arr elements is the 8? That should be your first index
then you have to search inside that element because it is also an array, that's your second index

bitgrower
@bitgrower
Apr 14 2016 01:18
@henrywashere -- haven't you mastered posting your code with formatting ?
henrywashere
@henrywashere
Apr 14 2016 01:18
are we using zero=based indexing?
Diego Mayer
@Chrono79
Apr 14 2016 01:18
@henrywashere yes
idietmoran
@idietmoran
Apr 14 2016 01:18
@henrywashere js uses zero based indexing
henrywashere
@henrywashere
Apr 14 2016 01:18
ok
bitgrower
@bitgrower
Apr 14 2016 01:19
most programming languages use zero-based indexing ...
Dustin
@Key-Banger
Apr 14 2016 01:19
@bitgrower
function addTogether() { 
  var first = arguments[0];
  var second = arguments[1];

  if (arguments.length > 2){
    return undefined;
  }

  else if (arguments.length === 1){
    // return something
  }

  function addArgs(a,b){
    a=first;
    console.log(a);
    b=second;
    console.log(b);
    return a+b;
  }

  return addArgs();
}

addTogether(2)(3);
Tom
@aphasiac2002
Apr 14 2016 01:20
@aphasiac2002
console.log("test") outputs nothing
how can i debug?
help, how do i write to the console for debugging?
CamperBot
@camperbot
Apr 14 2016 01:20
no wiki entry for: how do i write to the console for debugging
Diego Mayer
@Chrono79
Apr 14 2016 01:21
@aphasiac2002 if you use Chrome: ctrl+shift+j look in that console
Dustin
@Key-Banger
Apr 14 2016 01:21
@aphasiac2002 the console is in your browser. What browser?
idietmoran
@idietmoran
Apr 14 2016 01:21
@aphasiac2002 console.log('test') should write to the javascript console
bitgrower
@bitgrower
Apr 14 2016 01:21
you still don't want to define a variable if you don't know if it's valid ... that is ... when you define second, and just one parameter is passed, second is going to be, literally, undefined...
Tom
@aphasiac2002
Apr 14 2016 01:21
using chrome
oooh ok
idietmoran
@idietmoran
Apr 14 2016 01:21
@Key-Banger some text-editors / IDE's can run js inside it, but most of them run on node now
lyyourc
@DrakeLeung
Apr 14 2016 01:21
var str = `<div>{{name}}{{price}}</div>`

var reg = /{{([^}}]+)}}/g

str.match(reg)
Anyone tell me why can't capture the name string?
bitgrower
@bitgrower
Apr 14 2016 01:22
(you didn't actually handle the case of 0 arguments being passed, but that's okay for now ... )
This message was deleted
sorry, missed the '+' sign
Diego Mayer
@Chrono79
Apr 14 2016 01:26
@DrakeLeung here it says it should https://regex101.com/
bitgrower
@bitgrower
Apr 14 2016 01:26
help regex resources
CamperBot
@camperbot
Apr 14 2016 01:26

:point_right: js regex resources [wiki]

Links to useful RegEx resources.

See also: :clipboard: Tutorials | :syringe: Testing | :soccer: Games | :newspaper: Blogs | :package: Software

:pencil: read more about js regex resources on the FCC Wiki

bitgrower
@bitgrower
Apr 14 2016 01:26
I'd try it out on one of the testers ... mentioned in the "testing" link
Dustin
@Key-Banger
Apr 14 2016 01:27
function addTogether() { 
  var first = arguments[0];
  var second = arguments[arguments.length-1];

  if (arguments.length > 2 || arguments.length < 1){
    return undefined;
  }

  else if (arguments.length === 1){
     return addArgs();
  }

  function addArgs(a,b){
    a=first;
    console.log(a);
    b=second;
    console.log(b);
    return a+b;
  }

  return addArgs();
}

addTogether(2)(3);
bitgrower
@bitgrower
Apr 14 2016 01:28
again, your return statement is not returning addArgs ... it's EXECUTING it
and returning the result ...
henrywashere
@henrywashere
Apr 14 2016 01:29
@Chrono79 so the first index is a 9 right?
since we're using zero-based indexnig
lyyourc
@DrakeLeung
Apr 14 2016 01:29
Thanks, the site looks awesome, I try it now ~ @Chrono79
CamperBot
@camperbot
Apr 14 2016 01:29
drakeleung sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 390 | @chrono79 | http://www.freecodecamp.com/chrono79
Dustin
@Key-Banger
Apr 14 2016 01:30
@bitgrower I dont understand.
Diego Mayer
@Chrono79
Apr 14 2016 01:30
@henrywashere no, arr is an array (of arrays)
if you don't see what each element of arr is try putting
alert(arr[0]);
alert(arr[1]); 
etc.
bitgrower
@bitgrower
Apr 14 2016 01:30

if you have a line in your code which is this

myFunction(a,b);

what is your code going to do ?

Sean Umphlet
@umphlet
Apr 14 2016 01:32
Hey guys I may have found a bug with the Mutations bonfire?
function mutation(arr) {
  var arr1 = arr[0].toLowerCase();
  var arr2 = arr[1].toLowerCase();

  if (arr1.length < arr2.length) {

  for (i=0; i < arr1.length; i++) {
    if (arr2.indexOf(arr1.charAt(i)) === -1) {
      return false;
    }

  } 
  }
  else {
    for (i=0; i < arr2.length; i++) {
    if (arr1.indexOf(arr2.charAt(i)) === -1) {
      return false;
    }  
  }


  return true;
}}
mutation(["Mary", "Aarmy"]);
All of the tests pass except the Mary, Aarmy one, when I put that in it returns nothing, not true, not false
bitgrower
@bitgrower
Apr 14 2016 01:36
@DrakeLeung -- you've probably bumped into the "greedy algorithm" nature of regular expressions ... your regular expression will gobble up characters until it finds the LAST match for }} ... since you have 2 instances in your string, it's going to find the last one, and include all the intervening characters into your match ...
Diego Mayer
@Chrono79
Apr 14 2016 01:36
@umphlet
 return true;
}}
Sean Umphlet
@umphlet
Apr 14 2016 01:37
@Chrono79 Nothing gets returned on my end...
Diego Mayer
@Chrono79
Apr 14 2016 01:37
@umphlet that return is inside the else block, I think it should be outside
Sean Umphlet
@umphlet
Apr 14 2016 01:38
Well then don't I feel dumb lol
@Chrono79 Yeah I put it outside and it passed
Diego Mayer
@Chrono79
Apr 14 2016 01:38
@umphlet try to indent better, it will be easier to spot things like that
bkd705
@bkd705
Apr 14 2016 01:39
help Profile Lookup
CamperBot
@camperbot
Apr 14 2016 01:39

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

We have an array of objects representing different people in our contacts lists.

A lookUp function that takes firstName and a property (prop) as arguments has been pre-written for you.

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

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

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

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

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

:pencil: read more about checkpoint profile lookup on the FCC Wiki

Dustin
@Key-Banger
Apr 14 2016 01:39
@bitgrower return addArgs;?
Sean Umphlet
@umphlet
Apr 14 2016 01:40
@Chrono79 Righto, thanks for your help.
CamperBot
@camperbot
Apr 14 2016 01:40
umphlet sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star: 391 | @chrono79 | http://www.freecodecamp.com/chrono79
bitgrower
@bitgrower
Apr 14 2016 01:40

yes -- that would be how you return a function @Key-Banger ...

or, you can literally define the function in your return statement ...

return function addArgs ( ... etc

lyyourc
@DrakeLeung
Apr 14 2016 01:41
sorry, I still can not understand :(
bitgrower
@bitgrower
Apr 14 2016 01:41
@DrakeLeung -- check this page out: http://www.rexegg.com/regex-quickstart.html search for greedy (the opposite is "lazy")
lyyourc
@DrakeLeung
Apr 14 2016 01:41
OK
Dustin
@Key-Banger
Apr 14 2016 01:42
function addTogether() { 
  var first = arguments[0];
  var second = arguments[arguments.length-1];

  if (arguments.length > 2 || arguments.length < 1){
    return undefined;
  }

  else if (arguments.length === 1){
     return arguments[0];
  }

  return function addArgs(a,b){
    a=first;
    console.log(a);
    b=second;
    console.log(b);
    return a+b;
  };

}

addTogether(2)(3);
bitgrower
@bitgrower
Apr 14 2016 01:42
basically if I search for .*. in a piece of text, it's going to find ALL my sentences, not just the first one ... it doesn't stop at the first instance of my period, but rather at the last possible one ...
Diego Mayer
@Chrono79
Apr 14 2016 01:43
@DrakeLeung if you only want {{name}} (and not {{price}}) remove the g after the / I thought you wanted both
bitgrower
@bitgrower
Apr 14 2016 01:43
c'mon @Key-Banger -- read the problem definition again ... you were going in the right direction ... what's this return arguments[0]; ?
@Chrono79 -- doesn't actually matter if he uses g or not ... g has a different connotation, though it can get confusing when trying to understand how a match with g works and how a match with one or more wildcard characters works ...
Vik
@vvang044
Apr 14 2016 01:46
caeser cipher just flew off my head.....oh boi
Diego Mayer
@Chrono79
Apr 14 2016 01:48

@Key-Banger

addTogether(2)(3);

notice, that when you call addTogether like this, arguments.length is 1

Darrel Adams
@dadams-510
Apr 14 2016 01:49
Can anyone explain what the .splice() method does?
What exactly is going under the hood when .splice() is used.
Rex Smith Jr.
@rsmith731
Apr 14 2016 01:51
anyone good with ember?
lyyourc
@DrakeLeung
Apr 14 2016 01:51

cool ~ I have knew 'lazy' and 'greedy'. @bitgrower
@Chrono79 good idea

both of you are cool guy, thanks for helping me out ~

CamperBot
@camperbot
Apr 14 2016 01:51
drakeleung sends brownie points to @bitgrower and @chrono79 :sparkles: :thumbsup: :sparkles:
:warning: drakeleung already gave chrono79 points
:star: 989 | @bitgrower | http://www.freecodecamp.com/bitgrower
Dustin
@Key-Banger
Apr 14 2016 01:52
@bitgrower there is no world where you can sum one number.... What am I suppose to do with it? @Chrono79 Yep don't know what to do with that either. I'm obviously in way over my head. I'll just start over.
bitgrower
@bitgrower
Apr 14 2016 01:53
yw @DrakeLeung
khaduch @khaduch - hello folks
bitgrower
@bitgrower
Apr 14 2016 01:57
@Key-Banger -- you grab the one argument from the parent function (your closure) ... you can have an "undefined" named parameter for your inner function ... or, it can find a value ... which the named parameter will take the value of ... then you use those two values and add them together ...
the trick is ... in your inner function, while you reference a local variable in the parent function, that has to be an actual local variable ... it cannot be a reference to the arguments object ...
hi @khaduch !
Ken Haduch
@khaduch
Apr 14 2016 02:00
@bitgrower - hi there!!! :smile:
bitgrower
@bitgrower
Apr 14 2016 02:01
LOL now that I see your last name is Haduch -- I'm gonna be thinking of Hadoop when I see your name ... :)
Ken Haduch
@khaduch
Apr 14 2016 02:03
@bitgrower - I don't know Hadoop... but I do know the Profile lookup... :)
Dustin
@Key-Banger
Apr 14 2016 02:04
@khaduch do you know closure? because I dont.
bitgrower
@bitgrower
Apr 14 2016 02:05
I don't know hadoop either ... I just know OF it ...
LOL yeah, around here, I'm sure Profile Lookup could be used instead of counting sheep ...
Ken Haduch
@khaduch
Apr 14 2016 02:06
@Key-Banger - well, maybe I have some idea about it. I have a link to an article that might help you to understand them? http://javascriptissexy.com/understand-javascript-closures-with-ease (Although I take the words "with ease" with a grain of salt.)
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:07
help search and replace
CamperBot
@camperbot
Apr 14 2016 02:07

:point_right: algorithm search and replace [wiki]

Problem Explanation:

  • You will create a program that takes a sentence, then search for a word in it and replaces it for a new one while preserving the uppercase if there is one.
:pencil: read more about algorithm search and replace on the FCC Wiki
Ken Haduch
@khaduch
Apr 14 2016 02:08
@Key-Banger - oh, you must be doing that problem...
Benjamin Krall
@krall12
Apr 14 2016 02:08
Can someone help me out with pulling data from an API? I have a codepen here but can't get any data to output. http://codepen.io/Krall12/pen/RaMGwo?editors=0011
Dustin
@Key-Banger
Apr 14 2016 02:09
@khaduch Not profile lookup. ha ha ha I read that article and the preceding article about scope. In one eye out the other.
Ken Haduch
@khaduch
Apr 14 2016 02:09
@Key-Banger - I meant the problem "Arguments optional" or something like that? That was fun... :)
Dustin
@Key-Banger
Apr 14 2016 02:11
@khaduch bingo. Not much fun tonight. I understand it is a necessary evil. Evil none the less.
500seeds
@500seeds
Apr 14 2016 02:11

hi guys, I' doing Finding a Remainder in JavaScript. I've already used % operator in my variable. // Only change code below this line

var x = 11;
var y = 3 ;
var z = x % y;
var remainder = z;

did i do something wrong?
Ken Haduch
@khaduch
Apr 14 2016 02:12
@Key-Banger - I don't know if it is a necessary evil... closures seem to be a hot topic in JavaScript, though... how far have you gotten with it? I'm not sure if I can help, but I can give it a try...
bitgrower
@bitgrower
Apr 14 2016 02:13

@Key-Banger - well, maybe I have some idea about it. I have a link to an article that might help you to understand them? http://javascriptissexy.com/understand-javascript-closures-with-ease (Although I take the words "with ease" with a grain of salt.)

...yeah, any article that long inspires tl;dr ... hardly has the starting requirement for "ease" ... @khaduch ...

Dustin
@Key-Banger
Apr 14 2016 02:13
@khaduch Honestly not far. Just chasing my tail. @bitgrower has been trying to help graciously but I'm sort of bull headed sometimes.
@500seeds I think var z = x % y; is the remainder.
Ken Haduch
@khaduch
Apr 14 2016 02:14
@bitgrower :) - yes, I agree!
@500seeds - just try setting remainder directly with the operation using the remainder operator? That might be what they are checking for?
bitgrower
@bitgrower
Apr 14 2016 02:15
put another way ... closures make AJAX useful ... and how useful is AJAX ... ? Well ... it made gmail & google maps possible ... and navigation within the map without having to do page re-loads ... HUGELY powerful stuff ...
bkd705
@bkd705
Apr 14 2016 02:16
i feel like i learned html and css in 2 days, but its taking me what feels like years to understand javascript lmfao
Daniel
@profoundhub
Apr 14 2016 02:18
anyone here able to help me figure out how to Create Decimal Numbers with JavaScript?
reedhammond
@reedhammond
Apr 14 2016 02:18
@JB2016 Thanks!
CamperBot
@camperbot
Apr 14 2016 02:18
reedhammond sends brownie points to @jb2016 :sparkles: :thumbsup: :sparkles:
:star: 268 | @jb2016 | http://www.freecodecamp.com/jb2016
reedhammond
@reedhammond
Apr 14 2016 02:18
Sorry so late @JB2016
Elbert Cortez
@trip16661
Apr 14 2016 02:19
is there a better way to do this
function sumAll(arr) {
  var newArray = [];
  for (var a = Math.min(...arr);a<=Math.max(...arr);a++ ){
      newArray.push(a);
  }


  return newArray.reduce(function(q,w){
    return q+w;
  });
}

sumAll([1, 4]);
bitgrower
@bitgrower
Apr 14 2016 02:19
@trip16661 -- better ways are best discussed in the CodeReview room, not in here ... thanks !
CamperBot
@camperbot
Apr 14 2016 02:19
bitgrower sends brownie points to @trip16661 :sparkles: :thumbsup: :sparkles:
:star: 316 | @trip16661 | http://www.freecodecamp.com/trip16661
and "better" is subjective ... better for what? speed? clarity? space ? "better" depends on what you want to optimize for ... :)
Daniel
@profoundhub
Apr 14 2016 02:21
hmmm, ... Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7).
Ken Haduch
@khaduch
Apr 14 2016 02:21

@Key-Banger - okay, you know that you can return a function from JavaScript, that is one of the essential parts of that problem. Ignoring the part about undefined operators, you can create a function that will add a value to a number, for example, you can make a function addThree() and let's just say that it is created by another function.:

function makeAddThree() {
     return function addThree(arg) {
        return arg + 3;
    }
}

Now if you run that function, and save the result, you will get a variable that is a function which you can then call with another number, and it will add 3 to it and return the result.

500seeds
@500seeds
Apr 14 2016 02:21
@khaduch & @Key-Banger thanks. just keep it simple
CamperBot
@camperbot
Apr 14 2016 02:21
500seeds sends brownie points to @khaduch and @key-banger :sparkles: :thumbsup: :sparkles:
:star: 936 | @khaduch | http://www.freecodecamp.com/khaduch
:star: 393 | @key-banger | http://www.freecodecamp.com/key-banger
reedhammond
@reedhammond
Apr 14 2016 02:22
couple questions? How are you all sending screen shots? My chat room has no option for images?
Norvin Burrus
@ndburrus
Apr 14 2016 02:22
help multi line code
CamperBot
@camperbot
Apr 14 2016 02:22
no wiki entry for: multi line code
Daniel
@profoundhub
Apr 14 2016 02:22
those are not screenshots
Norvin Burrus
@ndburrus
Apr 14 2016 02:22
help code formatting
CamperBot
@camperbot
Apr 14 2016 02:22

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

This an inline `<paste code here>` code formatting with a single backtick(`) at start and end around the code.

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

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

reedhammond
@reedhammond
Apr 14 2016 02:23
@profoundhub what are they?
Norvin Burrus
@ndburrus
Apr 14 2016 02:23
@reedhammond
Daniel
@profoundhub
Apr 14 2016 02:23
@reedhammond Multi line Code
bitgrower
@bitgrower
Apr 14 2016 02:23
code formatting
Ken Haduch
@khaduch
Apr 14 2016 02:24

@Key-Banger - so the example of doing that is this:

function makeAddThree() {
     return function addThree(arg) {
        return arg + 3;
    }
}

var myAdd3 = makeAddThree();

var result = myAdd3(9);
console.log(result);

If you run that, you can see that the result that you get in the final variable is 3.

So now extend this a little and say that we want to call it with another value other than add3 - maybe we want to make a general function that will return a function that adds the first number (the argument we pass in when creating the function) to the other number that we pass when we call the created function.

reedhammond
@reedhammond
Apr 14 2016 02:25
This message was deleted
bitgrower
@bitgrower
Apr 14 2016 02:25
gitter understands something called markdown ... the formatting options make use of markdown syntax/commands to create the kind of code you see where there is syntax coloring on a black background ...
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:26
is there a way to target the first letter of a string with regex?
is it just /^/
bitgrower
@bitgrower
Apr 14 2016 02:27
well, ^ doesn't actually match a character ... it just indicates where to start looking for a match .. so you would have to do something like
/^./
Daniel
@profoundhub
Apr 14 2016 02:27
can someone help me with my question?
bitgrower
@bitgrower
Apr 14 2016 02:27
what was your q again, @profoundhub ?
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:27
that makes sense
decimals and fractions
reedhammond
@reedhammond
Apr 14 2016 02:28
Thanks @bitgrower @ndburrus @profoundhub I can't seem to get it to work. But I appreciate that i'm not crazy on the screen shots.
CamperBot
@camperbot
Apr 14 2016 02:28
reedhammond sends brownie points to @bitgrower and @ndburrus and @profoundhub :sparkles: :thumbsup: :sparkles:
:star: 990 | @bitgrower | http://www.freecodecamp.com/bitgrower
:star: 229 | @ndburrus | http://www.freecodecamp.com/ndburrus
:star: 169 | @profoundhub | http://www.freecodecamp.com/profoundhub
Norvin Burrus
@ndburrus
Apr 14 2016 02:28
@profoundhub what's your question Daniel?
bitgrower
@bitgrower
Apr 14 2016 02:28
hmmm .. I don't recall seeing that challenge before ... but it has been a while since I've done most of the challenges I've completed ...
reedhammond
@reedhammond
Apr 14 2016 02:29
This message was deleted
bitgrower
@bitgrower
Apr 14 2016 02:29
you're on the right track @reedhammond
you'll get it
Norvin Burrus
@ndburrus
Apr 14 2016 02:29
@reedhammond try using/changing to/from "chat" and "compose" modes. the buttons are to the right of the text entry area.
Daniel
@profoundhub
Apr 14 2016 02:30
var ourDecimal = 5.7;

// Only change code below this line
Norvin Burrus
@ndburrus
Apr 14 2016 02:30
@reedhammond it will work for you
Daniel
@profoundhub
Apr 14 2016 02:31
got it, ... i used, ctrl enter
instead of shift enter
i'm on Windows PC
Elbert Cortez
@trip16661
Apr 14 2016 02:32
is there any way to get the numbers btween a range and then using them later ?
Norvin Burrus
@ndburrus
Apr 14 2016 02:32
@profoundhub hmmm for pc, it's cntrl enter, that's good to know..
reedhammond
@reedhammond
Apr 14 2016 02:32
function myTest(val) {
  var answer = "";
  // Only change code below this line
  switch (val)
   { 
    case 1:
    case 2:
    case 3: 
        result = "Low";
        break;
    case 4:
    case 5:
    case 6: 
        result = "Mid";
        break;
    case 7:
    case 8:
    case 9: 
        result = "High";
        break;    


   }

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

// Change this value to test
myTest(1);
Ken Haduch
@khaduch
Apr 14 2016 02:32

@Key-Banger - so this is the next example, a function that I called makeAddWhatever() that now accepts an argument, and this argument becomes one of the addends (going back to my rusty mathematical terminology) in the function, and it is an example of a closure because you'll see that there is a variable that is captured in this created function that is then used when the function is called:

// here is my next example
function makeAddWhatever( arg1 ) {
     return function addWhatever(arg) {
        return arg + arg1;
    }
}

var myAdd9 = makeAddWhatever(9);

var result = myAdd9(12);
console.log(result); // returns 21

So I should be able to call this multiple times and create multiple functions, and I hope that each of them adds what I give as the original function argument when creating the function to the second argument. Let me try it and see...

function makeAddWhatever( arg1 ) {
     return function addWhatever(arg) {
        return arg + arg1;
    }
}

var myAdd9 = makeAddWhatever(9);

var result = myAdd9(12);
console.log(result);  // returns the value 21
var myAdd23 = makeAddWhatever(23);
var result2 = myAdd23(15);
console.log(result2);  // returns the value 38

That is an example using some fixed values - but you can create any number of functions with this that will add one value to another.

```

reedhammond
@reedhammond
Apr 14 2016 02:32
OK I GOT IT!!! Now what am I doing wrong please?

Instructions
Write a switch statement to set answer for the following ranges:
1-3 - "Low"
4-6 - "Mid"
7-9 - "High"

Note
You will need to have a case statement for each number in the range.

Norvin Burrus
@ndburrus
Apr 14 2016 02:33
@reedhammond what challenge is this?
reedhammond
@reedhammond
Apr 14 2016 02:33
Multiple Identical Options in Switch Statements
Jamie Lipschitz
@Jlipschitz
Apr 14 2016 02:34

@reedhammond tale a close look at the variable you are returning

 var answer = "";

 return answer;

once you make these two connect in between the following

case 1:
    case 2:
    case 3: 
        result = "Low";
        break;
    case 4:
    case 5:
    case 6: 
        result = "Mid";
        break;
    case 7:
    case 8:
    case 9: 
        result = "High";
        break;

then you will be finished with the assignment

Ken Haduch
@khaduch
Apr 14 2016 02:34
@reedhammond - somewhere in your function, you have to set a value in the variable answer... that is what you are returning. I don't see any place that you are connecting the result that you are setting with the values to the answer variable? Consider using answer in place of result?
reedhammond
@reedhammond
Apr 14 2016 02:37
function myTest(val) {
  var result = "";
  // Only change code below this line
  switch (val)
   { 
    case 1:
    case 2:
    case 3: 
        result = "Low";
        break;
    case 4:
    case 5:
    case 6: 
        result = "Mid";
        break;
    case 7:
    case 8:
    case 9: 
        result = "High";
        break;    


   }

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

// Change this value to test
myTest(1);
Norvin Burrus
@ndburrus
Apr 14 2016 02:38
@reedhammond what "type" (hint) of statement/s are you working with?
@reedhammond aaahh....ok
@reedhammond better
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:38
Thanks @bitgrower for that regex tip
CamperBot
@camperbot
Apr 14 2016 02:38
nyrrad sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 991 | @bitgrower | http://www.freecodecamp.com/bitgrower
reedhammond
@reedhammond
Apr 14 2016 02:38
Its still not working! I am really struggling with JS.
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:38
i didnt even end up using it haha :(
Daniel
@profoundhub
Apr 14 2016 02:38
ok I got it
bitgrower
@bitgrower
Apr 14 2016 02:39
congrats @nyrrad -- I'm not even sure which tip you're thanking me for ...
Darryn Bourgeois
@nyrrad
Apr 14 2016 02:39
/^./ regex question
Norvin Burrus
@ndburrus
Apr 14 2016 02:39
@reedhammond why are you not using the function name given in the challenge?
bitgrower
@bitgrower
Apr 14 2016 02:39
ah!
Jamie Lipschitz
@Jlipschitz
Apr 14 2016 02:40
@reedhammond your code with the adjustment will work. more than likely it's the naming convention it wants
Norvin Burrus
@ndburrus
Apr 14 2016 02:40
@reedhammond hint - look at what the desired results should be
Elbert Cortez
@trip16661
Apr 14 2016 02:40
is there any way to get the numbers btween a range and then using them later ? in javascript
without looping
Norvin Burrus
@ndburrus
Apr 14 2016 02:40
@reedhammond hint - 1st word of all but 2 of the desired results
@reedhammond (the last 2)
@reedhammond got it
?
Jamie Lipschitz
@Jlipschitz
Apr 14 2016 02:42
@trip16661 could you explain a little more. You want to have an array of the numbers between a range?
Norvin Burrus
@ndburrus
Apr 14 2016 02:42
@reedhammond sequential..... (wait for it....) Sizes.....
reedhammond
@reedhammond
Apr 14 2016 02:43
Thanks
Thanks @ndburrus
CamperBot
@camperbot
Apr 14 2016 02:43
reedhammond sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: reedhammond already gave ndburrus points
reedhammond
@reedhammond
Apr 14 2016 02:44
Dropped computer in water. Had to shut down. Thanks for help
Norvin Burrus
@ndburrus
Apr 14 2016 02:44
@reedhammond your welcome!
@reedhammond hint - don't do that... :)
reedhammond
@reedhammond
Apr 14 2016 02:45
Thanks jlip
Dustin
@Key-Banger
Apr 14 2016 02:45
function addTogether() { 
  if (arguments.length > 2 || arguments.length < 1){
    return undefined;
  }

  else if (arguments.typeOf!==Number){
     return undefined;
  }
  function addArgs(a,b){
    b=arguments;
    return a + b;
  }

  return addArgs;

}

addTogether(2,3);
Elbert Cortez
@trip16661
Apr 14 2016 02:45
@Jlipschitz yes but without using looping
harpoon747
@harpoon747
Apr 14 2016 02:46

Hello I am working on Caesars Cipher. Can Someone point out what mistake I am making.

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

  var o = [];
  for(i=0;i<str.length;i++)
    {
      if(str.charCodeAt(str[i]) >=65 && str.charCodeAt(str[i]) <=90)
        {
          o = str.fromCharCode(str.charCodeAt(str[i]) + 13);
        }
      else
         o = str.fromCharCode(str.charCodeAt(str[i]));

    }
  return o.join();
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

It is returning the Error :- str.fromCharCode is not a function

Ken Haduch
@khaduch
Apr 14 2016 02:49
@harpoon747 - I think that .fromCharCode() cannot be used with a string variable, but has to be referenced as String.fromCharCode() because it is a static function. That is probably the cause of that problem. (You can find more information on MDN.)
Ken Haduch
@khaduch
Apr 14 2016 02:53
@Key-Banger - looks like you are getting on the right track, but you should review the usage of the arguments object. It can be addressed like an array (although it is not fully an array.) It can also be converted to an array and then used that way. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments (but you probably know how to find it.)
Diego Mayer
@Chrono79
Apr 14 2016 02:54
@harpoon747 what @khaduch said and you should think about what to do when a charCode + 13 is not a letter
Dustin
@Key-Banger
Apr 14 2016 02:56
@khaduch Yea, I think I'm done banging my head into a wall for this evening. Thanks
CamperBot
@camperbot
Apr 14 2016 02:56
key-banger sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 937 | @khaduch | http://www.freecodecamp.com/khaduch
Dustin
@Key-Banger
Apr 14 2016 02:56
Thank you too @bitgrower :smile:
CamperBot
@camperbot
Apr 14 2016 02:57
key-banger sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 992 | @bitgrower | http://www.freecodecamp.com/bitgrower
Ken Haduch
@khaduch
Apr 14 2016 03:00
@Key-Banger - well, I think that you are on the right track. You just have to figure out how to deal with the arguments object and apply it in the right way to solve the problem. Should be good - good luck when you come back to it! You're welcome!
Norvin Burrus
@ndburrus
Apr 14 2016 03:10
are there any other js questions?
Ken Haduch
@khaduch
Apr 14 2016 03:13
@ndburrus - no, we ran out... :)
Norvin Burrus
@ndburrus
Apr 14 2016 03:13
@khaduch looks like it...
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:13

Having trouble figuring out what my problem is on Using Objects for Lookups. Keep getting the same answer of Frank no matter what I do. Here's the code. // Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line
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");

Norvin Burrus
@ndburrus
Apr 14 2016 03:14
@kevinpschwert which challenge is this?
@kevinpschwert ok got it
@kevinpschwert whoa.... it would be helpful to follow the format. check your table vs the table in the example...
@kev - see the difference?
@kevinpschwert ?
harpoon747
@harpoon747
Apr 14 2016 03:17
Can someone point out error in below code. It returns array as it is wothout rotating
function rot13(str) { // LBH QVQ VG!

  var o = "";
  for(i=0;i<str.length;i++)
    {
      var c = str.charCodeAt(i);
      if(c >=97 && c <=122)
        {
          o += String.fromCharCode(c + 13);
        }
      else
         o += String.fromCharCode(c);

    }
  return o;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
cannelflow
@cannelflow
Apr 14 2016 03:17
@kevinpschwert hint: object is key:value pair
Norvin Burrus
@ndburrus
Apr 14 2016 03:17
@kevinpschwert hint - you have an extra word in your code/table....
@kevinpschwert ...and that extra word starts with an "r"....
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:18
whenever i don't put the return in there it returns nothing. I have taken it out.
Norvin Burrus
@ndburrus
Apr 14 2016 03:18
post pls
bitgrower
@bitgrower
Apr 14 2016 03:19

@khaduch Yea, I think I'm done banging my head into a wall for this evening. Thanks

Good to know when it's time to take a break ... I tell people that it's your unconscious mind which figures it out anyway, not your conscious mind ... so sometimes you need to do stuff to get your conscious mind out of the way ...

CamperBot
@camperbot
Apr 14 2016 03:19
bitgrower sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
:star: 938 | @khaduch | http://www.freecodecamp.com/khaduch
Norvin Burrus
@ndburrus
Apr 14 2016 03:19
@kevinpschwert you have something else missing....
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:19

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

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

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

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

Chris Lacaille
@ChrisL108
Apr 14 2016 03:19
@bitgrower truee
Frank XC
@tenkdayz
Apr 14 2016 03:20
@harpoon747 charCode for capital leters starts at 64
Norvin Burrus
@ndburrus
Apr 14 2016 03:20
@kevinpschwert the code requests that the result be returned. but the only reference to result is the initial declaration. see what's missing?
@kevinpschwert hint - why are we using the key/value pairs?
Frank XC
@tenkdayz
Apr 14 2016 03:21
@harpoon747 yeah 65 - 90
Norvin Burrus
@ndburrus
Apr 14 2016 03:21
@kevinpschwert said another way, why is a lookup table being used?
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:22
It states that it is used when the input data is limited to a certain range
Norvin Burrus
@ndburrus
Apr 14 2016 03:22
@kevinpschwert might we be able to set the result to a lookup value?
Ebonie Lumpkin
@elumpkin
Apr 14 2016 03:22
I'm having trouble with the Profile Lookup exercise. Here is my code:
function lookUpProfile(firstName, prop){
// Only change code below this line
if (firstName !== "" && contacts.hasOwnProperty(prop)){
if (contacts.hasOwnProperty(firstName) ){
return contacts[prop];
}
}else if (contacts.hasOwnProperty(firstName) === false){
return "No such contact";
}else if (contacts.hasOwnProperty(prop) === false){
return "No such property";
}
Norvin Burrus
@ndburrus
Apr 14 2016 03:22
@kevinpschwert true, but, we need to use the range.
@kevinpschwert what should "result" be set equal to?
@kevinpschwert ...the lookup value, perhaps?
@kevinpschwert getting warmer?
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:24
I've been trying to figure out how to do that. That's why I had the result in the all the lookup at the first place.
Norvin Burrus
@ndburrus
Apr 14 2016 03:24
@kevinpschwert look at the last line of the example code...
@kevinpschwert your moving in the right direction - see previous comment
@kevinpschwert ok, you need to assign the lookup value to result....
@kevinpschwert ...can you do that?
@kevinpschwert ```
@kevinpschwert ```
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:29
That's what I'm trying to figure out how to do
Norvin Burrus
@ndburrus
Apr 14 2016 03:29
js
<>// Setup
function phoneticLookup(val) {
  var result = "";

  // Only change code below this line

    var lookup = {
    "alpha":"Adams",
    "bravo":"Boston",
    "charlie":"Chicago",
    "delta":"Denver",
    "echo":"Easy",
    "foxtrot":"Frank",
  };

  result = lookup[val];

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

// Change this value to test
phoneticLookup("charlie");
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:30
Thank you. I was getting thrown off by understanding how to do that. I appreciate your help very much.
Norvin Burrus
@ndburrus
Apr 14 2016 03:30
@kevinpschwert the lookup table needs to be used. it gets used when the result value gets assigned val
if you say thanks @name, i get brownie points
CamperBot
@camperbot
Apr 14 2016 03:31
ndburrus sends brownie points to @name :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for name
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:31
thanks @ndburrus
CamperBot
@camperbot
Apr 14 2016 03:31
kevinpschwert sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Apr 14 2016 03:31
your welcome....
CamperBot
@camperbot
Apr 14 2016 03:31
:star: 230 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 14 2016 03:32
@kevinpschwert do you understand it?
Diego Mayer
@Chrono79
Apr 14 2016 03:32
@harpoon747 I told you before, but you're not thinking what happens when you have a letter whose charCode is near the "border"
Let's say you have to transform V whose charCode is 86. When you add 13 to 86 the resulting char is not a letter
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:32
Yes I do...thank you. It makes sense now.
Chris Lacaille
@ChrisL108
Apr 14 2016 03:32
Hey is anyone familiar with the "Record Collection" JSON
Norvin Burrus
@ndburrus
Apr 14 2016 03:32
@kevinpschwert hey, i got a star at 230 points....
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:33
Great job!
Norvin Burrus
@ndburrus
Apr 14 2016 03:33
@kevinpschwert you put me at that mark.... there must be a chart on the wiki or something
Ken Haduch
@khaduch
Apr 14 2016 03:33
@elumpkin - hello there.
Take a look at the contacts variable. It is a structure composed of a number of objects, the "people", and they are being held in an array. So you would need to access the entries in the array in the usual way that you access array element - with some type of index. You can use a for loop to perform some action on multiple elements of the array. In this case the elements are objects, but the principle is the same, just the configuration of the element access is going to involve the object methods of "dot" notation and "bracket" notation, as needed.
Brian Zelip
@brianzelip
Apr 14 2016 03:33
@ChrisL108 yes, that's where you add some recording artist info right?
Norvin Burrus
@ndburrus
Apr 14 2016 03:33
@kevinpschwert ill have to take a look....
Chris Lacaille
@ChrisL108
Apr 14 2016 03:34
yeah I've got to here with the function you 'update'
function updateRecords(id, prop, value) {
  for (id in collection) {
    if (value !== "" && prop !== "tracks") {
      var newObj = { id : { prop: value }};
      collection[id] = newObj;
    }
  }
  return collection;
}
now im lost lol
Norvin Burrus
@ndburrus
Apr 14 2016 03:34
@kevinpschwert ok, great... that's what's important - that it makes sense. there was no assignment to result previously. now there is.... and it works...
Chris Lacaille
@ChrisL108
Apr 14 2016 03:35
Pretty sure I have 'props' and 'value' in the wrong place but I'm completely new to JSON
Brian Zelip
@brianzelip
Apr 14 2016 03:35
what's the name of the challenge so i can look it up @ChrisL108
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:35
Couldn't you create the var result later on and just make it var result = lookup[val]; instead of creating it earlier in the code?
Chris Lacaille
@ChrisL108
Apr 14 2016 03:35
Record Collection
Brian Zelip
@brianzelip
Apr 14 2016 03:35
:)
Chris Lacaille
@ChrisL108
Apr 14 2016 03:36
@ChrisL108 I feel like it's one of those issues I just wont be able to figure out until I leave it alone for a night lol my brain is full
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 03:37
Anyone can give me a hint on "Show Relationships with a Force Directed Graph" D3 challenge?
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:38
@ndburrus did you get my last question?
Chris Lacaille
@ChrisL108
Apr 14 2016 03:39
@brianzelip and I'm unsure if I'm supposed to be using collectionCopy instead?
Norvin Burrus
@ndburrus
Apr 14 2016 03:39
@kevinpschwert sorry, just saw your question.... moment/reading...
@kevinpschwert var needs to be declared/intialized...i believe....
Brian Zelip
@brianzelip
Apr 14 2016 03:41
@ChrisL108 if no you don't need to update collectionCopy
Norvin Burrus
@ndburrus
Apr 14 2016 03:41
@kevinpschwert you could try it out and see if that works
Chris Lacaille
@ChrisL108
Apr 14 2016 03:41
@brianzelip Oh okay, they really throw a JSON fast ball at you :smile:
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:42
It says it does work. It just seems redundant to create it and then recreate it later in the code.
Brian Zelip
@brianzelip
Apr 14 2016 03:42
@ChrisL108 the way I solved that one didn't include using a for loop, instead it was mostly based around an if statement
Chris Lacaille
@ChrisL108
Apr 14 2016 03:43
@brianzelip Yeah? I feel I'm stuck with my approach.. so it can't hurt
Norvin Burrus
@ndburrus
Apr 14 2016 03:43
@kevinpschwert ok, so you can set it equal to the desired result... your right that does seem cleaner...
Brian Zelip
@brianzelip
Apr 14 2016 03:44
@ChrisL108 the task isn't to cycle through, it's to compare the given input to what's in the collection given the rules specified in the instructions.
Kevin Schwert
@kevinpschwert
Apr 14 2016 03:44
Ok, just wondering. Thanks again for your help. I'm heading out for the night. Take care.
Brian Zelip
@brianzelip
Apr 14 2016 03:44
@ChrisL108 so take all the for loop stuff out, and focus on defining the rules they give you in javascript.
Chris Lacaille
@ChrisL108
Apr 14 2016 03:45
ahhh okay let me read back through! lol working tired
thanks @brianzelip
CamperBot
@camperbot
Apr 14 2016 03:45
chrisl108 sends brownie points to @brianzelip :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Apr 14 2016 03:45
@kevinpschwert it's really not re-creating it. it's just updating the initial value. but, your right. your suggestion is less verbose.
CamperBot
@camperbot
Apr 14 2016 03:45
:star: 233 | @brianzelip | http://www.freecodecamp.com/brianzelip
Brian Zelip
@brianzelip
Apr 14 2016 03:45
@ChrisL108 i had 1 if, and 2 else if statements
Chris Lacaille
@ChrisL108
Apr 14 2016 03:45
Okay i think I have an idea of what you mean :thumbsup:
Norvin Burrus
@ndburrus
Apr 14 2016 03:46
hey, i like that thumbs up. have to learn how to make that...
Taryn Trueblood
@ttrueblo
Apr 14 2016 03:46

In the Returning Boolean Values from functions, I don't understand why this function is not evaluating to true but evaluates to false: function isLess(a, b) {
// Fix this code
return a === b;
}

// Change these values to test
isLess(10, 15);

Chris Lacaille
@ChrisL108
Apr 14 2016 03:47
":thumbsup:"
Norvin Burrus
@ndburrus
Apr 14 2016 03:47
@ttrueblowhich challenge is that?
aaaah, ok :+1:
neat...
Chris Lacaille
@ChrisL108
Apr 14 2016 03:47
:sparkles:
Taryn Trueblood
@ttrueblo
Apr 14 2016 03:48
the challenge is returning boolean values from functions
Norvin Burrus
@ndburrus
Apr 14 2016 03:50
@ttrueblo ok, take a closer look at the challenge... what is the name of the function?
@ttrueblo in the code...
Taryn Trueblood
@ttrueblo
Apr 14 2016 03:50
isLess
@ndburrus isLess
Norvin Burrus
@ndburrus
Apr 14 2016 03:51
@ttrueblo yes.... now we need to use that symbology in the code (as opposed to the === in there now)
@ttrueblo ...make sense?
Diego Mayer
@Chrono79
Apr 14 2016 03:51
@ttrueblo a === b is for the function isEqual ;)
Norvin Burrus
@ndburrus
Apr 14 2016 03:51
:sparkles:
@ttrueblo ok, but what is the name of the function you mentioned previously (the function name in the code)?
Taryn Trueblood
@ttrueblo
Apr 14 2016 03:53
@ndburrus Oh, I got it now thanks!
CamperBot
@camperbot
Apr 14 2016 03:53
ttrueblo sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
:star: 231 | @ndburrus | http://www.freecodecamp.com/ndburrus
Norvin Burrus
@ndburrus
Apr 14 2016 03:53
@ttrueblo also, look at the 1st requirment to be met...aaah...ok.... super!
:shipit:
@ttrueblo your welcome.... on to the next challenge!
any other js questions i might be able to assist with?
Norvin Burrus
@ndburrus
Apr 14 2016 03:58
thanks @ChrisL108 for the :+1:
CamperBot
@camperbot
Apr 14 2016 03:58
ndburrus sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:star: 53 | @chrisl108 | http://www.freecodecamp.com/chrisl108
Chris Lacaille
@ChrisL108
Apr 14 2016 04:01
lol glad I can help! @ndburrus
What's the best method for deleting a Object 'Property'? i tried remove prop;
Chris Lacaille
@ChrisL108
Apr 14 2016 04:06
For instance if I wanted to delete 'artist'
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
}
Taryn Trueblood
@ttrueblo
Apr 14 2016 04:06
@ndburrus with this next challenge I have no clue as to what this challenge wants me to do?
Norvin Burrus
@ndburrus
Apr 14 2016 04:09
@ttrueblo hi taryn, which challenge is this?
Taryn Trueblood
@ttrueblo
Apr 14 2016 04:09
Counting Cards
Norvin Burrus
@ndburrus
Apr 14 2016 04:10
@ttrueblo it probably asks for somehting to be selected
@ttrueblo ...just a moment, let me take a look at it...
@ttrueblo i had an issue with counting cards also, i skipped that one...
can anyone assist with this one - "Counting Cards"?
<var count = 0;
var tally = 0;


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



    if (card >= 2 && card <= 6) {
      tally = (tally + 1); 
    }

      else if (card == 10) {
      tally = (tally - 1);
      }

      else if (card == 'J') {
      tally = (tally - 1);
      }
      else if (card == 'Q') {
      tally = (tally - 1);
      }
      else if (card == 'K') {
      tally = (tally - 1);
      }
      else if (card == 'A') {
      tally = (tally - 1);
      } 

count = count + tally;



if (count <= 0) {
    return count + " Hold";
    }
  else if (count > 0) {
    return count + " Bet";
  }

}

  // Only change code above this line





// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(4); cc(5); cc(6);>
Chris Lacaille
@ChrisL108
Apr 14 2016 04:13
I skipped that one too
Norvin Burrus
@ndburrus
Apr 14 2016 04:14
@ttrueblo to clean up the code, a suggestion was to use else for the letter cards.. but i'm unsure how to proceed from there... let me think for a moment...
Chris Lacaille
@ChrisL108
Apr 14 2016 04:15
wait i didnt skip
@ttrueblo I used a Witch statement
Switch*
Norvin Burrus
@ndburrus
Apr 14 2016 04:16
@ChrisL108 hmmm...switch...
brendo77
@brendo77
Apr 14 2016 04:16

hello! I'm having trouble with "Drop It".

this is returning [3,7,4] - but it should be [7,4] since 3 is not greater than 3. Any ideas? Any help appreciated.

function dropElements(arr, func) {
var shifted=0;
for (i=0;i<arr.length;i++) {
if (!func(arr[i]) && shifted == 0) {
arr.shift();
} else {
shifted=1;
}
}
return arr;
}

console.log(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}));

Chris Lacaille
@ChrisL108
Apr 14 2016 04:17
  // Only change code below this line


  switch(card) {

    case 2:
    case 3:
    case 4:
    case 5:
    case 6: 
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
    case 7:  
      break;
    case 8:  
      break;
    case 9:  
      break;


  }
  if (count > 0) {
        myStr = "Bet";
  } else {
        myStr = "Hold";
  }

  return count + " " + myStr;
  // Only change code above this line
Norvin Burrus
@ndburrus
Apr 14 2016 04:17
@ChrisL108 either way, i think there is something wrong with my if / esle if (return) statement/s
Chris Lacaille
@ChrisL108
Apr 14 2016 04:17
lol it worked? :smiley:
@ttrueblo BTW count++ is equal to count = count + 1;
brendo77
@brendo77
Apr 14 2016 04:20

hello! I'm having trouble with "Drop It".

this is returning [3,7,4] - but it should be [7,4] since 3 is not greater than 3. Any ideas? Any help appreciated.

function dropElements(arr, func) {
var shifted=0;
for (i=0;i<arr.length;i++) {
if (!func(arr[i]) && shifted == 0) {
arr.shift();
} else {
shifted=1;
}
}
return arr;
}

console.log(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}));

Taryn Trueblood
@ttrueblo
Apr 14 2016 04:21
@ChrisL108 Thanks for clarifying
CamperBot
@camperbot
Apr 14 2016 04:21
ttrueblo sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:star: 54 | @chrisl108 | http://www.freecodecamp.com/chrisl108
Chris Lacaille
@ChrisL108
Apr 14 2016 04:21
:thumbsup: @ttrueblo
@brendo77 I'm not really sure
Think your farther than me
Norvin Burrus
@ndburrus
Apr 14 2016 04:23
@ChrisL108 thank you....i get an illegal return statement with the code...
CamperBot
@camperbot
Apr 14 2016 04:23
ndburrus sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:warning: ndburrus already gave chrisl108 points
Chris Lacaille
@ChrisL108
Apr 14 2016 04:24
Are you on the same one as @ttrueblo ?
Norvin Burrus
@ndburrus
Apr 14 2016 04:24
@ChrisL108 Counting Cards, yes, i think so...
Chris Lacaille
@ChrisL108
Apr 14 2016 04:25
Here's the full code
var count = 0;

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


  switch(card) {

    case 2:
    case 3:
    case 4:
    case 5:
    case 6: 
      count++;
      break;
    case 10:
    case "J":
    case "Q":
    case "K":
    case "A":
      count--;
      break;
    case 7:  
      break;
    case 8:  
      break;
    case 9:  
      break;


  }
  if (count > 0) {
        myStr = "Bet";
  } else {
        myStr = "Hold";
  }

  return count + " " + myStr;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc("J"); cc(9);cc(2); cc(7);
Did you have it all?
@brendo77 which one are you on?
Norvin Burrus
@ndburrus
Apr 14 2016 04:27
@ChrisL108 aaah.... that did it... the var count ststament was missing, which made the return count statement illegal....
Kyle B.
@manbearkyle
Apr 14 2016 04:27
I'm getting murdered in challenge 174
Chris Lacaille
@ChrisL108
Apr 14 2016 04:27
sweetness ;p;
Norvin Burrus
@ndburrus
Apr 14 2016 04:27
:fire:
@ChrisL108 announcement - i now have no skipped challenges!! drumroll....
Benjamin Gonzalez
@xasuma
Apr 14 2016 04:29
what resources did you guys use to learn how to use api? Im working on the local weahter app.
Norvin Burrus
@ndburrus
Apr 14 2016 04:29
@xasuma i'm no there yet...
not*
Chris Lacaille
@ChrisL108
Apr 14 2016 04:30
I'm still trying to get this damn Record Collector working
Yeah @xasuma I havent got there yet either
Norvin Burrus
@ndburrus
Apr 14 2016 04:32
@ChrisL108 lloks like your 6/7 ahead of me... in js
@ChrisL108 looks*
ok, it's late.... im off to count sheep
cya tomorrow...
Chris Lacaille
@ChrisL108
Apr 14 2016 04:33
@ndburrus later :thumbsup:
Rex Smith Jr.
@rsmith731
Apr 14 2016 04:36
why pay to learn coding when you can learn for free?
Chris Lacaille
@ChrisL108
Apr 14 2016 04:37
@rsmith731 RIGHT!
Frank XC
@tenkdayz
Apr 14 2016 04:37
@rsmith731 suckers pay for class/talks
Eldar Tinjić
@EldarT90
Apr 14 2016 04:37
@xasuma best resource ever - this chat room
Chris Lacaille
@ChrisL108
Apr 14 2016 04:37
Are universities going down the :poop: 'er
Rex Smith Jr.
@rsmith731
Apr 14 2016 04:38
@ChrisL108 youtube, google, forums, docs, FCC, meet ups
plus the code thats “hot” right now won’t be the best code by the time you graduate in 4 yrs
so you would still have to learn that on your own
Chris Lacaille
@ChrisL108
Apr 14 2016 04:39
Yeah things are in constant motion in web dev :car:
@rsmith731 I agree
4 years is a long time 'on the line' lol
^^^ Neighborhood Watch anyone?
:facepunch: :satisfied:
Sherly
@sherlyc
Apr 14 2016 04:42
hi, can anyone explain why
confirmEnding("He has to give me a new name", "me") should return true.
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 04:43
which challenge @sherlyc
Chris Lacaille
@ChrisL108
Apr 14 2016 04:45
@sherlyc Something with the String.substr() method?
not sure
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 04:45
as "name" ends with "me"
confirmEnding("He has to give me a new name", "me") should return true
@sherlyc , you can use substring method and cut the given string from given string length-target string length. Then match this new string with the target string.
Chris Lacaille
@ChrisL108
Apr 14 2016 04:49
whats the best way to delete a key/value pair in a JSON object?
remove key; ?
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 04:50
@ChrisL108 ,
delete createdObj.createdkey;
Chris Lacaille
@ChrisL108
Apr 14 2016 04:51
ah okay, Thanks @arsho
CamperBot
@camperbot
Apr 14 2016 04:51
chrisl108 sends brownie points to @arsho :sparkles: :thumbsup: :sparkles:
:star: 473 | @arsho | http://www.freecodecamp.com/arsho
Chris Lacaille
@ChrisL108
Apr 14 2016 04:52
Hey @arsho how did you make that animation on your personal website? f you dont mind me asking
The letters animating on intro and the interactive background :thumbsup:
I mean, what did you use? CSS animation, JS?
Alba
@bitavee
Apr 14 2016 04:54
I need help :worried: Im stuck on this: Access MultiDimensional Arrays With Indexes, maybe im too sleepy to figure out what I need to do.
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 04:55
@ChrisL108 , I used jquery.typed.js thanks for appreciation :smile:
CamperBot
@camperbot
Apr 14 2016 04:55
arsho sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:star: 55 | @chrisl108 | http://www.freecodecamp.com/chrisl108
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 04:57
@bitavee , if are still energetic share your code/algo
Alba
@bitavee
Apr 14 2016 04:59

@arsho // Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];

// Only change code below this line.
var myData = myArray[0][0];

@arsho I apologize if it looks all crazy, I copy and pasted, still trying to figure this stuff out.
V Arun Kumar
@arunvkumr
Apr 14 2016 05:00
@bitavee var arr = [1,2,3,4] so you can access elements of array using index values like arr[0] which holds 1, arr[1] is 2, arr[2] is 3, arr[3] is 4. and index values starts from 0 and ends at array length - 1.
Now for multidimensional array. var arr= [[1,2,3],[4,5,6]] the array arr has two subarrays so you can access then using index values 0 and 1. like arr[0] which is [1,2,3] and arr[1] which is [4,5,6] now this subarrays are 1d array so you can access them like 1d array.. like arr[0][0] is 1, arr[0][1] is 2 and arr[0][2] is 3. So the syntax is arr[index1][index2], where index1 is for subarray and index2 is for elements of subarray.
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:01
@bitavee , you need to access the third row second element of the 2D array.
As you already know array is 0 indexed based try to access [2][1] position
Alba
@bitavee
Apr 14 2016 05:04
@arunkumrv Thank you. You're explanation helped alot, it actually clicked in my head now. Thank you.
CamperBot
@camperbot
Apr 14 2016 05:04
bitavee sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 456 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Dmitry Frolov
@ayatorii
Apr 14 2016 05:04
Hi guys
Alba
@bitavee
Apr 14 2016 05:05
@arsho Thank you. I think I get it now, I shall try. This is definitely my last one for the night.
CamperBot
@camperbot
Apr 14 2016 05:05
bitavee sends brownie points to @arsho :sparkles: :thumbsup: :sparkles:
:star: 475 | @arsho | http://www.freecodecamp.com/arsho
Dmitry Frolov
@ayatorii
Apr 14 2016 05:06
So i got stuck with a Profile Lookup task here: https://www.freecodecamp.com/challenges/profile-lookup
Duncan T
@dtweedle
Apr 14 2016 05:07
@ayatorii What's got you stuck?
Dmitry Frolov
@ayatorii
Apr 14 2016 05:07
Well i figured out this should work:
```
function lookUpProfile(firstName, prop){
// Only change code below this line
  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";
      }
    }
  }

  return "No such contact";
// Only change code above this line
}
but it only passes two lasts tests
and i can't really understand how should i test this
Duncan T
@dtweedle
Apr 14 2016 05:08
@ayatorii 1 Sec I'll give you a clue as to what's going wrong.
Dmitry Frolov
@ayatorii
Apr 14 2016 05:08
thanks @lsymm
CamperBot
@camperbot
Apr 14 2016 05:08
ayatorii sends brownie points to @lsymm :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for lsymm
Eldar Tinjić
@EldarT90
Apr 14 2016 05:11
need help from some1 who knows css and bs rly well
V Arun Kumar
@arunvkumr
Apr 14 2016 05:12
@ayatorii well the problem is with contacts[i].prop as prop doesn't exist in the contacts object. you have to use bracket notation for prop.
Chris Lacaille
@ChrisL108
Apr 14 2016 05:12
well prop is the argument given
parameter*
one of those lol
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:13
@ayatorii ,
as @arunkumrv mentioned try this:
// Only change code below this line
  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";
      }
    }
  }

  return "No such contact";
// Only change code above this line
Chris Lacaille
@ChrisL108
Apr 14 2016 05:13
so you can see the whole thing
Duncan T
@dtweedle
Apr 14 2016 05:14

@ayatorii You need to add square brackets for that lookup.

.prop will look an object named prop.. Where as [prop] will look up the index of an inputted property.

Dmitry Frolov
@ayatorii
Apr 14 2016 05:14
thanks guys
Chris Lacaille
@ChrisL108
Apr 14 2016 05:15
Are 'argument' and 'parameter' interchangeable?
V Arun Kumar
@arunvkumr
Apr 14 2016 05:17
@ChrisL108 imo both are the same.. arguments is used for function defination and parameter is used for calling a function.
Frank XC
@tenkdayz
Apr 14 2016 05:17
@ChrisL108 yes
Chris Lacaille
@ChrisL108
Apr 14 2016 05:17
@arunkumrv sorry lol im dumb :thumbsup:
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:17
argument is the function definition signature and parameter is the value/reference that is passing to that function.
For example:
function add(num1,num2) // these are arguments
{

}
add(5,8); // these are parameters
Chris Lacaille
@ChrisL108
Apr 14 2016 05:17
ok yeah that's kind of how i saw it too @arunkumrv
Dmitry Frolov
@ayatorii
Apr 14 2016 05:18
does it work like this because prop variable can contain spaces?
Chris Lacaille
@ChrisL108
Apr 14 2016 05:18
@arsho @arunkumrv thanks, I just had the 2 kinda mixed up
CamperBot
@camperbot
Apr 14 2016 05:18
chrisl108 sends brownie points to @arsho and @arunkumrv :sparkles: :thumbsup: :sparkles:
:warning: chrisl108 already gave arsho points
:star: 457 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Dmitry Frolov
@ayatorii
Apr 14 2016 05:18
@ChrisL108 @Isymm @arunkumrv Thanks!
CamperBot
@camperbot
Apr 14 2016 05:19
ayatorii sends brownie points to @chrisl108 and @isymm and @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 307 | @isymm | http://www.freecodecamp.com/isymm
:star: 458 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
:star: 59 | @chrisl108 | http://www.freecodecamp.com/chrisl108
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:19
nah because prop is not a property of that object @ayatorii
V Arun Kumar
@arunvkumr
Apr 14 2016 05:20
@ayatorii well dot notation is used when the prop exist in object like object.like this works if like is present in object and it is same as object["like"]. but if you have a value that you are getting from a function you have to use like object[prop] where prop holds the property name.
Zach
@Moose1551
Apr 14 2016 05:20
Is there a way to put each element of a string into its own array? I know that if I'm testing "cat," I can do split(''), and get ["c", "a", "t"], but how could I get [[c],[a],[t]]?
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:24

@Moose1551 ,
code:

var ar=[];
var wordAr="cat".split("");
wordAr.map(function(c){
  ar.push([c]);
})
console.log(ar);

output:

[ [ 'c' ], [ 'a' ], [ 't' ] ]
Chris Lacaille
@ChrisL108
Apr 14 2016 05:25
@arsho :thumbsup: I need to learn map() & filter() lol
Zach
@Moose1551
Apr 14 2016 05:25
Thanks, @arsho !
CamperBot
@camperbot
Apr 14 2016 05:25
moose1551 sends brownie points to @arsho :sparkles: :thumbsup: :sparkles:
:star: 477 | @arsho | http://www.freecodecamp.com/arsho
Ahmedur Rahman Shovon
@arsho
Apr 14 2016 05:26
ya. these are awesome features of JS that reduce Line of Code (LOC) and time. @ChrisL108
V Arun Kumar
@arunvkumr
Apr 14 2016 05:26
@Moose1551 you could also try this..
"cat".split('').map((val) => { return [val]; });
Robert Valmassoi
@valmassoi
Apr 14 2016 05:26
This message was deleted
This message was deleted
This message was deleted
This message was deleted
This message was deleted
V Arun Kumar
@arunvkumr
Apr 14 2016 05:29
@valmassoi you should look at front end room that is completely for front end stuffs
help rooms
CamperBot
@camperbot
Apr 14 2016 05:29

:point_right: help rooms [wiki]

FreeCodeCamp Chat Rooms

Help Rooms

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

Choose the right room for your questions!

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

back to top

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

Xf
@Darcy-FzR
Apr 14 2016 05:52

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

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

if(contacts[i].firstName == firstN ){
  if(contacts[i].firstName.hasOwnProperty(prop)){
    return contacts[i][prop];
  }else{
    return "No such property";
  }
}else{
  return "No such contact";
}
is there anything wrong?
Chris Lacaille
@ChrisL108
Apr 14 2016 05:55
@Darcy-FzR does line one actually have "firstN"
Xf
@Darcy-FzR
Apr 14 2016 05:57
I @ChrisL108 I just changed the arg name of the function lookUPProfile
function lookUpProfile(firstN, prop){
// Only change code below this line
Chris Lacaille
@ChrisL108
Apr 14 2016 05:58
@Darcy-FzR ah okay, just checking lol
V Arun Kumar
@arunvkumr
Apr 14 2016 05:59
@Darcy-FzR don't change the code which are not in the comment lines that says only change code below and above. that may break the code and will not work.
Remove else clause of No such contact and move it outside the for loop.
Xf
@Darcy-FzR
Apr 14 2016 06:04
This message was deleted
This message was deleted
This message was deleted
function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName == firstName ){
if(contacts[i].firstName.hasOwnProperty(prop)){
return contacts[i][prop];
}else{
return "No such property";
}
}
}
return "No such contact";
// Only change code above this line
}
Chris Lacaille
@ChrisL108
Apr 14 2016 06:05
In 'Nesting For Loops' I am multiplying all elements in an array.. can someone tell me what I'm missing..?
function multiplyAll(arr) {
  var product = 1;
  // Only change code below this line
  for (var x =0; x<arr.length;x++) {
    for (var y=0; y<arr[x].length;y++) {
      console.log(( arr[x][y] ) ); 
      product =+ arr[x][y];
    }
  }
  // Only change code above this line
  return product;
}

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);  //Should equal 6... getting 3...
oops product += not =+ lol
still not working :worried:
getting 7 instead of 6 on last line
Xf
@Darcy-FzR
Apr 14 2016 06:08
@ChrisL108 product *= arr[i][j];
V Arun Kumar
@arunvkumr
Apr 14 2016 06:08
@Darcy-FzR contacts[i].firstName.hasOwnProperty(prop) //<- check this line.
contacts[i] is an object and contacts[i].firstName returns the value of firstName property and it's is not an object so you can't use contacts[i].firstName.hasOwnProperty(prop)you have to check if contacts[i] has the property.
Chris Lacaille
@ChrisL108
Apr 14 2016 06:09
ah got it. Thanks @Darcy-FzR !
CamperBot
@camperbot
Apr 14 2016 06:09
chrisl108 sends brownie points to @darcy-fzr :sparkles: :thumbsup: :sparkles:
:star: 236 | @darcy-fzr | http://www.freecodecamp.com/darcy-fzr
Elbert Cortez
@trip16661
Apr 14 2016 06:09
guys is there a more efficient way to do this ?
function diffArray(arr1, arr2) {
  var newArr = [];
  for(a = 0; a < arr1.length; a++){
    if(arr2.indexOf(arr1[a]) <= -1){
      newArr.push(arr1[a]);
    }  
  }
  for(b = 0; b < arr2.length; b++){
  if(arr1.indexOf(arr2[b]) <= -1){
    newArr.push(arr2[b]);
  }
}  // Same, same; but different.
  return newArr;
}

diffArray([1, 2, 3, 5, 7], [1, 2, 3, 4, 5]);
Xf
@Darcy-FzR
Apr 14 2016 06:15
@ChrisL108 lol
@arunkumrv You are right/ Thank you!
CamperBot
@camperbot
Apr 14 2016 06:16
darcy-fzr sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 459 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Chris Lacaille
@ChrisL108
Apr 14 2016 06:16
brains a lil foggy lol i need to go to sleep
V Arun Kumar
@arunvkumr
Apr 14 2016 06:17
@Darcy-FzR You're welcome :+1: happy coding :smile: ~
Frank XC
@tenkdayz
Apr 14 2016 06:19
@trip16661 you could use array.includes()
Elbert Cortez
@trip16661
Apr 14 2016 06:22
@tenkdayz but that would be kind of the same using two foorloops
is the same as indexOf
Frank XC
@tenkdayz
Apr 14 2016 06:25
@trip16661 you just need one the way your doing it
Elbert Cortez
@trip16661
Apr 14 2016 06:26
how ?
Frank XC
@tenkdayz
Apr 14 2016 06:27
function diffArray(arr1, arr2) {
  var newArr = [];
  for(a = 0; a < arr1.length; a++){
    if(arr2.indexOf(arr1[a]) <= -1){
      newArr.push(arr1[a]);
    }  
  if(arr1.indexOf(arr2[b]) <= -1){
    newArr.push(arr2[b]);
  }
}
  return newArr;
}
change b to a
brendo77
@brendo77
Apr 14 2016 06:34

Hi All - doing "Drop It" - I'm stuck - the result is 3,7,4 - yet 3 is not > 3 - any help appreciated!

function dropElements(arr, func) {
// Drop them elements.
var shifted=0;
for (i=0;i<arr.length;i++) {
if (!func(arr[i]) && shifted == 0) {
arr.shift();
} else {
shifted=1;
}
}
return arr;
}

dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;});

Elbert Cortez
@trip16661
Apr 14 2016 06:39
@tenkdayz where is b initialized
Frank XC
@tenkdayz
Apr 14 2016 06:39
@trip16661 nevermind.. just checked the challenge . ..that would work assuming both arrays are the same length
Elbert Cortez
@trip16661
Apr 14 2016 06:41
y
@tenkdayz but anyway thanks for taking your time :) im just being annoying about it
CamperBot
@camperbot
Apr 14 2016 06:41
trip16661 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 385 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Frank XC
@tenkdayz
Apr 14 2016 06:43
@trip16661 np.. but youre right .. it feels like there should be a more efficient way of doing it
Chris Lacaille
@ChrisL108
Apr 14 2016 06:45
@brendo77 should you run 'shifted =1' when arr.shift() is run?
nvm ignore me I don't know what's going on in that lol
brendo77
@brendo77
Apr 14 2016 06:48
@ChrisL108 ha thanks. I'm using that shifted var to try and exit the loop when the function is true
CamperBot
@camperbot
Apr 14 2016 06:48
brendo77 sends brownie points to @chrisl108 :sparkles: :thumbsup: :sparkles:
:star: 65 | @chrisl108 | http://www.freecodecamp.com/chrisl108
Chris Lacaille
@ChrisL108
Apr 14 2016 06:50
:thumbsup: @brendo77
Frank XC
@tenkdayz
Apr 14 2016 06:51
@brendo77 to exit a for loop you could use return fail. fyi
Jackson Bates
@JacksonBates
Apr 14 2016 06:51
Non urgent question...I've used python a fair bit over the years, so the parts that are 'missing' (i.e. just different) in Javascript often catch me out. Today I found a comparison technique I use in Python that has the same syntax but behaves differently in js. For example, if I want to check whether an item is in an array, eg a = [1,1,2,2,3] in python I can just type 1 in a and it will return true, or 4 in a and it will return false. In js you can use the same code, but it returns true for BOTH of them (I'm assuming it is saying that the index is there rather than the value?). Can anyone tell me what operation js is performing when I type 1 in a so I can read up on it more? (or just explain it to me :) )...
Frank XC
@tenkdayz
Apr 14 2016 06:51
return false.**
Jackson Bates
@JacksonBates
Apr 14 2016 06:52
btw, I know how to actually check inside the array in js...just curious about this specific case
brendo77
@brendo77
Apr 14 2016 06:52
@tenkdayz ooh nice! thank you
CamperBot
@camperbot
Apr 14 2016 06:52
brendo77 sends brownie points to @tenkdayz :sparkles: :thumbsup: :sparkles:
:star: 386 | @tenkdayz | http://www.freecodecamp.com/tenkdayz
Frank XC
@tenkdayz
Apr 14 2016 06:55
@JacksonBates you can use a.includes(number)
Elbert Cortez
@trip16661
Apr 14 2016 06:55
@JacksonBates looping ?
Frank XC
@tenkdayz
Apr 14 2016 06:57
@JacksonBates when you use 0 in a or 4 in a ..in js the 0 and 4 refers to the index in an array
Jackson Bates
@JacksonBates
Apr 14 2016 06:59
@rujool beauty! I kept googling things like 'item in array' and I was getting SO questions about how to replicate the specific python way in JS, not getting details. I feel like an idiot for not just googling in operator!!! It's been a long day (that's my excuse anyway) thanks
CamperBot
@camperbot
Apr 14 2016 06:59
jacksonbates sends brownie points to @rujool :sparkles: :thumbsup: :sparkles:
:star: 305 | @rujool | http://www.freecodecamp.com/rujool
Coredelle
@coredelle
Apr 14 2016 07:01
function nextInLine(arr, item) {
nextInLine.push(item);
return nextInLine.shift();
can anyone help me understand why this should be arr.push(item) instead of nextInLine.push(item)?
Elbert Cortez
@trip16661
Apr 14 2016 07:03
@coredelle use proper format
help format
CamperBot
@camperbot
Apr 14 2016 07:03

: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 the code.

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

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

Coredelle
@coredelle
Apr 14 2016 07:06

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

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

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

CamperBot
@camperbot
Apr 14 2016 07:06
:bulb: to format code use backticks! ``` more info
Rujool Doshi
@rujool
Apr 14 2016 07:07
@coredelle is nextInLine an array?
Coredelle
@coredelle
Apr 14 2016 07:08
@rujool no it's a queue
Rujool Doshi
@rujool
Apr 14 2016 07:11
@coredelle Isnt nextInLine the function? How r u using push() on it
Coredelle
@coredelle
Apr 14 2016 07:13
@rujool oh! the switch just flipped for me. youre right, rookie mistake. thanks
CamperBot
@camperbot
Apr 14 2016 07:13
coredelle sends brownie points to @rujool :sparkles: :thumbsup: :sparkles:
:star: 306 | @rujool | http://www.freecodecamp.com/rujool
Eldar Tinjić
@EldarT90
Apr 14 2016 07:26
need help with ADVANCED css+bs, thanks
yuluoqianmu
@yuluoqianmu
Apr 14 2016 07:28
hello ,im newer
John Delaney
@jdpunk1
Apr 14 2016 07:41
Morning, here's something that's a bit weird..
I'm trying to use the following type of code in a for loop, basically I want to maintain the original array structure so I copy it to a new array, however...
```array1=[1,2,3]
[1, 2, 3]
myarr=array1
[1, 2, 3]
myarr.splice(0,1);
[1]
myarr
[2, 3]
myarr=array1;
[2, 3]
array1
[2, 3]
array1 gets overwritten
Jae Kim
@JSOdin
Apr 14 2016 07:42
if you want to copy an array, do var copyOfArray = thisArray.slice()
from what you wrote I cant see what youre tryign to do
you put console.log() in various places right ?
ok im going to ignore all the stuff thats printed, and tell you that myarr = array1 does not create a copy of array1, it serves as a pointer to the original object so in essence, myarr IS the original array. so doing things to myarr is the same as directly manipulating array1
John Delaney
@jdpunk1
Apr 14 2016 07:50
Right, that's what I suspected must have been happening. Is there a way to force it to copy rather than reference?
Jae Kim
@JSOdin
Apr 14 2016 07:50
@jdpunk1 yes, var myarr = array1.slice() that creates a copy
Ankit Panwar
@coderNoob
Apr 14 2016 07:50
I've have passed all the test cases in Make a Person BF but I'm still can't move to the next one. Apparently I can only pass the test case if it is the only function being called.
var Person = function(firstAndLast) {
  var fullName = firstAndLast;
  var first = firstAndLast.split(" ")[0];
  var last = firstAndLast.split(" ")[1];

  this.getFirstName = function(){
    return first;
  };

  this.getLastName = function(){
    return last;
  };

  this.getFullName = function(){
    return first+" "+last;
  };

  this.setFirstName = function(name){
    first = name;
  };

  this.setLastName = function(name){
    last = name;
  };

  this.setFullName = function(name){
    fullName = name;
  };

};
var bob = new Person('Bob Ross');
bob.getFirstName();
bob.getLastName();
bob.getFullName();
bob.setFirstName("Haskell");
bob.getFirstName();
bob.getFullName();
bob.setLastName("Curry");
bob.getFullName();
bob.setFullName("Haskell Curry");
bob.getFullName();
bob.getLastName();
John Delaney
@jdpunk1
Apr 14 2016 07:51
@JSOdin Cool, thanks!
CamperBot
@camperbot
Apr 14 2016 07:51
jdpunk1 sends brownie points to @jsodin :sparkles: :thumbsup: :sparkles:
:star: 147 | @jsodin | http://www.freecodecamp.com/jsodin
Jae Kim
@JSOdin
Apr 14 2016 07:51
np
Ankit Panwar
@coderNoob
Apr 14 2016 07:51
Once I call any of the setter methods, the other test cases fail.
Jae Kim
@JSOdin
Apr 14 2016 07:52
on first glance I dont see much wrong with the code
Ankit Panwar
@coderNoob
Apr 14 2016 07:54
I think it's a bug.
Jae Kim
@JSOdin
Apr 14 2016 07:55
@coderNoob I may be missing somethign so imma run it on my IDE
Astrid Feo
@astridfeo
Apr 14 2016 07:56
I'm having trouble with a assigment, the function should check if firstName is an actual contact's firstName and the given property (prop) is a property of that contact.
If both are true, then return the "value" of that property. This is the code I've written, but I can't figure out why it doesn't work.
//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 (contacts[firstName] === firstName && prop !== "") {
      return contacts[firstName][prop];
    }
    else if (contacts[firstName] !== firstName) {
      return "No such contact";
    }
    else {
      return "No such property";
    }
  }
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Jae Kim
@JSOdin
Apr 14 2016 07:57
@coderNoob ok theres absolutely nothign wrong with your code, everything returned what was expected
Ankit Panwar
@coderNoob
Apr 14 2016 07:57
@astridfeo contacts is not an object. It's an array of objects. So it should be something like contacts[i].firstName
lcthornhill
@lsrus
Apr 14 2016 07:57
@coderNoob from looking at this, your setFullName method changes the fullName variable, but first and last variables are never updated during the setFullName method
Jae Kim
@JSOdin
Apr 14 2016 07:58
@isrus rofl I missed that, nice
lcthornhill
@lsrus
Apr 14 2016 07:59
Jae Kim
@JSOdin
Apr 14 2016 07:59
@lsrus his test cases dont appear to cover that though u r right
Ankit Panwar
@coderNoob
Apr 14 2016 07:59

@lsrus If I did it like

var fullName = firstAndLast;
  var first = fullName.split(" ")[0];
  var last = fullName.split(" ")[1];

It should work?

lcthornhill
@lsrus
Apr 14 2016 08:00
@coderNoob that code only runs once, when you originally make the Person object
Jae Kim
@JSOdin
Apr 14 2016 08:01
   var self = this;

   this.setFullName = function(name){
        fullName = name;
        self.setFirstName(name.split(' ')[0]);
        self.setLastName(name.split(' ')[1])
    };
Ankit Panwar
@coderNoob
Apr 14 2016 08:02
@lsrus So instead of a global variable, I should put the first and last names in each setter method like this ?
fullName = fullName.split(" ")[0] + " " + name;
@JSOdin @lsrus Thanks a lot
CamperBot
@camperbot
Apr 14 2016 08:02
codernoob sends brownie points to @jsodin and @lsrus :sparkles: :thumbsup: :sparkles:
:star: 369 | @lsrus | http://www.freecodecamp.com/lsrus
:star: 148 | @jsodin | http://www.freecodecamp.com/jsodin
lcthornhill
@lsrus
Apr 14 2016 08:03
@coderNoob sorry if I misttok your meaning :-)
@JSOdin hi, btw :+1:
Sameer Shamsudeen
@sameershamsudheen
Apr 14 2016 08:07
hi i was doing profile lookup challenge in Javascript, please tell me what is wrong with my code, how to correct my errors.
My Code
function lookUpProfile(firstName, prop){
// Only change code below this line
if(firstName === contacts[firstName] && prop === contacts[prop]){
return contacts[prop]; 
}
  if(firstName !== contacts[firstName]) {
    return "No such contact";
  }
  if(prop !== contacts[prop]){
     return "No such property";
  }
// Only change code above this line
}
Jae Kim
@JSOdin
Apr 14 2016 08:08
@astridfeo ok I dont see you iterating over contacts, you have contacts[firstName] instead of contacts[i][firstName]
@astridfeo all of your conditional blocks have that same mistake in them
@sameershamsudheen you need to wrap the conditionals in a loop
Sameer Shamsudeen
@sameershamsudheen
Apr 14 2016 08:11
@JSOdin Ok will be back thank You
CamperBot
@camperbot
Apr 14 2016 08:11
sameershamsudheen sends brownie points to @jsodin :sparkles: :thumbsup: :sparkles:
:star: 150 | @jsodin | http://www.freecodecamp.com/jsodin
Jae Kim
@JSOdin
Apr 14 2016 08:12
@lsrus :thumbsup:
Rada
@Radascript
Apr 14 2016 08:19
hey guys I'm working on the Exact Change challenge. They are looking for answers to be in form ["TWENTY", 60.00], ["TEN", 20.00] etc. I was wondering how to make sure it's like that rather than ["TWENTY", 60], ["TEN", 20]
Jae Kim
@JSOdin
Apr 14 2016 08:20
parseFloat(num.toFixed(2))
@Radascript parseFloat(num.toFixed(2))
Sameer Shamsudeen
@sameershamsudheen
Apr 14 2016 08:21
@JSOdin Still my code not working
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i < contacts.length; i++){
  if(firstName === contacts[i][firstName] && prop === contacts[i][prop]){
return contacts[i][prop]; 
}
}
for (i=0; i < contacts.length; i++){
  if(firstName !== contacts[i][firstName]) {
    return "No such contact";
  }
}
  for (i=0; i < contacts.length; i++){
  if(prop !== contacts[i][prop]) {
    return "No such contact";
  }
}
// Only change code above this line
}
Rada
@Radascript
Apr 14 2016 08:21
@JSOdin thanks Jae!
CamperBot
@camperbot
Apr 14 2016 08:21
radascript sends brownie points to @jsodin :sparkles: :thumbsup: :sparkles:
:star: 159 | @jsodin | http://www.freecodecamp.com/jsodin
Jae Kim
@JSOdin
Apr 14 2016 08:22
@Radascript np
@sameershamsudheen you only need one loop, put all the if() blocks into one loop
Sameer Shamsudeen
@sameershamsudheen
Apr 14 2016 08:27
@JSOdin Done, still 4 more errors :smile:
function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i < contacts.length; i++){
  if(firstName === contacts[i][firstName] && prop === contacts[i][prop]){
return contacts[i][prop]; 
}
  if(firstName !== contacts[i][firstName]) {
    return "No such contact";
  }
  if(prop !== contacts[i][prop]) {
    return "No such property";
  }
}
// Only change code above this line
}
Blauelf
@Blauelf
Apr 14 2016 08:32
Test for property with hasOwnProperty, also, it should be contacts[i]["firstName"] or contacts[i].firstName. And don't return "No such contact" from within the loop, you might meet that person in another iteration, but after your loop you can be sure to not have met him/her.
@Radascript Return numbers, not strings, nobody cares how these numbers are formatted as they all are the same, 60, 60.0, 60.000000, and are formatted only for displaying (and you cannot influence that if you pass a number)
Jae Kim
@JSOdin
Apr 14 2016 08:36
@sameershamsudheen yeah @Blauelf got it, "return" from a for loop basically cuts the loop short and puts you out of the function
@sameershamsudheen @Blauelf care to link the challenge? I havent taken a look at it
Reginald Holt
@Reggiereg83
Apr 14 2016 08:37
How would i assign a to b with =????
Blauelf
@Blauelf
Apr 14 2016 08:37
b=a
assign the value of a to b means b=a :)
chibicorpse
@chibicorpse
Apr 14 2016 08:38
sup, guys - can anyone help with the word-blanks task? I really don't know what to do here
can't understand the task
Jae Kim
@JSOdin
Apr 14 2016 08:38
@chibicorpse put link here
Reginald Holt
@Reggiereg83
Apr 14 2016 08:39
thanks @Blauelf
CamperBot
@camperbot
Apr 14 2016 08:39
reggiereg83 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
CamperBot
@camperbot
Apr 14 2016 08:39
:star: 1624 | @blauelf | http://www.freecodecamp.com/blauelf
Eldar Tinjić
@EldarT90
Apr 14 2016 08:39
@Blauelf hey blue elf ^^ do you have lil bit of time to take a look at my project? I have big problem with css
Sameer Shamsudeen
@sameershamsudheen
Apr 14 2016 08:40
@Blauelf thanks for your support
CamperBot
@camperbot
Apr 14 2016 08:40
sameershamsudheen sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1625 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Apr 14 2016 08:40
Not so much a CSS guy, but maybe I can spot an obvious mistake ;)
Jae Kim
@JSOdin
Apr 14 2016 08:40
@chibicorpse it appears to just ask you make a sentence with your inputs
Eldar Tinjić
@EldarT90
Apr 14 2016 08:41
@Blauelf http://codepen.io/EldarT/pen/xVWqPZ i want these elements to be centralized, regardless if its 4 or 3 or 2 tbox-purbple boxes in a row
i want them to be in center
chibicorpse
@chibicorpse
Apr 14 2016 08:42
@JSOdin hm, can you give me a hint - how to do this with what i have? feeling like a total noob :-(
Puvendran Pillay
@puven12
Apr 14 2016 08:42
I need help with Record Collection challenge. I dont understand my instruction.
Ian Barker
@IanBarkerDev
Apr 14 2016 08:42
@EldarT90 text-align center?
Eldar Tinjić
@EldarT90
Apr 14 2016 08:43
@IanBarkerDev not working, nor margin 0 auto nor display inline-block worked on parents, children or combined elements
@IanBarkerDev i think i tried all these combos, it just wont work
Jae Kim
@JSOdin
Apr 14 2016 08:43
@chibicorpse concatenate your inputs onto "results", in an order that makes grammatical sense
Blauelf
@Blauelf
Apr 14 2016 08:44
@EldarT90 What should it look like if you had 4-4-3 elements in the rows?
Puvendran Pillay
@puven12
Apr 14 2016 08:44
help
Jae Kim
@JSOdin
Apr 14 2016 08:44
@chibicorpse cant tell you more because ill just be giving away the answer
Eldar Tinjić
@EldarT90
Apr 14 2016 08:44
@Blauelf it is 12 "boxes" ; so its either 4x3 or 3x4 or 2x6 or 1x12
@Blauelf im not sure how cna you get 4-4-3
Blauelf
@Blauelf
Apr 14 2016 08:44
@EldarT90 Ah, always 12, that's already some information :)
Ian Barker
@IanBarkerDev
Apr 14 2016 08:45
Ewww. Bootstrap.
Eldar Tinjić
@EldarT90
Apr 14 2016 08:45
@IanBarkerDev =(
Jae Kim
@JSOdin
Apr 14 2016 08:45
@IanBarkerDev gets the job done though ;p
Ian Barker
@IanBarkerDev
Apr 14 2016 08:46
@JSOdin Yeah but then you get frustrated because things don't work like you want them to and it's hard to adapt it.
Blauelf
@Blauelf
Apr 14 2016 08:47
@EldarT90 Then what about 5-5-2? Is that even desired or should it switch to 4-4-4 then?
Eldar Tinjić
@EldarT90
Apr 14 2016 08:48
@Blauelf i would like it to be max at 4 , is that possible
Jae Kim
@JSOdin
Apr 14 2016 08:48
@IanBarkerDev true, I actually used Foundation on a personal project instead of Bootstrap because I found the various classes and nesting of elements pretty annoying , but now I see bootstrap is a pretty nice toolkit once you get used to it
Eldar Tinjić
@EldarT90
Apr 14 2016 08:48
@Blauelf even if the screen widht is 2000px, would like to keep it 4-4-4
@Blauelf width*
Jae Kim
@JSOdin
Apr 14 2016 08:48
@IanBarkerDev it also has more functionality
Eldar Tinjić
@EldarT90
Apr 14 2016 08:49
@JSOdin @IanBarkerDev i have feeling bootstrap is rly good for both amateurs and pros; ppl that have problem with bootstrap are usually in the middle - the ones who want customized website but dont udnerstand bs functionality fully ^^ i might be wrong though
Jae Kim
@JSOdin
Apr 14 2016 08:51
@EldarT90 yeah customizing bootstrap css/js is a pain sometimes
Blauelf
@Blauelf
Apr 14 2016 08:51
@EldarT90 It looks somewhat ugly that you use an inline element <a> around a block element <div>
Nari Roh
@NariRoh
Apr 14 2016 08:52
Help Multiple Identical Options in Switch Statements
CamperBot
@camperbot
Apr 14 2016 08:52

:point_right: challenge multiple identical options in switch statements [wiki]

Challenge: Multiple Identical Options in Switch Statements

If the break statement is ommitted from a switch statement's case, the following case statement(s) are executed until a break is encountered. If you have multiple inputs with the same output, you can represent them in a switch statement like this:

switch(val) {
  case 1:
  case 2:
  case 3:
    result = "1, 2, or 3";
    break;
  case 4:
    result = "4 alone";
}

Cases for 1, 2, and 3 will all produce the same result.
:pencil: read more about challenge multiple identical options in switch statements on the FCC Wiki

Eldar Tinjić
@EldarT90
Apr 14 2016 08:53
@Blauelf hmm , i wanted it to be "clickable" , as a whole element
kirbyedy
@kirbyedy
Apr 14 2016 08:53
@EldarT90 this is how your app looks on 4k
Eldar Tinjić
@EldarT90
Apr 14 2016 08:53
i dont know other tehcniqeu xD
kirbyedy
@kirbyedy
Apr 14 2016 08:53
Screen Shot 2016-04-14 at 11.52.15.png
Eldar Tinjić
@EldarT90
Apr 14 2016 08:54
@kirbyedy yep it has 2 problems: 1 - its not centered 2 - it has more than 4 elements in 1 row
brendo77
@brendo77
Apr 14 2016 08:54
hello! Anyone familiar with the "Drop It" lesson?
I'm about to lose my collective poo
Ian Barker
@IanBarkerDev
Apr 14 2016 08:54
@brendo77 What's the goal?
brendo77
@brendo77
Apr 14 2016 08:55
Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.
Ian Barker
@IanBarkerDev
Apr 14 2016 08:57
So a while loop with a pop inside?
brendo77
@brendo77
Apr 14 2016 08:57
function dropElements(arr, func) {
  // Drop them elements.
  var foundMatch=0;

  for (i=0;i<arr.length;i++) {
    if (!func(arr[i]) && foundMatch === 0) {  
      arr.shift();
    } else {
      foundMatch=1;
    }    
  }
  return arr;
}

console.log(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}));
that should return [7,4] but it returns [3,7,4] (but 3 is not > 3 ??)
Blauelf
@Blauelf
Apr 14 2016 08:59
You might want to check func(arr[0]) instead. Also, condition should not be for (var i=0; i<arr.length; i++) but better something like while (arr.length && !foundMatch)
brendo77
@brendo77
Apr 14 2016 09:00
@Blauelf oh snap! yes - because arr(0) keeps shifting - thank you thank you - omg! so obvious now ha.
CamperBot
@camperbot
Apr 14 2016 09:00
brendo77 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1626 | @blauelf | http://www.freecodecamp.com/blauelf
Dragan
@daces
Apr 14 2016 09:01
@EldarT90 if you put margin: 0 auto; width: 1220px; in .row that will make it center
but its not responsive
Blauelf
@Blauelf
Apr 14 2016 09:03
@brendo77 Your loop might end too early if you keep shortening the array while you test arr.length in the condition, so better use that while loop I gave to you :)
usharya
@usharya
Apr 14 2016 09:04
stuck
doing the challenge "Iterate Through an Array with a For Loop"
here is my code
var total = 0;

for (var i=0; i < myArr.length; i++) {
  total = total + i;
}
Brendan Kinahan
@BKinahan
Apr 14 2016 09:04
mornin' y'all
usharya
@usharya
Apr 14 2016 09:04
morning @BKinahan
Craig Banach
@CraigBanach
Apr 14 2016 09:04
@usharya What tests are you failing?
Blauelf
@Blauelf
Apr 14 2016 09:05
@usharya You might not want to add i (the index), but myArr[i] (the corresponding array element), depending on the task.
Brendan Kinahan
@BKinahan
Apr 14 2016 09:05
@usharya at the end of the loop, total will be equal to the sum of the indices of the array, but not much else will happen.
Eldar Tinjić
@EldarT90
Apr 14 2016 09:05
@daces well, i want it to be responsive :/
but it looks like its really difficult problem
i am for almost 5 hours in chat rooms asking for an advice
manyp ppl tried, but ... in the end no perfect solution
usharya
@usharya
Apr 14 2016 09:06
@Blauelf why did we did myArr[i]?
brendo77
@brendo77
Apr 14 2016 09:08
@Blauelf thank you thank you - 2 evening on that thing!!
CamperBot
@camperbot
Apr 14 2016 09:08
brendo77 sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: brendo77 already gave blauelf points
Blauelf
@Blauelf
Apr 14 2016 09:08
It's the (i+1)th element of myArr (+1 as in our language we use 1-based indexing, while programming languages use 0-based indexing, which relates to the offset to the array start in a contiguous array structure)
Puvendran Pillay
@puven12
Apr 14 2016 09:08
Help Record Collection
CamperBot
@camperbot
Apr 14 2016 09:08

:point_right: checkpoint record collection [wiki]

Checkpoint: Record Collection

Instructions

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

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

For the given id in collection:

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

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

If value is blank, delete that prop.

Always return the entire collection object.

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

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

usharya
@usharya
Apr 14 2016 09:08
@Blauelf Ahh, I see. Thank you once more :)
CamperBot
@camperbot
Apr 14 2016 09:08
usharya sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1627 | @blauelf | http://www.freecodecamp.com/blauelf
Ian Barker
@IanBarkerDev
Apr 14 2016 09:11
@EldarT90 Why are they all in one row?
usharya
@usharya
Apr 14 2016 09:12
what are some materials that I can read for understanding javascript better?
Ian Barker
@IanBarkerDev
Apr 14 2016 09:12
@usharya Is JavaScript your first language?
Eldar Tinjić
@EldarT90
Apr 14 2016 09:12
@IanBarkerDev when they arent, i get 3-1-3-1 format on smaller resolutions
stuli5
@stuli5
Apr 14 2016 09:12
helllo can anybody help myVar = myVar++; still doesnt work myVar should be changed
Samuel Cupidon
@Zerazera
Apr 14 2016 09:13
@stuli5 myVar++ is syntactically equivalent to myVar = myVar + 1
stuli5
@stuli5
Apr 14 2016 09:13
I know
Blauelf
@Blauelf
Apr 14 2016 09:13

@brendo77 A while-loop seems perfect here (at least I think so), but you could also use a return inside the loop:

  for (var i = 0; i < arr.length; i++) {
    if (func(arr[i])) {
      return arr.slice(i);
    }
  }
  return [];

or recursive

  return !arr.length? [] : func(arr[0])? arr : dropElements(arr.slice(1), func);
Samuel Cupidon
@Zerazera
Apr 14 2016 09:13
@stuli5 Then you should know that you don't need the assignment
o boffill
@oboff
Apr 14 2016 09:13
what should be the strategy when wanting to verify that N k:v pairs are fully contained within N objects of N k:v pairs?
a counter variable?
stuli5
@stuli5
Apr 14 2016 09:15
cd.jpg
@Zerazera what do you mean? what is the problem
o boffill
@oboff
Apr 14 2016 09:15
@stuli5 myVar++
Samuel Cupidon
@Zerazera
Apr 14 2016 09:15
@myVar++ increases myVar by 1 and assigns the result to myVar
o boffill
@oboff
Apr 14 2016 09:15
its inplace increment
Samuel Cupidon
@Zerazera
Apr 14 2016 09:16
@stuli5 Your statement is equivalent to myVar = myVar = myVar + 1
Blauelf
@Blauelf
Apr 14 2016 09:16
@oboff I would use things like every(), a counter only makes sense if the outcome is not based on some all/none condition.
o boffill
@oboff
Apr 14 2016 09:16
ah every! havent seen that one
stuli5
@stuli5
Apr 14 2016 09:17
I know but I have still the problem with myVar should be changed as you see on the pic
o boffill
@oboff
Apr 14 2016 09:17
@Blauelf thats perfect thx
CamperBot
@camperbot
Apr 14 2016 09:17
oboff sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1628 | @blauelf | http://www.freecodecamp.com/blauelf
usharya
@usharya
Apr 14 2016 09:18
@IanBarkerDev Yes, I mainly want to master this language
Ian Barker
@IanBarkerDev
Apr 14 2016 09:18
@stuli5 myVar = myVar + 1 => myVar ++
Samuel Cupidon
@Zerazera
Apr 14 2016 09:18
@stuli5 Let's try it this way. These two statements are equivalent.
myVar = myVar + 1;
myVar++
o boffill
@oboff
Apr 14 2016 09:18
I'm trying to get away with as little imperative programming as possible
functional style is way less hassle
Blauelf
@Blauelf
Apr 14 2016 09:19
Funny thing: myVar = myVar++ should not change myVar at all, as myVar++ evaluates to the value of myVar, then increments the variable (postfix), then comes the assignment that assigns the previous value to myVar again :)
Alex
@blurges
Apr 14 2016 09:19
blob
@Blauelf could you look at this version for Drop It? I'm not sure what to do
Bosko
@boskoivic
Apr 14 2016 09:20
this worked, but could it be done simpler?
var count = 0;

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

  if(card >= 2 && card <= 6){
    count++;
     if(count<=0){
    return (count+" Hold");
     }

    else{
      return (count+" Bet");
    }
  }

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

     if(count<=0){
    return (count+" Hold");
     }

    else{
      return (count+" Bet");
    }
  }

   else if(card===10 || card==="J" ||  card==="Q" || card==="K" || card==="A"){
    count--;
    if(count<=0){

    return (count+" Hold");
     }

    else{
      return (count+" Bet");
    }
  }
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(2);  cc(10);
stuli5
@stuli5
Apr 14 2016 09:20
cd.jpg
this is my problem
the myVar should be changed
Ian Barker
@IanBarkerDev
Apr 14 2016 09:20
@stuli5 You don't need the myVar = part.