These are chat archives for FreeCodeCamp/HelpJavaScript

9th
Mar 2016
Dave Melia
@Dave-Melia
Mar 09 2016 00:00
function destroyer(arr) {
  var args = [].slice.call(arguments, 1);
  var filtered = arr.filter(function(item) {
    return item !== args.indexOf();
  });

  return filtered;
}
alpox
@alpox
Mar 09 2016 00:00
This message was deleted
Jesse Jafa
@awareness481
Mar 09 2016 00:00
Is using this return str.fromCharCode(i); inside a for loop illegal? I'm asking because it seems to be causing an error
alpox
@alpox
Mar 09 2016 00:01
@Dave-Melia Read indexOf more properly :-D you don't tell it of what you want to have the index
Dave Melia
@Dave-Melia
Mar 09 2016 00:01
@alpox yeah I'm on that
@alpox
function destroyer(arr) {
  var args = [].slice.call(arguments, 1);
  var filtered = arr.filter(function(item) {
    return args.indexOf(item);
  });

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
that now returns 1, 3, 1, 3
so bloody close
alpox
@alpox
Mar 09 2016 00:08

@Dave-Melia

The index to start the search at. If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched.

@Dave-Melia From the MDN page
Dave Melia
@Dave-Melia
Mar 09 2016 00:09
args, arr, and items all return 1,2,3,1,2,3 for some reason
Rick Bernas
@rbernas
Mar 09 2016 00:09
in the "confirm the ending" basic algorithms section, shouldn't this requirement be true, instead of false: end("Walking on water and developing software from a specification are easy if both are frozen", "specification") should return false.
Dave Melia
@Dave-Melia
Mar 09 2016 00:09
no it doesn't, ignore me
Rick Bernas
@rbernas
Mar 09 2016 00:09
since frozen and specification both end in "n"
DJ
@qualitymanifest
Mar 09 2016 00:10
@rbernas the end of the sentence there is "frozen", not "specification"
Rick Bernas
@rbernas
Mar 09 2016 00:10
right
both end in n
so the requirement should be return true
DJ
@qualitymanifest
Mar 09 2016 00:10
you're not checking only the last letter, necessarily.
you're checking to see that the first string ends with the last string
Rick Bernas
@rbernas
Mar 09 2016 00:10
yes you are
DJ
@qualitymanifest
Mar 09 2016 00:11
okay then dude
whatever you say
Rick Bernas
@rbernas
Mar 09 2016 00:11
another requirement: end("He has to give me a new name", "me") should return true.
DJ
@qualitymanifest
Mar 09 2016 00:11
name ends with me.
Rick Bernas
@rbernas
Mar 09 2016 00:12
ah ok thx
Richard Corbett
@reacorbett
Mar 09 2016 00:13
@qualitymanifest thanks, i will give you those brownie points you deserve. :)
CamperBot
@camperbot
Mar 09 2016 00:13
reacorbett sends brownie points to @qualitymanifest :sparkles: :thumbsup: :sparkles:
:star: 1063 | @qualitymanifest | http://www.freecodecamp.com/qualitymanifest
DJ
@qualitymanifest
Mar 09 2016 00:13
@reacorbett tanks
CamperBot
@camperbot
Mar 09 2016 00:13
qualitymanifest sends brownie points to @reacorbett :sparkles: :thumbsup: :sparkles:
:star: 302 | @reacorbett | http://www.freecodecamp.com/reacorbett
Dave Melia
@Dave-Melia
Mar 09 2016 00:15
@alpox BOOM BOOM BOOM BOOM!!!!!
function destroyer(arr) {
  var args = [].slice.call(arguments, 1);
  var filtered = arr.filter(function(item) {
    return args.indexOf(item) === -1;
  });

  return filtered;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
oh the relief!!!!!
Richard Corbett
@reacorbett
Mar 09 2016 00:16
@Dave-Melia good job
Dave Melia
@Dave-Melia
Mar 09 2016 00:16
@reacorbett thanks :)
alpox
@alpox
Mar 09 2016 00:17
@Dave-Melia Gratulations! :D
Dave Melia
@Dave-Melia
Mar 09 2016 00:18
@alpox phew!
alpox
@alpox
Mar 09 2016 00:18
@Dave-Melia Well done! ^_^ thats how it should look like
Dave Melia
@Dave-Melia
Mar 09 2016 00:18
hahaha
alpox
@alpox
Mar 09 2016 00:18
@Dave-Melia And here the short version before i can run away because you hunt me:
function destroyer(arr, ...args) {
  return arr.filter(i => !~args.indexOf(i));
}
Dave Melia
@Dave-Melia
Mar 09 2016 00:18
I feel like i've given birth
nah, you can keep your ES6 until it's the standard!
alpox
@alpox
Mar 09 2016 00:19
:D
Dave Melia
@Dave-Melia
Mar 09 2016 00:19
lol
alpox
@alpox
Mar 09 2016 00:19
well !~args.indexOf(i) isnt...
Dave Melia
@Dave-Melia
Mar 09 2016 00:19
thanks @alpox
CamperBot
@camperbot
Mar 09 2016 00:19
dave-melia sends brownie points to @alpox :sparkles: :thumbsup: :sparkles:
:star: 332 | @alpox | http://www.freecodecamp.com/alpox
Pedro Abel Díaz Sánchez
@coderHook
Mar 09 2016 00:19

Guys need some help understanding reduce() function (I was trying to understand it for a couple of days but I cannot get the essence of it)

Working on "Pairwise Algorithm" could if be posible to do it all with the reduce form?

alpox
@alpox
Mar 09 2016 00:20
@Dave-Melia You're welcome :-)
Pedro Abel Díaz Sánchez
@coderHook
Mar 09 2016 00:20

here is my code

function pairwise(arr, arg) {
  var newArr = [];
  var indexes = [];

  /*arr.reduce(function(a, b, index){

    console.log("Before if A: ", a);
    console.log("Before if B: ", b);
    console.log("index current: ", index);


    if (a+b == arg){ 
      newArr.push(a);
      newArr.push(b);
      indexes.push(aux.indexOf(a));
      indexes.push(aux.indexOf(b));

      arr[arr.indexOf(a)] = 0;
      arr[arr.indexOf(b)] = 0;

    }

    if(index == arr.length) { return }

    return a;
  });*/

  var total = 0;

  if (arr.length === 0) {return 0;}
  else {
  for(var i=0; i < arr.length -1; i++){
    var a = arr[i];
    for(var j = i+1; j < arr.length; j++){
      var b= arr[j];

      if(a !== '' && b !== '' && a+b == arg){
          indexes.push(i);
          indexes.push(j);

          arr[i] = '';
          arr[j] = '';
          break;

        } 
    }
  }

 total = indexes.reduce(function(a, b){
    return a+b;
  });

  return total;
  }
}

pairwise([1, 4, 2, 3, 0, 5], 7);

As you can see I tried but I could so I came back to my for loops :)

alpox
@alpox
Mar 09 2016 00:21
Good night guys :-)
Greg D
@mosaic-greg
Mar 09 2016 00:21
String.fromCharCode("SERR PBQR PNZC".charCodeAt(0)-13) == F
but
String.fromCharCode("SERR PBQR PNZC".charCodeAt(1)-13) == 8
it should equal R
why is that
Dave Melia
@Dave-Melia
Mar 09 2016 00:21
@alpox Gute Nieche or whatever it was
@alpox o7
Darwin RC
@darwinrc
Mar 09 2016 00:22
@Abel1987 and also check this interactive tutorial: https://github.com/timoxley/functional-javascript-workshop
Pedro Abel Díaz Sánchez
@coderHook
Mar 09 2016 00:22

@darwinrc yeap, I can sum all the numbers in an array, but the problem comes when I want to adapt that reduce form to other problems.

In "Pairwise Algorithm" I was trying to check with reduce if some pair match the arg value. but I couldn't

@darwinrc uff, I do not know how to use gitHub :s and I do not have linux to install it
Darwin RC
@darwinrc
Mar 09 2016 00:24
@Abel1987 you don't need linux, npm can be installed in windows or macos
Pedro Abel Díaz Sánchez
@coderHook
Mar 09 2016 00:26
umm, I am going to investigate it : ) thanks @darwinrc , btw, did you complete "Pairwise algorithm" with a function reduce?
CamperBot
@camperbot
Mar 09 2016 00:26
abel1987 sends brownie points to @darwinrc :sparkles: :thumbsup: :sparkles:
:star: 393 | @darwinrc | http://www.freecodecamp.com/darwinrc
Darwin RC
@darwinrc
Mar 09 2016 00:26
@Abel1987 a clue for understanding reduce is to see the first argument of the callback function as an accumulator (that can be initialized with whichever value you pass as the second argument to the reduce function) and the second argument of the cb is just the value being traversed in the array.
@Abel1987 letme check
Pedro Abel Díaz Sánchez
@coderHook
Mar 09 2016 00:28
@darwinrc I saw that, for that purpose I set as a return value a couse then it will check the whole array but then after it finished, it came back again so...
up to this point I only could use reduce to sum all the elements.
PattyCreates
@PattyCreates
Mar 09 2016 00:33
Hey is anyone familiar with linking node to a git repo? I'm currently running into issues trying to set up a local environment.
Darwin RC
@darwinrc
Mar 09 2016 00:33
@PattyCreates what do you mean by linking?
PattyCreates
@PattyCreates
Mar 09 2016 00:34
@darwinrc My npm isn't working. I've run brew doctor and it says node is installed but not linked. It suggests brew link node but that compiles with an error message
``
Linking /usr/local/Cellar/node/5.7.1... Error: Could not symlink include/node/android-ifaddrs.h /usr/local/include/node is not writable.
Which I've tried uninstalling / reinstalling a few times.
Not sure how to properly link node in.
Darwin RC
@darwinrc
Mar 09 2016 00:36
@PattyCreates it appears to be something with permissions... have you looked at https://gist.github.com/Critter/c52dc9257f40ded4dfc1 ?
Norman Dela Cruz
@dcnr
Mar 09 2016 00:36
@mosaic-greg E is char code 69 and 56 (69 - 13) is 8. 69 + 13 is R
Darwin RC
@darwinrc
Mar 09 2016 00:37
@PattyCreates you must change the privileges of the node folder
PattyCreates
@PattyCreates
Mar 09 2016 00:39
How do I change permissions?
Is sudo chown -R whoami /usr/local/include/node permissions change? @darwinrc
Darwin RC
@darwinrc
Mar 09 2016 00:41
@PattyCreates yes. Don't forget sudo and to put backticks in the command whoami
PattyCreates
@PattyCreates
Mar 09 2016 00:43
I'm getting stuck in circles.
I'm seeing
Darwin RC
@darwinrc
Mar 09 2016 00:43
did you put backticks around whoami? you can also put your user there instead of the command
PattyCreates
@PattyCreates
Mar 09 2016 00:45
Linking /usr/local/Cellar/node/5.7.1... 
Error: Could not symlink include/node/ares.h
Target /usr/local/include/node/ares.h
already exists. You may want to remove it:
  rm '/usr/local/include/node/ares.h'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node
After i did the chown command.
And then I did the brew link node command.
and this was the output. I then tried to remove '/usr/local/include/node/ares.h' but it stuck around.
Darwin RC
@darwinrc
Mar 09 2016 00:47
you can ovewrite it
PattyCreates
@PattyCreates
Mar 09 2016 00:47
So I tried brew link --overwrite node and it goes back to the initial response that prompted this question.
should I sudo it?
Darwin RC
@darwinrc
Mar 09 2016 00:47
can you post your chmod command please?
PattyCreates
@PattyCreates
Mar 09 2016 00:48
chmod?
Darwin RC
@darwinrc
Mar 09 2016 00:48
yes, the one you used to change the permissions
chown, sorry
PattyCreates
@PattyCreates
Mar 09 2016 00:48
sudo chown -R whoami /usr/local/include/node
Oh, i just tried to use my name for that command.
and I got a different response.
Darwin RC
@darwinrc
Mar 09 2016 00:50
and if you run brew link node after it, doesn't work?
PattyCreates
@PattyCreates
Mar 09 2016 00:51
Nope
Darwin RC
@darwinrc
Mar 09 2016 00:51
same error?
try sudo then
PattyCreates
@PattyCreates
Mar 09 2016 00:52
Yeah, cowardly is rejecting my sudo.
It's a similar message as previous, but the prompt for what its telling me to rm is different.
You may want to remove it: rm '/usr/local/lib/dtrace/node.d' and before it was a ...ares.h file.
Darwin RC
@darwinrc
Mar 09 2016 00:54
hmm, but it's a different directory... weird
PattyCreates
@PattyCreates
Mar 09 2016 00:55
Yeah, I actually don't know what any of this means at the moment. All of these errors are far past my general understanding.
Darwin RC
@darwinrc
Mar 09 2016 00:57
It seems you had installed node before and when trying to reinstall it it crashes... I'm not a macos user, but lets dig deeper
PattyCreates
@PattyCreates
Mar 09 2016 00:57
Yeah, I think it's part of me reinstalling Node often whenever it's not responsive.
Greg D
@mosaic-greg
Mar 09 2016 00:57
@dcnr ok thanks so maybe it shifts -13 or +13 depending if its over halfway in the alphabet
CamperBot
@camperbot
Mar 09 2016 00:57
mosaic-greg sends brownie points to @dcnr :sparkles: :thumbsup: :sparkles:
:star: 758 | @dcnr | http://www.freecodecamp.com/dcnr
PattyCreates
@PattyCreates
Mar 09 2016 00:57
I don't feel like its the best practice.
Carrie A
@tuningmind
Mar 09 2016 00:59
if I ask a question here about code I'm writing on fcc, is there an easy way for me to make the code visible to you?
Norman Dela Cruz
@dcnr
Mar 09 2016 00:59
@mosaic-greg yes you're right, the char code for capital letters A-Z go from 65 to 90 so you'll have to +/- accordingly
PattyCreates
@PattyCreates
Mar 09 2016 01:00
➜  learnup git:(master) brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
    /usr/local/include/node/eio-emul.h
    /usr/local/include/node/ev-emul.h
    /usr/local/include/node/uv-private/eio.h
    /usr/local/include/node/uv-private/ev.h
    /usr/local/include/node/uv-private/ngx-queue.h
    /usr/local/include/node/uv-private/tree.h
    /usr/local/include/node/uv-private/uv-unix.h
    /usr/local/include/node/uv-private/uv-win.h
    /usr/local/include/node/v8-preparser.h
    /usr/local/include/node/v8stdint.h

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    heroku-toolbelt
    node

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
    c_rehash
    erb
    gem
    irb
    openssl
    rake
    rdoc
    ri
    ruby

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

Warning: Your Xcode (5.1.1) is outdated
Please update to Xcode 6.2.
Xcode can be updated from the App Store.

Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.

Binaries provided by keg-only formulae may override system binaries
with other strange results.

You may wish to `brew unlink` these brews:
    openssl
Darwin RC
@darwinrc
Mar 09 2016 01:01
@PattyCreates take a look at the first answer to this issue: Homebrew/homebrew#34141
PattyCreates
@PattyCreates
Mar 09 2016 01:01
My brew set up is weird.
Carrie A
@tuningmind
Mar 09 2016 01:01
it looks like what is being done here to share code snippets is a screen capture; is that correct?
Darwin RC
@darwinrc
Mar 09 2016 01:01
they're just warnings...i think it's ok
PattyCreates
@PattyCreates
Mar 09 2016 01:02
@tuningmind no, it's markdown. cmd ctl m shows you them
Carrie A
@tuningmind
Mar 09 2016 01:02
thanks, Patty
PattyCreates
@PattyCreates
Mar 09 2016 01:02
nw
Darwin RC
@darwinrc
Mar 09 2016 01:02
This message was deleted
Norman Dela Cruz
@dcnr
Mar 09 2016 01:02

@tuningmind
You can easily format your code by typing it out like this:
```js (shift+enter)(paste code)(enter)


Those are 3 backquotes, the key above tab, left of 1, and below esc.


So it'll look like this:

```js
// pasted code here
```

Carrie A
@tuningmind
Mar 09 2016 01:03

I'm working on Make Object Properties Private, and I thought my code is right but it won't accept the submission.
var Bike = function() {

var gear = 0;
this.getGear = function() {
return gear;
};
this.setGear = function(change) {
gear += change;
};
};

var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();

um, sorry about that formatting, this is my first time posting here
Michael Aubrey
@mca62511
Mar 09 2016 01:04

Question: I was running my code through JSLint and it seems to be suggesting practices I haven't seen (or don't remember) advocated in FreeCodeCamp. For example, it suggests avoiding using "for" loops, and instead to use .forEach() method on arrays instead.

It also seems to suggest using "use strict"; at the beginning of every function.

Are these things that I should be doing?

Darwin RC
@darwinrc
Mar 09 2016 01:05
@PattyCreates what they recommend is to delete the whole stuff and install it again:
sudo rm /usr/local/include/node/* && sudo rm -rf /usr/local/include/node/* && sudo rm -rf /usr/local/lib/dtrace

&

sudo chown -R `whoami` /usr/local then brew post-install node
tia
@tvdeleon24
Mar 09 2016 01:05
I'm having a really hard time understanding "iterate through an array with a loop" I got the challenge correct but I don't understand how. defeats the purpose, right? this part throws me off: "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."
Darwin RC
@darwinrc
Mar 09 2016 01:06
@tuningmind
var Bike = function() {
var gear = 1;
this.getGear = function() {
return gear;
};
this.setGear = function(change) {
gear = change;
};
};
Carrie A
@tuningmind
Mar 09 2016 01:07
var Bike = function() {
var gear = 0;
this.getGear = function() {
return gear;
};
this.setGear = function(change) {
gear += change;
};
};
var myBike = new Bike();
myBike.setGear(1);
myBike.getGear();
sorry folks, definitely feeling like the noob here :D
Darwin RC
@darwinrc
Mar 09 2016 01:07
@mca62511 jslint are just best practices. I think it is not necessary to use strict within FCC
PattyCreates
@PattyCreates
Mar 09 2016 01:07
@darwinrc thanks. So, i've got the symlinks created and node is reading.
CamperBot
@camperbot
Mar 09 2016 01:07
pattycreates sends brownie points to @darwinrc :sparkles: :thumbsup: :sparkles:
Michael Aubrey
@mca62511
Mar 09 2016 01:07
but what about in production?
CamperBot
@camperbot
Mar 09 2016 01:07
:star: 394 | @darwinrc | http://www.freecodecamp.com/darwinrc
Darwin RC
@darwinrc
Mar 09 2016 01:07
@tuningmind look at mine
PattyCreates
@PattyCreates
Mar 09 2016 01:07
But now NPM isn't reading.
Michael Aubrey
@mca62511
Mar 09 2016 01:07
should I add "use strict"; to every function?
I mean it seems to make sense to try to get used to using best practices as early as possible, no?
Carrie A
@tuningmind
Mar 09 2016 01:08
@darwinrc , looks like you have gear initialized to 1, and you're making gear equal change
Michael Aubrey
@mca62511
Mar 09 2016 01:08
alrighty, thanks @darwinrc
CamperBot
@camperbot
Mar 09 2016 01:08
mca62511 sends brownie points to @darwinrc :sparkles: :thumbsup: :sparkles:
:star: 395 | @darwinrc | http://www.freecodecamp.com/darwinrc
Darwin RC
@darwinrc
Mar 09 2016 01:08
@PattyCreates great it is working now! Nothing a reinstall can't solve.
@mca62511 an regarding loops, it is always better to use functional constructs, they are much expressive and fast. The thing is they take a bit of time to get right
Carrie A
@tuningmind
Mar 09 2016 01:10
@darwinrc - that does in fact allow it to be submitted, but I don't understand why; there's nothing in the instructions about what to initialize gear to, and it doesn't make sense for gear to always equal the change - seems like you'd want to add the change to the existing gear, as in gear += change
PattyCreates
@PattyCreates
Mar 09 2016 01:10
@darwinrc yeah, it feels weird / good when it actually goes to the next step. haha.
I'm reading through this right now. npm/npm#3125
Darwin RC
@darwinrc
Mar 09 2016 01:12
I guess with gear = 0 it would also work. And for the other stuff think of the setter function as receiving the value you want it to be the gear, not to ask it to go up or down.
PattyCreates
@PattyCreates
Mar 09 2016 01:12
Wait, so Homebrew/homebrew#34141 this says to uninstall / reinstall node afterward?
Carrie A
@tuningmind
Mar 09 2016 01:13
@PattyCreates I've had to do that before. It's been a while but yeah, iirc homebrew and node don't play nicely together
at least at first
@darwinrc okay, that makes sense, thanks
CamperBot
@camperbot
Mar 09 2016 01:14
tuningmind sends brownie points to @darwinrc :sparkles: :thumbsup: :sparkles:
:star: 396 | @darwinrc | http://www.freecodecamp.com/darwinrc
Darwin RC
@darwinrc
Mar 09 2016 01:15
@PattyCreates handling permissions is always a hurdle, specially with those managers
Ryan Hellerud
@ryanhellerud1
Mar 09 2016 01:15
anyone do the seaser-cipher one?
ceaser
Tyler Moeller
@TylerMoeller
Mar 09 2016 01:15

How would you combine duplicates in a multi-dimensional array with decimals while preserving sort order?

Let's say I want this array:

[['A', 0.01], ['A', 0.01], ['A', 0.01], ['A', 0.01], ['Z', 0.1], ['Z', 0.1], ['D', 5], ['F', 10], ['G', 20], ['F', 10], ['D', 5], ['D', 5]]

To reduce to:

[['A', 0.04], ['Z', 0.2], ['D', 15], ['F', 20], ['G', 20]];

This is the closest I've gotten:

while (arr.length > 0) {
  for (var i = 1; i < arr.length; i++) {
    if (arr[0][0] === arr[i][0]) {
      arr[0][1] += arr[i][1];
      arr.splice(i, 1);
    }
  }

  arr2.push(arr[0]);
  arr.splice(0, 1);
}

return arr2;  // still has duplicates
Devin
@devblanchard
Mar 09 2016 01:17
so i am trying to wrap my head around what i need to be trying to do with "where do i belong". do i need to sort the num variable into the array and then identify its index?
PattyCreates
@PattyCreates
Mar 09 2016 01:22
@darwinrc so, I've reinstalled node again. And, now I'm getting an error with NPM not working. I tried `ls -laF /usr/local/bin/npm ls: /usr/local/bin/npm: No such file or directory' and it's output seems like that directory is empty.
Darwin RC
@darwinrc
Mar 09 2016 01:24
let me look
PattyCreates
@PattyCreates
Mar 09 2016 01:24
It does output here.
ls -laF /usr/local/lib/node_modules
total 0
drwxr-xr-x    5 24561   wheel   170 Jun 21  2013 ./
drwxrwxr-x  253 24561   admin  8602 Mar  8 17:14 ../
drwxr-xr-x   16 nobody  staff   544 Jun 13  2013 bower/
drwxr-xr-x   12 nobody  staff   408 Jun 21  2013 foreman/
drwxr-xr-x   18 24561   staff   612 Jan  8  2013 npm/
npm/npm#4851
Darwin RC
@darwinrc
Mar 09 2016 01:27
did you try brew install npm?
Jason Xie
@JasonXjx
Mar 09 2016 01:37
This message was deleted
PattyCreates
@PattyCreates
Mar 09 2016 01:37
@darwinrc Warning: node-5.7.1 already installed is out put
Kweku Duncan
@kwekuofficial
Mar 09 2016 01:38

To test your learning you will create a solution "from scratch". Place your code between the indicated lines and it will be tested against multiple test cases.

The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.

You are given a variable celsius representing a temperature in Celsius. Create a variable fahrenheit and apply the algorithm to assign it the corresponding temperature in Fahrenheit. function convert(celsius) {
// Only change code below this line

// Only change code above this line
if ( typeof fahrenheit !== 'undefined' ) {
return fahrenheit;
} else {
return 'fahrenheit not defined';
}
}

// Change the inputs below to test your code
convert(30);

Darwin RC
@darwinrc
Mar 09 2016 01:38
@PattyCreates and npm version?
PattyCreates
@PattyCreates
Mar 09 2016 01:39
command not found.
Darwin RC
@darwinrc
Mar 09 2016 01:40
you will have to reinstall your brew, haha
PattyCreates
@PattyCreates
Mar 09 2016 01:41
:(
Darwin RC
@darwinrc
Mar 09 2016 01:41
you could link it manually, but I don't think it's a good idea
http://stackoverflow.com/questions/8935341/npm-wont-run-after-upgrade @PattyCreates it seems hash -r will do the trick
Jason Xie
@JasonXjx
Mar 09 2016 01:43

function destroyer(arr) {
// Remove all the values
var arr1 = Array.prototype.slice.call(arguments);
var newArr = arr1[0].filter(function(val) {
return val == arguments[1];
}
);
return newArr;
}

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

hey there. Why it returns an empty array when I'm using arguments[1]? And it returns the array I want when the arguments[1] is replaced by array1[1]. It's just a piece of codes for testing, not the desired codes. Thanks.

Supreeth
@hallidude
Mar 09 2016 01:48
help js
CamperBot
@camperbot
Mar 09 2016 01:48

:point_right: challenge accessing nested arrays in json [wiki]

Challenge: Accessing Nested Arrays in JSON

As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.

Here is an example of how to access a nested array:

```js
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
:pencil: read more about challenge accessing nested arrays in json on the FCC Wiki

Supreeth
@hallidude
Mar 09 2016 01:48
Selecting from many options with Switch Statements
Greg D
@mosaic-greg
Mar 09 2016 01:48
@JasonXjx i think you need to convert the arguments object in to an actual object before accessing it
Supreeth
@hallidude
Mar 09 2016 01:49
@mosaic-greg Can you help me with this?
Selecting from many options with Switch Statements
PattyCreates
@PattyCreates
Mar 09 2016 01:49
@darwinrc thanks for your help. I think i'm going to have to sit with my dev team and debug the issue. It's kinda all over the place.
CamperBot
@camperbot
Mar 09 2016 01:49
pattycreates sends brownie points to @darwinrc :sparkles: :thumbsup: :sparkles:
:warning: pattycreates already gave darwinrc points
Supreeth
@hallidude
Mar 09 2016 01:49
@mosaic-greg switch (num) {
case value1:
statement1;
break;
case value2:
statement2;
break;
...
case valueN:
statementN;
break;
} is the pseudo code
I'm a little lost on what the actual code should look like
switch (val) {
case val === 1:
"alpha";
Darwin RC
@darwinrc
Mar 09 2016 01:50
@PattyCreates ok. Sorry I couldn't help you more. Didn't hash -r work?
PattyCreates
@PattyCreates
Mar 09 2016 01:51
Nope, it didn't return anything.
I really appreciate it a bunch so no apologies!
Darwin RC
@darwinrc
Mar 09 2016 01:54
they say it doesn't return anything but npm works.
Greg D
@mosaic-greg
Mar 09 2016 01:54
@hallidude look at a bunch of examples and it will start to make sense
Jason Xie
@JasonXjx
Mar 09 2016 01:54
@mosaic-greg Yes, I did that and passed the challenge. But when using return arguments[1], I get 2...and I didn't see the difference between arguments[1] and arr1[1]. Maybe I should read the documents about arguments. Thanks for your reply.
CamperBot
@camperbot
Mar 09 2016 01:54
jasonxjx sends brownie points to @mosaic-greg :sparkles: :thumbsup: :sparkles:
:star: 314 | @mosaic-greg | http://www.freecodecamp.com/mosaic-greg
asaki444
@asaki444
Mar 09 2016 01:57

function chunk(arr, size) {
  // Break it up.
var fin = [];
var divide = arr.length/size;
  for(var i = 0; i < arr.length; i + divide)
    { arr.slice(i);   
    }

}

chunk(["a", "b", "c", "d"], 2);
i keep getting an infinite loop error message
Darwin RC
@darwinrc
Mar 09 2016 02:02
@asaki444 you are not incrementing the i counter. It's always 2. It should be something like i+= divide
yoni chanowitz
@yonichanowitz
Mar 09 2016 02:05
help me!
CamperBot
@camperbot
Mar 09 2016 02:05

:point_right: adding environment variables [wiki]

In Windows

Via GUI

  1. Download Varpanel.
  2. Open Varpanel.
  3. In PATH variable, add the relevant path (for example).

:pencil: read more about adding environment variables on the FCC Wiki

yoni chanowitz
@yonichanowitz
Mar 09 2016 02:07
i amdoing ceasers cipher, and i keep getting "-" instead of white space.
what am i missing?
function rot13(str) { // LBH QVQ VG!
 var a = " ";

 for (var dude = 0; dude < str.length ;dude++){
   var b = str.charCodeAt(dude);
   if(str.charAt(dude !== /\s/) ){
  if(b < 77){
    a += String.fromCharCode(b + 13);
  }else if (b > 77){
    a += String.fromCharCode(b - 13);
  }
   }

   }return a;

}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Devin
@devblanchard
Mar 09 2016 02:17
function where(arr, num) {
  // Find my place in this sorted array.

  arr.push(num);
  return arr.sort().indexOf(num);
}

where([40, 60], 50);
this handles the first three sets, but i don't know how to make it work for the others.
and i don't see how the logic doesn't work with them all.
Todd Easter
@justplaintodd
Mar 09 2016 02:21
help Accessing Nested Arrays in JSON
CamperBot
@camperbot
Mar 09 2016 02:21

:point_right: challenge accessing nested arrays in json [wiki]

Challenge: Accessing Nested Arrays in JSON

As we have seen in earlier examples, JSON objects can contain both nested objects and nested arrays. Similar to accessing nested objects, Array bracket notation can be chained to access nested arrays.

Here is an example of how to access a nested array:

```js
var ourPets = {
"cats": [
"Meowzer",
"Fluffy",
"Kit-Cat"
],
"dogs": [
"Spot",
"Bowser",
"Frankie"
]
};
ourPets.cats1; // "Fluffy"
:pencil: read more about challenge accessing nested arrays in json on the FCC Wiki

bitgrower
@bitgrower
Mar 09 2016 02:21
@yonichanowitz -- you are making two separate checks .. you need to determine that a number is within a range by bounding both the upper & lower bounds simultaneously
Jeremy Roe
@jeremyroe
Mar 09 2016 02:21
Hey guys - I’m stuck on my twitch viewer - I have a function searching an array of objects but it’s getting stuck using the same source object as the search value and I’m not sure why - Anyone have a chance to take a peek?
Ryan Price
@rsprice
Mar 09 2016 02:22
@jeremyroe yeah I'll take a look for you
Jeremy Roe
@jeremyroe
Mar 09 2016 02:22
Appreciate it - http://codepen.io/jeremyroe/pen/zqGRvO?editors=0010 in the syncHandler function line 46 can see some logs in console
Ryan Price
@rsprice
Mar 09 2016 02:22
@devblanchard I think your problem lies with Array.sort(), which sorts by string unicode values by default
@devblanchard you need to pass a callback function to sort to make it work the way you expect. Check this out: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
Devin
@devblanchard
Mar 09 2016 02:26
thanks @rsprice i have been reading through it. earlier i had it written to where i had all but the last one working, but my code didn't look very pretty though so i started over and thought this might be heading in the right direction. i'll keep working on figuring out how to make the callback function do what i want it to.
CamperBot
@camperbot
Mar 09 2016 02:26
devblanchard sends brownie points to @rsprice :sparkles: :thumbsup: :sparkles:
:star: 366 | @rsprice | http://www.freecodecamp.com/rsprice
Ryan Price
@rsprice
Mar 09 2016 02:27
@devblanchard let me know if you need any help
Vietnamese Donkey
@vietnamkong
Mar 09 2016 02:28
help make object properties
CamperBot
@camperbot
Mar 09 2016 02:28

:point_right: challenge make object properties private [wiki]

Objects have their own attributes, called properties_, and their own functions, called _methods.

You can use the this keyword to reference public properties and methods of the current objects. However, when You need to create private ones so they are not accessible from the outside of the object you just remove the keyword this from the object property or method declaration and declare it with var so that it is private outside its scope.

var Bike = function() {
  var speed = 100; // private
  function addUnit(value) { // private
    return value + "KM/H";
  }

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

};

Another example:

:pencil: read more about challenge make object properties private on the FCC Wiki

tia
@tvdeleon24
Mar 09 2016 02:30
in "nesting for loops" why is the var product = 1? It instructs me to not change that line but I don't understand why?
can anyone help me out there?
Ryan Price
@rsprice
Mar 09 2016 02:30
@jeremyroe any chance the problem is coming from this findWhere_.findWhere(list, properties) Looks through the list and returns the first value that matches all of the key-value pairs listed in properties.
Jeremy Roe
@jeremyroe
Mar 09 2016 02:36
I suspect that’s the issue @rsprice but my assumption is it should return a fresh “find” with each iteration of this function - somehow it’s getting stuck
Andrew Charlebois
@andrewchar
Mar 09 2016 02:36
algorithm Repeat a string repeat a string. my solution. a more elegant way to do it?
function repeat(str, num) {

 if (num < 0 ) {
    return "";
  } 
    return str.repeat(num);
}

repeat("abc", 3);
Jeremy Roe
@jeremyroe
Mar 09 2016 02:36
and it’s not always the same one
might be I just need a different aproach
Andrew Charlebois
@andrewchar
Mar 09 2016 02:36
help Repeat a string repeat a string
CamperBot
@camperbot
Mar 09 2016 02:36

:point_right: algorithm repeat a string repeat a string [wiki]

Explanation:

The program is very simple, we have to take a variable and return that variable being repeated certain amount of times. No need to add space or anything, just keep repeating it into one single string.

:pencil: read more about algorithm repeat a string repeat a string on the FCC Wiki

Devin
@devblanchard
Mar 09 2016 02:38
@rsprice
function where(arr, num) {
  // Find my place in this sorted array.
  var numSort = arr.sort(function(a, b) {
  return a - b;
});
  for(var i = 0; i < numSort.length; i++) {
    if(numSort[i]>=num){
      return i;
    }
  }
}
where([40, 60], 50);
doing it this way i can get all but the last one...
Andrew Charlebois
@andrewchar
Mar 09 2016 02:39
could someone explain what is going on here, whats the ? do return num >= 0 ? str.repeat(num) : "";
is that some kind of evaluating thing
like an operator
Devin
@devblanchard
Mar 09 2016 02:40
ternary operator
Andrew Charlebois
@andrewchar
Mar 09 2016 02:40
that means takes 3 arguments
i think
right?
Devin
@devblanchard
Mar 09 2016 02:41
It has the form of: condition ? value-if-true : value-if-false
Think of the ? as "then" and : as "else".
Andrew Charlebois
@andrewchar
Mar 09 2016 02:41
that was my next question, what the : does
perfect, thank you much @devblanchard
CamperBot
@camperbot
Mar 09 2016 02:41
andrewchar sends brownie points to @devblanchard :sparkles: :thumbsup: :sparkles:
:star: 265 | @devblanchard | http://www.freecodecamp.com/devblanchard
Devin
@devblanchard
Mar 09 2016 02:42
yw
Andrew Charlebois
@andrewchar
Mar 09 2016 02:42
oh sorry one more thing
is it always true on the left, false on the right
Devin
@devblanchard
Mar 09 2016 02:43
i do believe so
i think it works kind of as a condensed if else statement
i'm still trying to figure all this business out though
Andrew Charlebois
@andrewchar
Mar 09 2016 02:46
yeah i just checkd my solution to algorithm against it and they the exact same but mine is an if statement with 2 returns
where they just do the one line with the ? : thing
conditional operator i guess you call it
bitgrower
@bitgrower
Mar 09 2016 02:48
they call the whole thing a ternary operator @andrewchar -- not sure if that was mentioned earlier ...
Andrew Charlebois
@andrewchar
Mar 09 2016 02:49
just checked mdn
The ?: operator can be used as a shortcut for an if...else statement. It is typically used as part of a larger expression where an if...else statement would be awkward.
ive never seen this before now lol
was confused
bitgrower
@bitgrower
Mar 09 2016 02:49
it's found in other languages as well ...
Ryan Price
@rsprice
Mar 09 2016 02:50
@devblanchard in your code you sort arr and save a reference to the sorted arr in numSort. You then use a for loop to iterate over that array. You run a check which tells you whether or not the current element is greater than or equal to num, and if so, you return the current index.
@devblanchard it looks like you forgot to push num onto arr before you sorted it
bitgrower
@bitgrower
Mar 09 2016 02:50
:wave: @rsprice @andrewchar
Ryan Price
@rsprice
Mar 09 2016 02:51
@bitgrower 0/
Andrew Charlebois
@andrewchar
Mar 09 2016 02:51
@bitgrower other languages?
bitgrower
@bitgrower
Mar 09 2016 02:52
java, python & ruby -- if google suggest is leading me correctly ... :)
Ryan Price
@rsprice
Mar 09 2016 02:52
@devblanchard I would definitely write out all the logic involved in your algorithm in pseudocode before coding it in javascript
Andrew Charlebois
@andrewchar
Mar 09 2016 02:52
oh
Ryan Price
@rsprice
Mar 09 2016 02:52
it helps me to do that ~100% of the time
bitgrower
@bitgrower
Mar 09 2016 02:53
@rsprice -- ding! ding! ding!!!! give that coder a prize !
Andrew Charlebois
@andrewchar
Mar 09 2016 02:53
i dont get that whole pseudocode thing
bitgrower
@bitgrower
Mar 09 2016 02:54
among others, @andrewchar : https://en.wikipedia.org/wiki/%3F:
@andrewchar -- it's a more language-independent way of writing what a particular piece of code is supposed to do ...
yoni chanowitz
@yonichanowitz
Mar 09 2016 02:56
help ceasers cipher
CamperBot
@camperbot
Mar 09 2016 02:56
no wiki entry for: ceasers cipher
bitgrower
@bitgrower
Mar 09 2016 02:56
so you're not worried about semicolons & brackets & other syntactical gotchas -- and just concentrate on what the code has to do, less on how it does it ...
yoni chanowitz
@yonichanowitz
Mar 09 2016 02:56
help Caesars Cipher
CamperBot
@camperbot
Mar 09 2016 02:56

:point_right: algorithm caesars cipher [wiki]

Problem Explanation:

  • You need to write a function, which will take string encoded with
    Caesar cipher as a parameter and decode it.
  • The one used here is ROT13 where the value of the letter is
    shifted by 13 places.
    e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
  • You have to shift it back 13 positions, such that 'N' ↔ 'A'.
:pencil: read more about algorithm caesars cipher on the FCC Wiki
Amanda
@invaderrizz
Mar 09 2016 02:57
help Title Case
CamperBot
@camperbot
Mar 09 2016 02:57

:point_right: algorithm title case a sentence [wiki]

Explanation:

We have to return a sentence with camel case. This means that the first letter will always be in uppercase and the rest lowercase.

:pencil: read more about algorithm title case a sentence on the FCC Wiki

Andrew Charlebois
@andrewchar
Mar 09 2016 02:57
@bitgrower In C-descended languages, "?" is part of the ?: operator
from the wiki you posted
javascript was made to look like C when it was created correct?
err no it was made to look like java?
Devin
@devblanchard
Mar 09 2016 02:58
@rsprice i think i will try that. i have just been trying to do that mentally but i totally see the benefit of having something physical to reference. good idea.
Ryan Price
@rsprice
Mar 09 2016 02:59
@andrewchar there are plenty of reasons to use pseudocode :)
Andrew Charlebois
@andrewchar
Mar 09 2016 02:59
@rsprice i just feel when i do, say in algorithms. i write my pseudo out but then decide to take a different path to solving an algorithm
bitgrower
@bitgrower
Mar 09 2016 03:00
java, @andrewchar --
@andrewchar -- that's okay if you decide to take a different path -- but doing the pseudocode probably helped you find that different path ...
...that's part of the point ... :)
Andrew Charlebois
@andrewchar
Mar 09 2016 03:01
@bitgrower now im reading the wiki on JS lol -_-
JavaScript was originally developed in 10 days ............ my god... srsly?
Malcolm
@noinkling
Mar 09 2016 03:02
@andrewchar haha yup
And we're still feeling the effects today
bitgrower
@bitgrower
Mar 09 2016 03:02
yeah -- big marketing effort by netscape
it's not the js you are learning today ... I don't think there were any functional programming methods there initially ... all languages grow (and hopefully improve)
Malcolm
@noinkling
Mar 09 2016 03:04
Many of the original design decisions remain
Andrew Charlebois
@andrewchar
Mar 09 2016 03:04
amazing. 10 days
Malcolm
@noinkling
Mar 09 2016 03:05
Many of the features and workarounds and method names that have been implemented since are a direct result of those original decisions in those 10 days
bitgrower
@bitgrower
Mar 09 2016 03:05
there are a lot of tools which help language developers create languages ... :)
Malcolm
@noinkling
Mar 09 2016 03:06
Since the number one rule for people improving the language is "don't break backwards compatibility" (if you can help it)
Andrew Charlebois
@andrewchar
Mar 09 2016 03:07
the guy must of been really smart
Ryan Price
@rsprice
Mar 09 2016 03:08
There is a really good talk about the origin of JS on Youtube by Doug Crockford
I think it's part of the JS: The Good Parts lecture
Malcolm
@noinkling
Mar 09 2016 03:11
@rsprice Yeah that's the one
Andrew Charlebois
@andrewchar
Mar 09 2016 03:12
was just thinking how it would be nice to hear some about that
ill check it out
bitgrower
@bitgrower
Mar 09 2016 03:13

@andrewchar -- languages are just programs which take user input and translate it into something (ultimately) that the computer can understand .. . in that sense, it's like any other program ... :)

...and, like I said, there are special kinds of tools & knowledge which make creating languages easier ...

grizzlyadams4725
@grizzlyadams4725
Mar 09 2016 03:16
how do I post code in here again?
Andrew Charlebois
@andrewchar
Mar 09 2016 03:19
help format
CamperBot
@camperbot
Mar 09 2016 03:19

: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

Ryan Price
@rsprice
Mar 09 2016 03:21
@devblanchard you know, that bonfire is actually really tricky. Have you figured it out yet?
Patrick Black
@Mortiferr
Mar 09 2016 03:21
// Setup
var myPlants = [
  { 
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }  
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line
Why isn't my code returning pine?
Suprith Aireddy
@sup-rith
Mar 09 2016 03:22
@Mortiferr use bracket notation
Andrew Charlebois
@andrewchar
Mar 09 2016 03:22
@Mortiferr what is myPlant. an object? an array?
Patrick Black
@Mortiferr
Mar 09 2016 03:22
an object
Andrew Charlebois
@andrewchar
Mar 09 2016 03:23
how many objects are there
asaki444
@asaki444
Mar 09 2016 03:23
```

function mutation(arr) {
var comp1 = arr0.toLowerCase().split(" ");
var comp2 = arr1.toLowerCase().split(" ");
for (var i = 0; i < arr.length; i++){
if(comp1[i] in comp2){
return true;
}
return false;
}

}

mutation(["hello", "Hello"]);
```

Patrick Black
@Mortiferr
Mar 09 2016 03:23
oh excuse me it's an array
a nested array
Andrew Charlebois
@andrewchar
Mar 09 2016 03:23
you had it right the first time
Suprith Aireddy
@sup-rith
Mar 09 2016 03:23
@Mortiferr you have to return the second tree
Patrick Black
@Mortiferr
Mar 09 2016 03:23
right, it should return "pine"
Andrew Charlebois
@andrewchar
Mar 09 2016 03:24
how many objects are in the array
Patrick Black
@Mortiferr
Mar 09 2016 03:24
secondTree should equal "pine"
@andrewchar It's a nested array
So 3 in the second array
Andrew Charlebois
@andrewchar
Mar 09 2016 03:24
{ type: "trees", list: [ "fir", "pine", "birch" ] }
what is this
Patrick Black
@Mortiferr
Mar 09 2016 03:24
So I would have to call the second one to call pine
Andrew Charlebois
@andrewchar
Mar 09 2016 03:25
yes
how do you call the second one
what notation
Patrick Black
@Mortiferr
Mar 09 2016 03:25
oh I have to specifiy thelist
Suprith Aireddy
@sup-rith
Mar 09 2016 03:25
myPlants[trees][1];
Andrew Charlebois
@andrewchar
Mar 09 2016 03:26
@Mortiferr you have to specify the object you want to target
@Mortiferr we have 2 in this case
Joseph
@revisualize
Mar 09 2016 03:26
myPlants.trees[1].list[0]
Andrew Charlebois
@andrewchar
Mar 09 2016 03:26
why even type trees?
no need
Suprith Aireddy
@sup-rith
Mar 09 2016 03:26
@Mortiferr what is the challenge called?
Patrick Black
@Mortiferr
Mar 09 2016 03:27
@sup-rith that returns "can't read property of 1"
Andrew Charlebois
@andrewchar
Mar 09 2016 03:27
@Mortiferr look at what im telling you lol
Patrick Black
@Mortiferr
Mar 09 2016 03:27
@sup-rith Accessing Nested Arrays in JSON
@andrewchar Sorry, there are like 3 people telling me 3 different things
Andrew Charlebois
@andrewchar
Mar 09 2016 03:28
@Mortiferr im the only correct one so far
Patrick Black
@Mortiferr
Mar 09 2016 03:29
okay so what two objects do I have to call?
Suprith Aireddy
@sup-rith
Mar 09 2016 03:29
@Mortiferr myPlants[1].list[1]
Patrick Black
@Mortiferr
Mar 09 2016 03:29
@andrewchar got it I have to call myPlants, tell it the second object in the array and then tell it which number in the list.
bitgrower @bitgrower slaps @sup-rith on the wrist ... people don't learn if you just give them the answer ...
Patrick Black
@Mortiferr
Mar 09 2016 03:30
thanks @sup-rith @andrewchar and @revisualize
CamperBot
@camperbot
Mar 09 2016 03:30
mortiferr sends brownie points to @sup-rith and @andrewchar and @revisualize :sparkles: :thumbsup: :sparkles:
J. Clarke
@Jussic
Mar 09 2016 03:30
This message was deleted
CamperBot
@camperbot
Mar 09 2016 03:30
:star: 725 | @revisualize | http://www.freecodecamp.com/revisualize
:star: 342 | @andrewchar | http://www.freecodecamp.com/andrewchar
:star: 260 | @sup-rith | http://www.freecodecamp.com/sup-rith
Andrew Charlebois
@andrewchar
Mar 09 2016 03:30
i was trying to walk you through it haha
but yes
J. Clarke
@Jussic
Mar 09 2016 03:30

``` // Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.
var removedFromMyArray;

myArray.pop(["cat", 2]);
ourArray.push(["cat",2]);
```

Patrick Black
@Mortiferr
Mar 09 2016 03:30
yeah I actually got it before I was told the answer
Andrew Charlebois
@andrewchar
Mar 09 2016 03:30
good!
Patrick Black
@Mortiferr
Mar 09 2016 03:30
thanks dude
J. Clarke
@Jussic
Mar 09 2016 03:30
Can I get help with this manipulating arrays please?
Patrick Black
@Mortiferr
Mar 09 2016 03:30
I get confused sometimes, theres all these arrays and objects and functions
Andrew Charlebois
@andrewchar
Mar 09 2016 03:31
@Mortiferr indeed, it can start to look a little odd with all the nesting
Patrick Black
@Mortiferr
Mar 09 2016 03:31
@Jussic What did the challenge ask for
.
bitgrower
@bitgrower
Mar 09 2016 03:31
is that an FCC challenge, @Jussic -- if so, what's the name (I don't recognize it)
Suprith Aireddy
@sup-rith
Mar 09 2016 03:31
@Jussic whats your question?
J. Clarke
@Jussic
Mar 09 2016 03:31
Manipulate Arrays With pop : Use the .pop() function to remove the last item from myArray, assigning the "popped off" value to removedFromMyArray.
bitgrower
@bitgrower
Mar 09 2016 03:31
@Mortiferr -- 1. that's typical; 2. it gets more complex
Gershom
@jinmanbok
Mar 09 2016 03:31

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

Andrew Charlebois
@andrewchar
Mar 09 2016 03:32
@bitgrower way to break em down haha
Gershom
@jinmanbok
Mar 09 2016 03:32
I tried to do the golfscore activity but it doesn't work :(
Patrick Black
@Mortiferr
Mar 09 2016 03:32
@bitgrower I know, lol. I need to make some flashcards or something.
Andrew Charlebois
@andrewchar
Mar 09 2016 03:32
it gets harder, just you wait :P
Suprith Aireddy
@sup-rith
Mar 09 2016 03:32
@Jussic what is your array claaed?
called
Gershom
@jinmanbok
Mar 09 2016 03:33
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
J. Clarke
@Jussic
Mar 09 2016 03:33
Solved guys! Its cool thanks @sup-rith
CamperBot
@camperbot
Mar 09 2016 03:33
jussic sends brownie points to @sup-rith :sparkles: :thumbsup: :sparkles:
:star: 261 | @sup-rith | http://www.freecodecamp.com/sup-rith
bitgrower
@bitgrower
Mar 09 2016 03:33
just keep practicing ... I was actually writing a little piece of code the other day where I was creating properties in an object ... and I was going -- -OH YEAH this is COOL!!!!
sweet @Jussic
Andrew Charlebois
@andrewchar
Mar 09 2016 03:33
@jinmanbok have you tried using a switch statement?
Gershom
@jinmanbok
Mar 09 2016 03:33
I haven't made it that far
Patrick Black
@Mortiferr
Mar 09 2016 03:33
@Jussic I didn't use the && operator
Gershom
@jinmanbok
Mar 09 2016 03:33
Just using if else statements
Andrew Charlebois
@andrewchar
Mar 09 2016 03:34
@jinmanbok the lessons you covered just before that challenge went over them, did it not?
oh my bad
got mixed up
Patrick Black
@Mortiferr
Mar 09 2016 03:34
@Jussic For example, I would strokes == par + 1 do something like that instead. Use <= for a couple of them
Gershom
@jinmanbok
Mar 09 2016 03:34
Ah it's right after the golf code exercise
Patrick Black
@Mortiferr
Mar 09 2016 03:35
@Jussic That way, you can use a lot less code.
Andrew Charlebois
@andrewchar
Mar 09 2016 03:35
@jinmanbok post your code using backticks so we can see
help format
CamperBot
@camperbot
Mar 09 2016 03:35

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Patrick Black
@Mortiferr
Mar 09 2016 03:36
@Jussic I only used around 18 lines of code instead of your 50+
Gershom
@jinmanbok
Mar 09 2016 03:36
golfScore(4, 7) should return "Go Home!"
golfScore(5, 9) should return "Go Home!"
'''
CamperBot
@camperbot
Mar 09 2016 03:36
:bulb: to format code use backticks! ``` more info
Gershom
@jinmanbok
Mar 09 2016 03:36
oops sorry
Patrick Black
@Mortiferr
Mar 09 2016 03:36
'''
CamperBot
@camperbot
Mar 09 2016 03:36
:bulb: to format code use backticks! ``` more info
Gershom
@jinmanbok
Mar 09 2016 03:37

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

'''

CamperBot
@camperbot
Mar 09 2016 03:37
:bulb: to format code use backticks! ``` more info
Patrick Black
@Mortiferr
Mar 09 2016 03:37
lol nice correction
Andrew Charlebois
@andrewchar
Mar 09 2016 03:37
backticks party

Patrick Black
@Mortiferr
Mar 09 2016 03:37

bitgrower
@bitgrower
Mar 09 2016 03:37
click on the "more info" link, @Mortiferr
Gershom
@jinmanbok
Mar 09 2016 03:37

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

'''js

CamperBot
@camperbot
Mar 09 2016 03:37
:bulb: to format code use backticks! ``` more info
asaki444
@asaki444
Mar 09 2016 03:37
function mutation(arr) {
  var comp1 = arr[0].toLowerCase().split(" ");
  var comp2 = arr[1].toLowerCase().split(" ");
  for (var i = 0; i < arr.length; i++){
   if(comp1[i] in comp2){
     return true;
   }
    return false;
    }

}

mutation(["hello", "Hello"]);
I am not sure where I went wrong
I am doing the mutations algorithms
bitgrower
@bitgrower
Mar 09 2016 03:37
ahhhh ... i see success !!!! sweet sweet success!!!
Patrick Black
@Mortiferr
Mar 09 2016 03:38
@bitgrower I know, I was just messing around
Suprith Aireddy
@sup-rith
Mar 09 2016 03:38
@jinmanbok your if statements are incorrect.
Andrew Charlebois
@andrewchar
Mar 09 2016 03:38
code code
ouuu fancy
bitgrower
@bitgrower
Mar 09 2016 03:38
gotta love js -- you can't do this in another language without getting a compiter error: (if comp1[i] in comp2)
Gershom
@jinmanbok
Mar 09 2016 03:38
I did three backticks but not working @sup-rith ah really?
Andrew Charlebois
@andrewchar
Mar 09 2016 03:38
you need to have your backticks on a line alone
bitgrower
@bitgrower
Mar 09 2016 03:38
you thinking about indexOf, perhaps @asaki444
Andrew Charlebois
@andrewchar
Mar 09 2016 03:39
three backticks, go to next line. post code, go to next line, 3 backticks
Patrick Black
@Mortiferr
Mar 09 2016 03:39
yay everybody likes format ing
Gershom
@jinmanbok
Mar 09 2016 03:39

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

'''

CamperBot
@camperbot
Mar 09 2016 03:39
:bulb: to format code use backticks! ``` more info
bitgrower
@bitgrower
Mar 09 2016 03:39
'''
CamperBot
@camperbot
Mar 09 2016 03:39
:bulb: to format code use backticks! ``` more info
andreyorlov33
@andreyorlov33
Mar 09 2016 03:39
This message was deleted
bitgrower
@bitgrower
Mar 09 2016 03:39
click on the "more info" tag for back tick help
Gershom
@jinmanbok
Mar 09 2016 03:39

function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

```

Andrew Charlebois
@andrewchar
Mar 09 2016 03:39
3 backticks before the code to
Patrick Black
@Mortiferr
Mar 09 2016 03:39
You have to have three at the beginning and three at the end
Andrew Charlebois
@andrewchar
Mar 09 2016 03:39
on a line alone
3 lonely backticks
Gershom
@jinmanbok
Mar 09 2016 03:39

'''
function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";

}
else if(par==4 && strokes==6) {
return "Double Bogey";

}
else if(par==4 && strokes == 7) {
return "Go Home";

}

else if(par==5 && strokes == 9) {
return "Go Home";

}
else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(4, 7);

'''

CamperBot
@camperbot
Mar 09 2016 03:39
:bulb: to format code use backticks! ``` more info
Patrick Black
@Mortiferr
Mar 09 2016 03:40
backticks dude
Andrew Charlebois
@andrewchar
Mar 09 2016 03:40
well then
Patrick Black
@Mortiferr
Mar 09 2016 03:40
`
not '
Andrew Charlebois
@andrewchar
Mar 09 2016 03:40
above your tab
Patrick Black
@Mortiferr
Mar 09 2016 03:40
see!
bitgrower
@bitgrower
Mar 09 2016 03:40

@jinmanbok -- you gotta start your code with a line which has 3 backticks on it, by itself ...

in some cases, you also need to follow the 3 backticks with js -- so it would look like this ```js

Andrew Charlebois
@andrewchar
Mar 09 2016 03:40
backticks not quotation marks
Patrick Black
@Mortiferr
Mar 09 2016 03:40
:)_
help format
CamperBot
@camperbot
Mar 09 2016 03:40

: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

Patrick Black
@Mortiferr
Mar 09 2016 03:40
see
Andrew Charlebois
@andrewchar
Mar 09 2016 03:40
we will get there
believe you must
Patrick Black
@Mortiferr
Mar 09 2016 03:41
help
CamperBot
@camperbot
Mar 09 2016 03:41

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

Basic Commands:

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

:speech_balloon: meet CamperBot in this room!

:pencil: read more about camperbot on the FCC Wiki

Patrick Black
@Mortiferr
Mar 09 2016 03:41
find js
bitgrower
@bitgrower
Mar 09 2016 03:41
oh interesting ... i like that command!
andreyorlov33
@andreyorlov33
Mar 09 2016 03:41
This message was deleted
Andrew Charlebois
@andrewchar
Mar 09 2016 03:41
didnt know about that one
bitgrower
@bitgrower
Mar 09 2016 03:42
i'd seen it -- but never in action ...
Patrick Black
@Mortiferr
Mar 09 2016 03:42
help
bitgrower
@bitgrower
Mar 09 2016 03:42
or maybe I just got too much jquery .find on Saturday ...
Patrick Black
@Mortiferr
Mar 09 2016 03:42
lol
@camperbot Hi
Andrew Charlebois
@andrewchar
Mar 09 2016 03:42
@jinmanbok
function golfScore(par, strokes) {
// Only change code below this line
if (par==4 && strokes == 1) {
return "Hole-in-one!";
}
else if (par==4 && strokes == 2) {
return "Eagle";
}
else if (par==5 && strokes== 2) {
return "Eagle";
}
else if (par==4 && strokes ==3) {
return "Birdie";
}
else if (par==4 && strokes ==4) {
return "Par";
}
else if (par==1 && strokes==1) {
return "Hole-in-one!";
}
else if (par==5 && strokes==5) {
return "Par";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes==5) {
return "Bogey";
}
else if(par==4 && strokes==6) {
return "Double Bogey";
}
else if(par==4 && strokes == 7) {
return "Go Home";
}
else if(par==5 && strokes == 9) {
return "Go Home";
}
else {
return "Go Home";
}
// Only change code above this line
}
// Change these values to test
golfScore(4, 7);
Patrick Black
@Mortiferr
Mar 09 2016 03:43
you did it
:clap:
Andrew Charlebois
@andrewchar
Mar 09 2016 03:43
that was me
bitgrower
@bitgrower
Mar 09 2016 03:43
@andrewchar did it ... he's a past master ...
Andrew Charlebois
@andrewchar
Mar 09 2016 03:43
a what
Patrick Black
@Mortiferr
Mar 09 2016 03:43
oh
I cri
I think he means you already knew how
John Pyles
@japyles
Mar 09 2016 03:43
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 lookUp(firstName, prop){
// Only change code below this line
  for (i = 0; i < contacts.length; i++) {
    if (contacts[i].firstName === firstName) { //This checks if name is in array, right? 
      if (contacts[i].hasOwnProperty(prop)) { //If name is found, it goes here and looks for prop, correct?
      return contacts[i][prop]; //I think this is where it is going wrong, but not sure why. 
      }
    return 'No such property';
    }
  return 'No such contact';
  }

// Only change code above this line
}

// Change these values to test your function
lookUp("Harry", "likes");
bitgrower
@bitgrower
Mar 09 2016 03:44
yes ... you've already mastered the formatting topic
John Pyles
@japyles
Mar 09 2016 03:44
Hi everyone. Not sure why my code’s not working
I added comments to what my thought process is
Patrick Black
@Mortiferr
Mar 09 2016 03:44
I think your formatting is wrong on the return contacts[i][prop]
Andrew Charlebois
@andrewchar
Mar 09 2016 03:44
@japyles you dont actually have to check the prop
bitgrower
@bitgrower
Mar 09 2016 03:44
AWESOME ... congrats ... I was just reading them ... actually, that one line checks for the firstname propety in the particular element of the array ...
John Pyles
@japyles
Mar 09 2016 03:45
@andrewchar but I thought it said I had to check for name and prop
Patrick Black
@Mortiferr
Mar 09 2016 03:45
You shouldn't need to return [i]
bitgrower
@bitgrower
Mar 09 2016 03:45
he means with .hasOwnProperty, I think ...
Andrew Charlebois
@andrewchar
Mar 09 2016 03:46
@japyles its misleading i think. your checking the firstnames which is correct. for the property check you just want to make sure its there
@japyles so checking with hasownproperty is not needed
andreyorlov33
@andreyorlov33
Mar 09 2016 03:47
Hey Guys ! I was working on the Record Collection Challenge and for some reason my code is not going through. Can some one please take a look and explain why its not working ???
Tons of thanks guys!!
// Setup
var collection = {
    2548: {
      album: "Slippery When Wet",
      artist: "Bon Jovi",
      tracks: [ 
        "Let It Rock", 
        "You Give Love a Bad Name" 
      ]
    },
    2468: {
      album: "1999",
      artist: "Prince",
      tracks: [ 
        "1999", 
        "Little Red Corvette" 
      ]
    },
    1245: {
      artist: "Robert Palmer",
      tracks: [ ]
    },
    5439: {
      album: "ABBA Gold"
    }
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

  return collection;
}

// Alter values below to test your code
update(2458, "track", 'Abba');
John Pyles
@japyles
Mar 09 2016 03:47
@andrewchar I thought the hasOwnProperty was the way to check if the property was there.
bitgrower
@bitgrower
Mar 09 2016 03:47
I actually used .hasOwnProperty in this challenge, tbh
I wouldn't discourage its use ...
Gershom
@jinmanbok
Mar 09 2016 03:47

 function golfScore(par, strokes) {
  // Only change code below this line
  if (par==4 && strokes == 1) {
    return "Hole-in-one!";
  }
  else if (par==4 && strokes == 2) {
    return "Eagle";
  }
  else if (par==5 && strokes== 2) {
    return "Eagle";
  }
  else if (par==4 && strokes ==3) {
    return "Birdie";
  }
  else if (par==4 && strokes ==4) {
    return "Par";
  }
  else if (par==1 && strokes==1) {
    return "Hole-in-one!";
  }
  else if (par==5 && strokes==5) {
    return "Par";
  }
  else if(par==4 && strokes==5) {
    return "Bogey";
  }
   else if(par==4 && strokes==6) {
    return "Double Bogey";
   }
      else if(par==4 && strokes==5) {
    return "Bogey";

  }
  else if(par==4 && strokes==6) {
    return "Double Bogey";

  }
  else if(par==4 && strokes == 7) {
    return "Go Home";

  }

  else if(par==5 && strokes == 9) {
    return "Go Home";

  }
  else {
  return "Go Home";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(4, 7);
browser is buggy..
Andrew Charlebois
@andrewchar
Mar 09 2016 03:48
@japyles @bitgrower would know better then me, i didnt use it but apparently you should
i did not use it because the code would not work for me when i tried using it
Gershom
@jinmanbok
Mar 09 2016 03:48
thanks lol
John Pyles
@japyles
Mar 09 2016 03:48
@Mortiferr I tried different ways of returning the property but none of them worked
bitgrower
@bitgrower
Mar 09 2016 03:49
@japyles -- I think the only thing you are missing is returning the "no such contact" message correctly ...
Gershom
@jinmanbok
Mar 09 2016 03:50
@Mortiferr Ok thanks!
CamperBot
@camperbot
Mar 09 2016 03:50
jinmanbok sends brownie points to @mortiferr :sparkles: :thumbsup: :sparkles:
:star: 131 | @mortiferr | http://www.freecodecamp.com/mortiferr
Gershom
@jinmanbok
Mar 09 2016 03:50
How do I give you guys kudos
John Pyles
@japyles
Mar 09 2016 03:51
@bitgrower I re-aligned my returns to match the correct if statements. The ‘No such contact’ is actually what is being returned when the code is executed, even with a contact that is actually there
Andrew Charlebois
@andrewchar
Mar 09 2016 03:51
click their name and say thanks
@japyles your last return is in the wrong place
bitgrower
@bitgrower
Mar 09 2016 03:51
@japyles -- I'm lazy tonight, so I'm not gonna pull it out of ya ... that message has to be returned outside of the loop
asaki444
@asaki444
Mar 09 2016 03:51
@bitgrower I looked it up. It only gives me the position of the element
Gershom
@jinmanbok
Mar 09 2016 03:52
@Mortiferr thanks
CamperBot
@camperbot
Mar 09 2016 03:52
jinmanbok sends brownie points to @mortiferr :sparkles: :thumbsup: :sparkles:
:warning: jinmanbok already gave mortiferr points
Gershom
@jinmanbok
Mar 09 2016 03:52
@andrewchar thanks
CamperBot
@camperbot
Mar 09 2016 03:52
jinmanbok sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 343 | @andrewchar | http://www.freecodecamp.com/andrewchar
John Pyles
@japyles
Mar 09 2016 03:53
@bitgrower Outside of the for or the if loop? I’ve tried both to no avail. Seems to me that it should line up with the if loop that looks for the firstName
@bitgrower Woaaaah! It worked! I figured out how to place it properly outside of the loop THANKS!
CamperBot
@camperbot
Mar 09 2016 03:56
japyles sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 781 | @bitgrower | http://www.freecodecamp.com/bitgrower
John Pyles
@japyles
Mar 09 2016 03:57
Thanks! @bitgrower @andrewchar @Mortiferr
CamperBot
@camperbot
Mar 09 2016 03:57
japyles sends brownie points to @bitgrower and @andrewchar and @mortiferr :sparkles: :thumbsup: :sparkles:
:warning: japyles already gave bitgrower points
:star: 132 | @mortiferr | http://www.freecodecamp.com/mortiferr
:star: 344 | @andrewchar | http://www.freecodecamp.com/andrewchar
bitgrower
@bitgrower
Mar 09 2016 03:59
since I was lazy, @japyles -- your next assignment is to understand WHY it has to be outside the loop
understanding when, and when not to, return within a loop is a very important tidbit ... and it comes up in various challenges ... not just this one ...
John Pyles
@japyles
Mar 09 2016 04:00
@bitgrower Let me think about that for a moment :)
bitgrower
@bitgrower
Mar 09 2016 04:01
here's the analogy I use, @japyles -- if you have a bag of 10 marbles ... how many of the marbles do you have to look at to know there are no black marbles in the bag ?
John Pyles
@japyles
Mar 09 2016 04:01
@bitgrower Is it because if the array does not contain firstName that it just falls out of the loop?
bitgrower
@bitgrower
Mar 09 2016 04:02
yes ... and you have to look thru the ENTIRE array to say that ... and you've not looked thru the entire array until you drop out of the loop
John Pyles
@japyles
Mar 09 2016 04:03
@bitgrower It has taken me some time to figure out this assignment, but I am glad I stuck with it and I do appreciate your time in helping me understand the WHY and not just the HOW
bitgrower
@bitgrower
Mar 09 2016 04:03
:)
Andrew Charlebois
@andrewchar
Mar 09 2016 04:04
so my chat does weird stuff lately
stop working and give dns message
bitgrower
@bitgrower
Mar 09 2016 04:04

yeah, I can be a bit of a hard aXX sometimes, because I want to help people to discover the answers for themselves ... so I try to use socratic reasoning so they will see the answer for themselves ...

(this, incidentally, has also been shown, in learning theory, to help retention)

how often do you reboot your router/modem, @andrewchar
Andrew Charlebois
@andrewchar
Mar 09 2016 04:05
never
bitgrower
@bitgrower
Mar 09 2016 04:05
you should ... it's a new playground for hackers ...
Andrew Charlebois
@andrewchar
Mar 09 2016 04:06
srsly?
i have not rebooted in forever
bitgrower
@bitgrower
Mar 09 2016 04:06
the other question is what you use for DNS ... my isp is notorious for DNS issues ... so I use google dns ... (there's also an "openDNS" you can use as well)
srsly
Andrew Charlebois
@andrewchar
Mar 09 2016 04:06
i do when i notice stuff justs not going right
bitgrower
@bitgrower
Mar 09 2016 04:07
I mean, the other thing is to check other connections between your computer and the rest of the web -- like loose coax cables, etc ...
Andrew Charlebois
@andrewchar
Mar 09 2016 04:07
i am on satellite internet
bitgrower
@bitgrower
Mar 09 2016 04:07
just about everything computer-ish should be re-booted from time to time ...
Andrew Charlebois
@andrewchar
Mar 09 2016 04:07
not sure if that makes a difference.
bitgrower
@bitgrower
Mar 09 2016 04:07
well ... clouds, I hear, can cause problems with satellite internet ...
Andrew Charlebois
@andrewchar
Mar 09 2016 04:09
rude clouds
smzagury
@smzagury
Mar 09 2016 04:15
I need help with my code. It's the random code generator
Andrew Charlebois
@andrewchar
Mar 09 2016 04:15
give us that sweet sweet code
Rex Schrader
@SaintPeter
Mar 09 2016 04:16
AAaaawwww yeah . . . sweet sweet code!
smzagury
@smzagury
Mar 09 2016 04:16
I can't get the button to work
Andrew Charlebois
@andrewchar
Mar 09 2016 04:16
haha peter
Rex Schrader
@SaintPeter
Mar 09 2016 04:16
@smzagury Why do you have all your quotes commented out?
@smzagury Also, I don't see a click handler.
smzagury
@smzagury
Mar 09 2016 04:17
I figured I'd try to get the button to work with a very simple function, then when it works apply it to the more complex function. So right now we're trying to change the blockquote text to red.
@SaintPeter Dinstrinctly possible. I don't really know what I'm doing.
Andrew Charlebois
@andrewchar
Mar 09 2016 04:18
@smzagury you can search up jquery on "click functions
Rex Schrader
@SaintPeter
Mar 09 2016 04:18
@smzagury ok, so
document.getElementById('newQuote').addEventListener('click', function(e) {
    // do stuff here
});
I think
smzagury
@smzagury
Mar 09 2016 04:19
What does the e do/represent?
Rex Schrader
@SaintPeter
Mar 09 2016 04:20
@smzagury It's the event object. It passes in data about the click. For example, e.target is a link to the button DOM object
@smzagury Oh, my bad, it's addEventListener
smzagury
@smzagury
Mar 09 2016 04:21
@SaintPeter Do the commented out parts look ok?
So I write a JQ click handler, then use it to call the JS function?
asaki444
@asaki444
Mar 09 2016 04:23
function mutation(arr) {
  var comp1 = arr[0].toLowerCase().split(" ");
  var comp2 = arr[1].toLowerCase().split(" ");
  for (var i = 0; i < comp1.length; i++){
   if(comp1[i].indexOf(comp2) >= 0){
     return true;
   }
   else if(comp2[i].indexOf(comp1)>=0){
     return true;
   }
    return false;
    }

}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);
The strings won't turn into an array for some reason
Rex Schrader
@SaintPeter
Mar 09 2016 04:23
@smzagury No, jQuery makes your life easier. It's an alternative to vanilla JS. You can do:
$('#newQuote').on('click', function(e) {
   // do click stuff here
});
@asaki444 You are returning after only the first itteration of your loop. You cannot return true from within your loop because there is no way to tell if everything is present until you have completed your loop.
smzagury
@smzagury
Mar 09 2016 04:24
k. Thanks @SaintPeter . I'll play around more and you'll probably see me back here on a different day.
CamperBot
@camperbot
Mar 09 2016 04:24
smzagury sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2623 | @saintpeter | http://www.freecodecamp.com/saintpeter
Andrew Charlebois
@andrewchar
Mar 09 2016 04:26
am i doing something stupid for this not to console.log anything
if (str > num) {
    var sliced = str.slice(num, -3) + "...";
  console.log(sliced);
  }
Rex Schrader
@SaintPeter
Mar 09 2016 04:26
@andrewchar Is str a string? and is num a number?
Andrew Charlebois
@andrewchar
Mar 09 2016 04:26
yes
Rex Schrader
@SaintPeter
Mar 09 2016 04:27
@andrewchar Then what does str > num mean?
Andrew Charlebois
@andrewchar
Mar 09 2016 04:27
wait
lol
yup, something stupid
Rex Schrader
@SaintPeter
Mar 09 2016 04:27
@andrewchar (Short answer, yeah, a little dumb . . . but that's cool)
Andrew Charlebois
@andrewchar
Mar 09 2016 04:27
.length
i got this
Rex Schrader
@SaintPeter
Mar 09 2016 04:27
@andrewchar :D :D
Andrew Charlebois
@andrewchar
Mar 09 2016 04:27
dont you worry :P
Rex Schrader
@SaintPeter
Mar 09 2016 04:27
:heart:
SaintPeter @SaintPeter is not worried.
Andrew Charlebois
@andrewchar
Mar 09 2016 04:28
i cant stop laughing a bit
/facepalm
Rex Schrader
@SaintPeter
Mar 09 2016 04:28
@andrewchar All of programming is a series of quasi-embaressing mistakes.
Andrew Charlebois
@andrewchar
Mar 09 2016 04:29
ohh?
that sounds like fun to watch
Rex Schrader
@SaintPeter
Mar 09 2016 04:29
Seriously.
You should tune into some of our Twitch streaming
asaki444
@asaki444
Mar 09 2016 04:29
@smzagury thanks
CamperBot
@camperbot
Mar 09 2016 04:29
asaki444 sends brownie points to @smzagury :sparkles: :thumbsup: :sparkles:
:star: 282 | @smzagury | http://www.freecodecamp.com/smzagury
Rex Schrader
@SaintPeter
Mar 09 2016 04:29
where you can see poeple make mistakes on live TV
Andrew Charlebois
@andrewchar
Mar 09 2016 04:30
ffc twitch?
im there all the time
Rex Schrader
@SaintPeter
Mar 09 2016 04:31
I think the greatest lie we tell ourselves is that "good programmers" write flawless code the first time.
The reality is that a good programmer might wright slightly better code the first time, but will be faster at debugging the error.
bitgrower @bitgrower says programming is a humbling experience ...
SaintPeter @SaintPeter says AMEN to that
Rex Schrader
@SaintPeter
Mar 09 2016 04:32
"Programmers are paid to be frusturated"
Andrew Charlebois
@andrewchar
Mar 09 2016 04:32
where is this series
Greg D
@mosaic-greg
Mar 09 2016 04:33
making progress, almost there:
rot13("SERR PBQR PNZC");
~result~
"FREE-CODE-C[MP"
bitgrower
@bitgrower
Mar 09 2016 04:33
people come in here and say ... "oh I made a stupid mistake" ... and I go ... get used to it ... we humans are not used to the exacting demands of programming .. few other endeavors have this need for exactitude (that said, i've still seen some amazing bugs living in code for years...)
@mosaic-greg -- you need to have 1 if statement that checks your character for being within a range ... you have to check against the bottom & top of the range at the same time...
Rex Schrader
@SaintPeter
Mar 09 2016 04:34
@mosaic-greg Looking good - You need to skip things which are not alphabetic. You also need to check your boundry conditions.
bitgrower @bitgrower is getting used to what kind of error produces the "-" problem ...
Rex Schrader
@SaintPeter
Mar 09 2016 04:34
@mosaic-greg I think you're off by 1 - I'm pretty sure that N is close to the middle of the alphabet
SaintPeter @SaintPeter laughs
bitgrower
@bitgrower
Mar 09 2016 04:35
M = 13 ...
I thank the legalize MJ folks for that tidbit of knowledge ...
Rex Schrader
@SaintPeter
Mar 09 2016 04:36
Haha, I see what kind of bits you're growing . . .
bitgrower
@bitgrower
Mar 09 2016 04:36
nah ... just live in California, grew up in the 60s ...
Greg D
@mosaic-greg
Mar 09 2016 04:36
@SaintPeter aw yep thnx
CamperBot
@camperbot
Mar 09 2016 04:36
mosaic-greg sends brownie points to @saintpeter :sparkles: :thumbsup: :sparkles:
:star: 2624 | @saintpeter | http://www.freecodecamp.com/saintpeter
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:37
Evening everybody! Was hoping to get a little advice on the Mutations problem. I'm having a hard time coming up with a way to check for letters that are out of order. My code, posted below, works for the strings that appear in the proper order, but something like mutation(["Mary", "Army"]) returns false since right now I'm only using the indexOf() method. Here is my code:
bitgrower
@bitgrower
Mar 09 2016 04:37
what ?!?! you don't like my suggestions @mosaic-greg ?!?! :( :( :(
Greg D
@mosaic-greg
Mar 09 2016 04:37
@bitgrower aw some tax for you
CamperBot
@camperbot
Mar 09 2016 04:37
mosaic-greg sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:37
function mutation(arr) {
  arr = arr.join(" ").toLowerCase().split(" ");
  bool = arr[0].indexOf(arr[1]);
  return (bool !== -1);
}
mutation(["hello", "Hello"]);
CamperBot
@camperbot
Mar 09 2016 04:37
:star: 782 | @bitgrower | http://www.freecodecamp.com/bitgrower
bitgrower
@bitgrower
Mar 09 2016 04:37
thank you ...but seriously ... did they help ? :)
Rex Schrader
@SaintPeter
Mar 09 2016 04:38
@AmirEskandari87 You need to loop through all of the letters one at a time. You're on the right track, though.
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:39
@SaintPeter Ah I see, OK I will give that a shot.
Joshua Jerrick
@JoshuaJerrick
Mar 09 2016 04:41
does anyone understand the word blanks challenge in the beginner js for the front end development challenge?
bitgrower
@bitgrower
Mar 09 2016 04:41
@AmirEskandari87 -- i think your return statement is not correct as well ... -- if (bool !== -1) it means the character was not found, but that statement by itself is going to evaluate to true if a character is not found .. I think you want to return false under that condition, no ?
Robert Richey
@0x0936
Mar 09 2016 04:43
the tic tac toe is getting to me. time for a break or three
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:43
hi everyone im facing couple of problem in my script .i think everythings seems ok to me. but problem was im not able to complete this challenge can anybody help me here is my switch statement
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:44
@bitgrower if (bool !== -1) it means the character(s) was/were found.
Robert Richey
@0x0936
Mar 09 2016 04:44
@JoshuaJerrick basically, use the provided variables and add your own words, for a complete sentence
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:45
@bitgrower Maybe I'm not thinking about it correctly..
Joshua Jerrick
@JoshuaJerrick
Mar 09 2016 04:45
ok let me try @0x0936
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:46
@bitgrower I think the return is correct.
bitgrower
@bitgrower
Mar 09 2016 04:46
me too -- and you're right ...
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:46
@bitgrower Took me a second to think about the logic again haha..
bitgrower
@bitgrower
Mar 09 2016 04:47
yeah .. which is another concern with that kind of construct -- it's not quite immediate what it's doing ... (though maybe it's just matter of repetition...)
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:47

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

switch(val){
case val== "alpha":
answer="hello world";
break;
case "beta":
answer="Im learning FSD At FCC";
break;
case"gama":
answer="This is very good place for learn new things";
break;
default: answer="delta";

}

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

// Change this value to test
myTest('alpha');

how to take snapshot of our code any trick available here

bitgrower
@bitgrower
Mar 09 2016 04:48
...but still thinking about it, @AmirEskandari87 ...
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:48
@bitgrower Right. Yeah I originally had the standard if/else return true/false, then I changed it to this to make it "cleaner".
bitgrower
@bitgrower
Mar 09 2016 04:48
it may be returning the right answer for the wrong reasons ...
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:48
@bitgrower Hmmmmm..
bitgrower
@bitgrower
Mar 09 2016 04:49
iow ... is bool strictly equal to -1 .. no ... it's not
so it evaluates to false ...
Amir Eskandari
@AmirEskandari87
Mar 09 2016 04:50
@bitgrower This is my thought process: If indexOf() returns -1, it means no matching string was found, so that's what I'm checking for the return.
@bitgrower I figured that was the only check required for this challenge.
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:51
how did you finished this challenge Selecting from many options with Switch Statements ..im stuck here can anybody share your code for this challenge .thanks in advance
bitgrower
@bitgrower
Mar 09 2016 04:51
negative logic can be tricky!
V Arun Kumar
@arunvkumr
Mar 09 2016 04:51
@MaheshProgrammerz post your code here we will try to help you out :smiley:
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:52
i did every things to it what i know but it doesnt work

@arunkumrv here is my code function myTest(val) {
var answer = "";
// Only change code below this line

switch(val){
case val== "alpha":
answer="hello world";
break;
case "beta":
answer="Im learning FSD At FCC";
break;
case"gama":
answer="This is very good place for learn new things";
break;
default: answer="delta";

}

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

// Change this value to test
myTest('alpha');

Jared Pranke
@EtherWolf
Mar 09 2016 04:53
code formatting
bitgrower
@bitgrower
Mar 09 2016 04:53
what challenge is this, @MaheshProgrammerz ?
V Arun Kumar
@arunvkumr
Mar 09 2016 04:53
@MaheshProgrammerz 1st case val == "alpha" check that statement again
bitgrower
@bitgrower
Mar 09 2016 04:53
^^^^^ what @arunkumrv said
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:54
@bitgrower this is Selecting from many options with Switch Statements challenge
bitgrower
@bitgrower
Mar 09 2016 04:54
thanks, @MaheshProgrammerz
CamperBot
@camperbot
Mar 09 2016 04:54
bitgrower sends brownie points to @maheshprogrammerz :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for maheshprogrammerz
bitgrower
@bitgrower
Mar 09 2016 04:54
ahh .. you haven't linked up your fcc/git repo etc with gitter ...
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:54
let me check
bitgrower
@bitgrower
Mar 09 2016 04:56
yeah, not finding your profile (at least under this name: MaheshProgrammerz ) on FCC ...
MaheshProgrammerz
@MaheshProgrammerz
Mar 09 2016 04:59
@bitgrower what are you talking about
bitgrower
@bitgrower
Mar 09 2016 05:04
http://www.freecodecamp.com/maheshprogrammerz <-- should be where your FCC profile can be found if you set up the linkages between FCC, git & gitter correctly ... (should use the same name on all 3)
Andrew Charlebois
@andrewchar
Mar 09 2016 05:11
woohoo it only took me like 15 minutes to solve truncate a string
feels good :)
Gershom
@jinmanbok
Mar 09 2016 05:14

'''js function golfScore(par, strokes) {
// Only change code below this line
if (strokes == par -3 || strokes && par ==1) {
return "Hole-in-one!";
}
else if (strokes <= par -2) {
return "Eagle";
}

else if (strokes== par -1) {
return "Birdie";
}
else if (strokes== par) {
return "Par";
}

else if(strokes== par +1) {
return "Bogey";
}
else if(strokes== par +2) {
return "Double Bogey";
}

else if(strokes >= par + 3) {
return "Go Home!";

}

else if(strokes >= par + 3) {
return "Hole-in-one!";

}

else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 2);

CamperBot
@camperbot
Mar 09 2016 05:14
:bulb: to format code use backticks! ``` more info
Gershom
@jinmanbok
Mar 09 2016 05:14
This message was deleted

```js function golfScore(par, strokes) {
// Only change code below this line
if (strokes == par -3 || strokes && par ==1) {
return "Hole-in-one!";
}
else if (strokes <= par -2) {
return "Eagle";
}

else if (strokes== par -1) {
return "Birdie";
}
else if (strokes== par) {
return "Par";
}

else if(strokes== par +1) {
return "Bogey";
}
else if(strokes== par +2) {
return "Double Bogey";
}

else if(strokes >= par + 3) {
return "Go Home!";

}

else if(strokes >= par + 3) {
return "Hole-in-one!";

}

else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 2);
```

```js function golfScore(par, strokes) {
// Only change code below this line
if (strokes == par -3 || strokes && par ==1) {
return "Hole-in-one!";
}
else if (strokes <= par -2) {
return "Eagle";
}

else if (strokes== par -1) {
return "Birdie";
}
else if (strokes== par) {
return "Par";
}

else if(strokes== par +1) {
return "Bogey";
}
else if(strokes== par +2) {
return "Double Bogey";
}

else if(strokes >= par + 3) {
return "Go Home!";

}

else if(strokes >= par + 3) {
return "Hole-in-one!";

}

else {
return "Go Home";
}
// Only change code above this line
}

// Change these values to test
golfScore(5, 2);

```

bitgrower
@bitgrower
Mar 09 2016 05:17

@jinmanbok -- 3 different copies of your code ?!?

@andrewchar -- congrats !

Gershom
@jinmanbok
Mar 09 2016 05:17
I pasted my code with the 3 backsticks and js but the code didn't paste properly still
Andrew Charlebois
@andrewchar
Mar 09 2016 05:18
you need your backticks to be on a line alone
bitgrower
@bitgrower
Mar 09 2016 05:18
you can delete and/or edit your message ...
bigbeno37
@bigbeno37
Mar 09 2016 05:18
Hey, can anyone help me with the Seek and Destroy challenge?
Andrew Charlebois
@andrewchar
Mar 09 2016 05:18
backticks ALONE on a single line, on the top and botton of your code
Gershom
@jinmanbok
Mar 09 2016 05:18
js function golfScore(par, strokes) {
  // Only change code below this line
  if (strokes == par -3 || strokes && par ==1) {
    return "Hole-in-one!";
  }
  else if (strokes <= par -2) {
    return "Eagle";
  }

  else if (strokes== par -1) {
    return "Birdie";
  }
  else if (strokes== par) {
    return "Par";
  }

  else if(strokes== par +1) {
    return "Bogey";
  }
   else if(strokes== par +2) {
    return "Double Bogey";
   }


  else if(strokes >= par + 3) {
    return "Go Home!";

  }

 else if(strokes >= par + 3) {
    return "Hole-in-one!";

  }


  else {
  return "Go Home";
  }
  // Only change code above this line
}

// Change these values to test
golfScore(5, 2);
V Arun Kumar
@arunvkumr
Mar 09 2016 05:18
help format
CamperBot
@camperbot
Mar 09 2016 05:18

: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

Gershom
@jinmanbok
Mar 09 2016 05:18
Sorry still new to this
golfScore(5, 2) should return "Eagle"
Andrew Charlebois
@andrewchar
Mar 09 2016 05:19
@jinmanbok what is a hole in one when reference it to strokes?
Gershom
@jinmanbok
Mar 09 2016 05:19
That's the only thing messed up
Andrew Charlebois
@andrewchar
Mar 09 2016 05:19
@jinmanbok how many strokes in a hole in one
Gershom
@jinmanbok
Mar 09 2016 05:20
Like if par is usually 3 and you get a hole in one one the first stroke
Andrew Charlebois
@andrewchar
Mar 09 2016 05:20
@jinmanbok your hole in one is passing the test?
Gershom
@jinmanbok
Mar 09 2016 05:20
Yeah
Andrew Charlebois
@andrewchar
Mar 09 2016 05:20
oh
Gershom
@jinmanbok
Mar 09 2016 05:20
But the logic is weird.... like i know the first stroke...and in the hole is a hole in one
but par is usually 3 strokes ... 1 stroke and 2 puts
golf is confusing for me
Andrew Charlebois
@andrewchar
Mar 09 2016 05:21
just need to follow the little table they have
Gershom
@jinmanbok
Mar 09 2016 05:21
So I cheated and put the "or" symbol with par==1 and stroke ==1
I did but it wouldn't work for eagle as well
<= par -2
strokes < = par -2 but Eagle is still not working...
And i guess hole in one code is wrong...but passes the test
Is it just a bug?
Andrew Charlebois
@andrewchar
Mar 09 2016 05:23
well
i have no idea how thats passing
but you can just say if strokes is 1
then its a hole in one
no compare it and do math with it
1 strokes, hole in one. thats it
stroke*
i think your if statement for that is messing with your next lines or something.ionno
Gershom
@jinmanbok
Mar 09 2016 05:25
Ah it works now @andrewchar thanks
CamperBot
@camperbot
Mar 09 2016 05:25
jinmanbok sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 345 | @andrewchar | http://www.freecodecamp.com/andrewchar
Andrew Charlebois
@andrewchar
Mar 09 2016 05:25
np
Gershom
@jinmanbok
Mar 09 2016 05:25
Yeah it was weird...lol (^_^)^ Thanks for the logic help!
Have a good day!
Andrew Charlebois
@andrewchar
Mar 09 2016 05:26
you two.
to*
my god cant type
Gershom
@jinmanbok
Mar 09 2016 05:26
lol me too
Tabi
@mrpassiontea
Mar 09 2016 05:39
Help guys! I don't understand the www.freecodecamp.com/challenges/word-blanks
CamperBot
@camperbot
Mar 09 2016 05:39
no wiki entry for: guys i dont understand the wwwfreecodecampcomchallengesword-blanks
V Arun Kumar
@arunvkumr
Mar 09 2016 05:39
@mrpassiontea help word blanks
Tabi
@mrpassiontea
Mar 09 2016 05:39
what?
V Arun Kumar
@arunvkumr
Mar 09 2016 05:39
help work blanks
CamperBot
@camperbot
Mar 09 2016 05:39
no wiki entry for: work blanks
Andrew Charlebois
@andrewchar
Mar 09 2016 05:40
@mrpassiontea it just wants you to concatenate a string while using the function's parameters in that string.
Tabi
@mrpassiontea
Mar 09 2016 05:40
I still don't get it ._.
Andrew Charlebois
@andrewchar
Mar 09 2016 05:41
thats the one where they refence the game mad libs right
Tabi
@mrpassiontea
Mar 09 2016 05:41
yeah
Andrew Charlebois
@andrewchar
Mar 09 2016 05:41
yeah so they want you to make a string right
V Arun Kumar
@arunvkumr
Mar 09 2016 05:41
@mrpassiontea you have given 4 parameters in the function you have to concatenate those words with your words and return it.
Andrew Charlebois
@andrewchar
Mar 09 2016 05:41
and you know you can use the plus sign to put stuff together in a string
Tabi
@mrpassiontea
Mar 09 2016 05:41
Yeah I understand that
V Arun Kumar
@arunvkumr
Mar 09 2016 05:42
to add two string use + as @andrewchar said
Tabi
@mrpassiontea
Mar 09 2016 05:42
Yeah I understand that, I just don't understand what they want me to do
This si the code:

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

._.
V Arun Kumar
@arunvkumr
Mar 09 2016 05:43
@mrpassiontea you have to make a new string here.. result using mynoun, myadjective, myverb and myadverd
Andrew Charlebois
@andrewchar
Mar 09 2016 05:43
var a = "string" + "string"; i just concatenated 2 strings. all you need to do is use the parameters (myNoun, myAdjective, myVerb, myAdverb) while adding words between them using the + to concatenate
@mrpassiontea and remember you do not need to put parenthesis around your parameters
走你飛艇
@gofighting123
Mar 09 2016 05:45
i got stuck at
http://www.freecodecamp.com/challenges/profile-lookup
where i can ask help @@
Andrew Charlebois
@andrewchar
Mar 09 2016 05:46
right here my friend
what code do you have
走你飛艇
@gofighting123
Mar 09 2016 05:46
0.0
V Arun Kumar
@arunvkumr
Mar 09 2016 05:46
@mrpassiontea you have parameters dog, big, ran, quickly. using this words make a new word something like The big dog after seeing me ran very quickly.
走你飛艇
@gofighting123
Mar 09 2016 05:46
i put the code on codepen or somewhere ?
Andrew Charlebois
@andrewchar
Mar 09 2016 05:46
no you can post it here
V Arun Kumar
@arunvkumr
Mar 09 2016 05:46
@gofighting123 post your code here.. listen to what camperbot has to say
Andrew Charlebois
@andrewchar
Mar 09 2016 05:46
help format
CamperBot
@camperbot
Mar 09 2016 05:46

: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

V Arun Kumar
@arunvkumr
Mar 09 2016 05:46
help format
CamperBot
@camperbot
Mar 09 2016 05:46

: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

Andrew Charlebois
@andrewchar
Mar 09 2016 05:47
use that format to post code here
BEAT YOU!
走你飛艇
@gofighting123
Mar 09 2016 05:47
ok i see
Andrew Charlebois
@andrewchar
Mar 09 2016 05:47
:P:P
V Arun Kumar
@arunvkumr
Mar 09 2016 05:47
:smile:
走你飛艇
@gofighting123
Mar 09 2016 05:47

function lookUp(firstName, prop){
// Only change code below this line
var msg="";
var found=false;

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

if (contacts[i].firstName == firstName) {
  switch (prop) {
    case "lastName":
    case "number":
    case "likes":
      msg=contacts[i][prop];
      found=true;
      break;
    default:
      msg="No such property";
  }
}
if (contacts[i].firstName !== firstName) {
    msg= "No such contact";
}

if (found) break;

}

return msg;

// Only change code above this line
}

that's cool@@
it's first time i use the chat for help @@
Andrew Charlebois
@andrewchar
Mar 09 2016 05:48
not sure whats going on there you have code that didnt get put between your ticks
can you try that again
走你飛艇
@gofighting123
Mar 09 2016 05:49
ok i try@@

function lookUp(firstName, prop){
// Only change code below this line
var msg="";
var found=false;

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

if (contacts[i].firstName == firstName) {
  switch (prop) {
    case "lastName":
    case "number":
    case "likes":
      msg=contacts[i][prop];
      found=true;
      break;
    default:
      msg="No such property";
  }
}
if (contacts[i].firstName !== firstName) {
    msg= "No such contact";
}

if (found) break;

}

return msg;

// Only change code above this line
}

oh my @@
Anil verma
@vermanil
Mar 09 2016 05:50

var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}

];

// Only change code below this line
var secondTree = myPlants1.list1; // Change this line

V Arun Kumar
@arunvkumr
Mar 09 2016 05:50
@gofighting123 in for, condition i < contacts.length.
走你飛艇
@gofighting123
Mar 09 2016 05:50
.length !?
....
hahah
i see= =
Anil verma
@vermanil
Mar 09 2016 05:51
what is wrong
走你飛艇
@gofighting123
Mar 09 2016 05:51
nope, wait....contacts.length ?
Andrew Charlebois
@andrewchar
Mar 09 2016 05:51
@vermanil you're close. remember bracket notation
V Arun Kumar
@arunvkumr
Mar 09 2016 05:51
@gofighting123 remove the if condition which you are using for no such contact, and move the return statement out of loop
@gofighting123 ya contacts. length, the indexing starts from 0 and ends at length-1. :smiley:
走你飛艇
@gofighting123
Mar 09 2016 05:53
yes? i have no check all the array members
i have to
it's so hard to follow up in pair programming mode , hahaha
Meghana
@meghanasarikonda
Mar 09 2016 05:55
hello any one pls help me with counting cards challange
Ankit Panwar
@coderNoob
Mar 09 2016 05:55
Show us your code and the problem you're facing. @meghanasarikonda
V Arun Kumar
@arunvkumr
Mar 09 2016 05:55
@gofighting123 the index of array and object starts from 0 and ends at length-1. so if 5 members are there it will check from 0 to 4, so that whhy we use i<=length-1 or i < length.
走你飛艇
@gofighting123
Mar 09 2016 05:56
@@ i see that...i fix it
yap i got another right check , and left one XD
V Arun Kumar
@arunvkumr
Mar 09 2016 05:58
@gofighting123 inside your loop, when the if fails it directly goes to second if and it returns true without checking other entries in array, so you hav to move the return no such contact out of loop then all the entries will be check after that if nothing found it will return no such contact.
走你飛艇
@gofighting123
Mar 09 2016 05:59
@meghanasarikonda
check at https://gist.github.com/gofighting123/fbc488d7e3e51d9c3964
i just logdown mine to see if can help any others:>
oh my gd
V Arun Kumar
@arunvkumr
Mar 09 2016 06:03
@gofighting123 wait i think i missed something
走你飛艇
@gofighting123
Mar 09 2016 06:04
@@
that's internet !! XD
Ogarunite
@Ogarunite
Mar 09 2016 06:05
hi
走你飛艇
@gofighting123
Mar 09 2016 06:05
in chat mode, it's really hard to follow up...
V Arun Kumar
@arunvkumr
Mar 09 2016 06:06
@gofighting123 your code is working fine i just checked. i have made just 1 small change in your code.
Ogarunite
@Ogarunite
Mar 09 2016 06:06
When i have a constructor function, and insie the constructor there is a this.accelerate = function(change)
how do i pass value to this parameter for the method inside the constructor?
i am following the "Make Object Properties Private" challenge
Marin Mestrovic
@mmarinm
Mar 09 2016 06:06
can someone help me with twitter feed dynamic text button. I can't figure it out. I don't see a lot of people having issue with that I wonder why?
走你飛艇
@gofighting123
Mar 09 2016 06:07
yes ?
V Arun Kumar
@arunvkumr
Mar 09 2016 06:07
remove the second if completely and when you are declaring msg, declare it with "no such contact" like var msg="no such contact"
Ogarunite
@Ogarunite
Mar 09 2016 06:07
anyone?
走你飛艇
@gofighting123
Mar 09 2016 06:07
...
by defaults....
Ogarunite
@Ogarunite
Mar 09 2016 06:08
how?
走你飛艇
@gofighting123
Mar 09 2016 06:08
that's not bad trick@@
V Arun Kumar
@arunvkumr
Mar 09 2016 06:08
@gofighting123 no not the default on before for loop, you are declaring var msg="" instead declare it as var msg="no such contact"
走你飛艇
@gofighting123
Mar 09 2016 06:09
haha , chat mode makes me crazy XD
V Arun Kumar
@arunvkumr
Mar 09 2016 06:09
and remove second if statement, the entire no such contact if.
function lookUp(firstName, prop){
var msg="no such contact";
var found=false;
for(var i=0;i<contacts.length;i++) {
if (contacts[i].firstName == firstName) {
  switch (prop) {
    case "lastName":
    case "number":
    case "likes":
      msg=contacts[i][prop];
      found=true;
      break;
    default:
      msg="No such property";
  }
}
if (found) break;
}
return msg;
}
that one ^^^
@gofighting123
走你飛艇
@gofighting123
Mar 09 2016 06:10
....
V Arun Kumar
@arunvkumr
Mar 09 2016 06:13
@gofighting123 what this will do is if it finds the name of contact and he has the property then it will change the msg to "no such property" and if the property exists msg would be hold the property of contact and if both fails just return the string in msg which you initialized i.e. "no such contact"
Meghana
@meghanasarikonda
Mar 09 2016 06:13
<var ans=0;

function cc(card) {
  // Only change code below this line
  var count=0 ;
  if(card==2||card==3||card==4||card==5||card==6){
    count=count+1;
  }
  else if(card==7||card==8||card||9){
    count= count;
  } else if(card==10 || card=='J' || card=='Q' || card=='K' || card=='A'){
    count= count-1;
  }

  ans=ans+count;
  return ans;
  // Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
 cc('K');>
V Arun Kumar
@arunvkumr
Mar 09 2016 06:13
@gofighting123 he doesn't have the property then no such property**
Meghana
@meghanasarikonda
Mar 09 2016 06:13
@coderNoob
im not getting -1,when i use above code
V Arun Kumar
@arunvkumr
Mar 09 2016 06:14
@meghanasarikonda you have return ans with Bet and Hold.
@meghanasarikonda use concat operator(+) to add string.
走你飛艇
@gofighting123
Mar 09 2016 06:15
@arunkumrv i am trying @@
JCCoding
@JCCoding
Mar 09 2016 06:15
I have a question about "Access MultiDimensional Arrays With Indexes
"
Meghana
@meghanasarikonda
Mar 09 2016 06:15
@arunkumrv yeah i know ,but im checking individual parts
JCCoding
@JCCoding
Mar 09 2016 06:15
Why does arr[0]; // equals [1,2,3]
Why does arr1; // equals 6
Why does arr[3]0; // equals 11
I
I got the right answer for the challenge but I don't know why the solution was right
Meghana
@meghanasarikonda
Mar 09 2016 06:16
im getting error at the above part
@arunkumrv
JCCoding
@JCCoding
Mar 09 2016 06:16

Why does arr[0]; // equals [1,2,3]?
Why does arr[1][2]; // equals 6
Why does arr[3][0][1]; // equals 11

My answer was var myData = myArray[2][1]; But I don't know why that was right

For "Access MultiDimensional Arrays With Indexes
"
V Arun Kumar
@arunvkumr
Mar 09 2016 06:19
@meghanasarikonda for 'K' it will return -1, when you pass 'K' to function CC, the card value is K and when it is checked with if-else the second else-if condition becomes true and initially count was 0, so now the operation count = count -1 makes it -1 and you are storing it to ans and ans just return -1.
JCCoding
@JCCoding
Mar 09 2016 06:21
I'm logging off. Sleepy...
bye
Feel free to message me
Meghana
@meghanasarikonda
Mar 09 2016 06:22
@arunkumrv no im getting 0 as my answer
please one run at your end
once*
Durga Prasad Duggirala
@prasduggirala
Mar 09 2016 06:24
@japyles return "No such contact" statement should be between the last two closing braces of the loop..by placing the return "No such contacts" statement after the 2nd closing brace the contacts[i].firstName condition checks f0r i=0 only and returns back,leaving the first loop incomplete
V Arun Kumar
@arunvkumr
Mar 09 2016 06:26
@meghanasarikonda that's odd. let me check once
Ankit Panwar
@coderNoob
Mar 09 2016 06:26

I have an array like this [ [ 2, 'Hair Pin' ], [ 3, 'Half-Eaten Apple' ], [ 67, 'Bowling Ball' ], [ 7, 'Toothpaste' ] ] and I need to eliminate any duplicate entries. I used the following loop

for(var k=0; k<newArray.length; k++){
        for(var l=0; l<newArray.length; l++){
            if(newArray[k][1]===newArray[l][1]){
                console.log("This is equal = "+newArray[k][1]);
                newArray.splice(l, 1);
            }
        }
    }

But apparently according to this loop Hair Pin and Bowling Bowl are equal. Why?

走你飛艇
@gofighting123
Mar 09 2016 06:26
....
V Arun Kumar
@arunvkumr
Mar 09 2016 06:29
@meghanasarikonda in you second else-if condition see the condition card == 9. thats the problem
:smiley:
Meghana
@meghanasarikonda
Mar 09 2016 06:29
@arunkumrv yeah
This message was deleted
thats right
V Arun Kumar
@arunvkumr
Mar 09 2016 06:30
@gofighting123 did it work?
走你飛艇
@gofighting123
Mar 09 2016 06:30
i am still stucking @@
hahaha
V Arun Kumar
@arunvkumr
Mar 09 2016 06:30
repost your new code @gofighting123
走你飛艇
@gofighting123
Mar 09 2016 06:31
not changed much @@ as yours
i just change the msg variable to "No such contact" ...
and try to figure the test result...the last two not passed @@
V Arun Kumar
@arunvkumr
Mar 09 2016 06:34
@gofighting123 i just checked, it passes all the test cases. no sure what are you doing wrong?
repost your code once.
走你飛艇
@gofighting123
Mar 09 2016 06:34
the problem now is there are no found= false situation

function lookUp(firstName, prop){
// Only change code below this line
var msg="No such contact";
var found=false;

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

if (contacts[i].firstName == firstName) {
  switch (prop) {
    case "lastName":
    case "number":
    case "likes":
      msg=contacts[i][prop];
      found=true;
      break;
    default:
      msg="No such property";
  }
}  
if (found) break;

}
return msg;

// Only change code above this line
}

0.0
V Arun Kumar
@arunvkumr
Mar 09 2016 06:35
@gofighting123 for condition still not right. :smile: i < contacts.length
Meghana
@meghanasarikonda
Mar 09 2016 06:35
@arunkumrv
<var ans=0;
var final="";

function cc(card) {
  // Only change code below this line
  var count=0 ;
  if(card==2||card==3||card==4||card==5||card==6){
    count=count+1;
  }
else if(card==7||card==8||card==9){
    count= count;
  } 
  else if(card==10 || card=='J' || card=='Q' || card=='K' || card=='A'){
    count= count-1;
  }

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

// Add/remove calls to test your function.
// Note: Only the last will display
 cc(7);cc(8);cc(9);>
走你飛艇
@gofighting123
Mar 09 2016 06:35
haha i am walking dead :XD
Meghana
@meghanasarikonda
Mar 09 2016 06:35
still im not getting
@arunkumrv
走你飛艇
@gofighting123
Mar 09 2016 06:36
xd
OK I GOT PASSED QAQ
V Arun Kumar
@arunvkumr
Mar 09 2016 06:36
@meghanasarikonda for which test case it's not passing?
走你飛艇
@gofighting123
Mar 09 2016 06:37
thanks @arunkumrv , move on the next challenge @@
CamperBot
@camperbot
Mar 09 2016 06:37
gofighting123 sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 323 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
V Arun Kumar
@arunvkumr
Mar 09 2016 06:37
@gofighting123 :+1: :smiley: .happy coding
走你飛艇
@gofighting123
Mar 09 2016 06:37
it's not happy :XD
Meghana
@meghanasarikonda
Mar 09 201