These are chat archives for FreeCodeCamp/HelpJavaScript

1st
Apr 2016
Stephane
@overmelo
Apr 01 2016 00:03
@rphares worldBlanks="my "+myNoun+ "is "+myAdjective+ "and it "+myVerb + myAdverb; ??
rphares
@rphares
Apr 01 2016 00:04
close, but a few things,
you need spaces on both sides of those params... think about the output as is:
My dogis bigand it ranquickly
second,
you seem to have stored it in worldBlanks.... take a look at what you will return...
(its below the 'do not change' line)
you probably wanna store that line in the same var you will return, so maybe change worldBlanks to that ;)
Stephane
@overmelo
Apr 01 2016 00:05
ok nice,i will find out
rphares
@rphares
Apr 01 2016 00:05
cool cool, good luck!
bitgrower
@bitgrower
Apr 01 2016 00:07
:wave: @rphares
Stephane
@overmelo
Apr 01 2016 00:08
it's really giving me muscles this challenge @rphares
rphares
@rphares
Apr 01 2016 00:08
hi, @bitgrower ~
Thats good! Its hard, but how we learn : )
Stephane
@overmelo
Apr 01 2016 00:11
i did it wow
thank you @rphares
CamperBot
@camperbot
Apr 01 2016 00:11
overmelo sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
bitgrower
@bitgrower
Apr 01 2016 00:11
woohoo! congrats @overmelo !!!
CamperBot
@camperbot
Apr 01 2016 00:11
:star: 3670 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Apr 01 2016 00:11
Awesome-- congratulations, @overmelo !
Stephane
@overmelo
Apr 01 2016 00:12
@bitgrower cheers
bitgrower
@bitgrower
Apr 01 2016 00:12
keep at it, and you'll be surprised how quickly this becomes old hat ...
Stephane
@overmelo
Apr 01 2016 00:13
yea javascript is quite bizarre compared to others languages
but it will be fine
Craig Morrison
@frogmorton
Apr 01 2016 00:14
hint profile lookup
CamperBot
@camperbot
Apr 01 2016 00:14
Set a bonfire to talk about with bonfire name
SwatiK21
@SwatiK21
Apr 01 2016 00:15
help closures
CamperBot
@camperbot
Apr 01 2016 00:15

:point_right: js closures [wiki]

Closures are functions that refer to independent (free) variables. In other words, the function defined in the closure 'remembers' the environment in which it was created.

function makeFunc() {
  var name = "Mozilla";
  function displayName() {
    alert(name);
  }
  return displayName;
}

var myFunc = makeFunc();
myFunc();

See MDN

tags: closure, javascript, js
:pencil: read more about js closures on the FCC Wiki

Craig Morrison
@frogmorton
Apr 01 2016 00:16
help Profile Lookup
CamperBot
@camperbot
Apr 01 2016 00:16

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

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

swimrr
@swimrr
Apr 01 2016 00:18
okay, that's enough frustration for one day. Perhaps tomorrow I can bang my head against a wall some more;
bitgrower
@bitgrower
Apr 01 2016 00:20
well, be sure to reward yourself for what you've accomplished and learned, @swimrr ... :)
swimrr
@swimrr
Apr 01 2016 00:20
bye all
@bitgrower thanks, but nothing today other than I'm stubborn
CamperBot
@camperbot
Apr 01 2016 00:20
swimrr sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star: 953 | @bitgrower | http://www.freecodecamp.com/bitgrower
Craig Morrison
@frogmorton
Apr 01 2016 00:26
hey guys, when i give valid arguments, the function runs, but if I put in intentionally incorrect ("nonexistent") data, I get the classic "Type error: contacts[i] is undefined". Here is the code:
Luke Barry
@LukeBarry
Apr 01 2016 00:27
I am stuck on "Confirming the Ending." I can't get my code to identify the last word or last letters in the word to return true.
var answer = "";
answer += str.substr(-1);
if (answer === target)
return true;
else {
return false;
}
}
Craig Morrison
@frogmorton
Apr 01 2016 00:27
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop) {
// Only change code below this line
var len = contacts.length;
console.log(len);

//if(contacts[i].firstName=== firstName){ifcontacts[firstName][prop]=="prop" return contacts[i]; else......}

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

        if (contacts[i].firstName !== firstName) {
              console.log("No such contact");
            //return "No such contact";
        }
        else if ((contacts[i].firstName === firstName) && (contacts[i][prop] !== undefined)) {
            if (contacts[i].hasOwnProperty(prop)){
                return contacts[i][prop];
            }

        } else if (contacts[i][prop] === undefined) {
            console.log("No such property");
            //return "No such property";

        }
    }
}

// Only change code above this line


// Change these values to test your function
lookUp("Bob", "contact");
Luke Barry
@LukeBarry
Apr 01 2016 00:27
confirmEnding("He has to give me a new name", "name") should return true.
confirmEnding("He has to give me a new name", "me") should return true.
Duncan T
@dtweedle
Apr 01 2016 00:29
@frogmorton You can't lookup value of an undefined property. You need to check if the property is defined before you can do an equality check
Craig Morrison
@frogmorton
Apr 01 2016 00:30
@Isymm OK that makes sense
@LukeBarry where is the beginning of the function?
Luke Barry
@LukeBarry
Apr 01 2016 00:31
function confirmEnding(str, target) {
var answer = "";
answer += str.substr(-1);
if (answer === target)
return true;
else {
return false;
}
}
confirmEnding("He has to give me a new name", "name");
Craig Morrison
@frogmorton
Apr 01 2016 00:31
thanks.
Luke Barry
@LukeBarry
Apr 01 2016 00:31
Sorry. I didn't paste that part in
Craig Morrison
@frogmorton
Apr 01 2016 00:33
@LukeBarry you aren't looping to increment answer
it only does the last char, 'e'
i mean the substring operation.
as written, it only checks the if once
Does that make sense?
Duncan T
@dtweedle
Apr 01 2016 00:37
@frogmorton Had a look at your code, you're actually heading down the right track, you have a problem with you for loop though, check your equality operator. <=
@frogmorton Something in your comparison is causing you to access and index that isn't there. let me know if you can spot it.
Craig Morrison
@frogmorton
Apr 01 2016 00:39
@Isymm thanks for taking a look. I'll try to find the bug, with your hints
CamperBot
@camperbot
Apr 01 2016 00:39
frogmorton sends brownie points to @isymm :sparkles: :thumbsup: :sparkles:
:star: 280 | @isymm | http://www.freecodecamp.com/isymm
Craig Morrison
@frogmorton
Apr 01 2016 00:40
@Isymm = sign?
Luke Barry
@LukeBarry
Apr 01 2016 00:40
@frogmorton so add a for loop in there so that it checks the last letter, and then the last two letters, last three letters, etc?
Duncan T
@dtweedle
Apr 01 2016 00:40
yup. thats the one. get rid of the equals sign
@frogmorton Yup, see what happens when you remove it.
Craig Morrison
@frogmorton
Apr 01 2016 00:41
@LukeBarry maybe try a while loop...as in while answer !== target, but you could get a for loop to work also
Nyarlat-hotep
@Nyarlat-hotep
Apr 01 2016 00:41
help mutations
CamperBot
@camperbot
Apr 01 2016 00:41

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
Craig Morrison
@frogmorton
Apr 01 2016 00:41
@Isymm no error this time
but a few tests didnt pass
let me try elsewhere so I can see what is happening in the console
Duncan T
@dtweedle
Apr 01 2016 00:43
@frogmorton yup, so the equals sign meant your while loop was executing 5 iterations instead of 4. The loop continues to execute because it is waiting until your variable i is GREATER than 4. You only need a little bit of tidying up to finish the test.
Craig Morrison
@frogmorton
Apr 01 2016 00:47
Thanks again for your keen eye @Isymm
CamperBot
@camperbot
Apr 01 2016 00:47
frogmorton sends brownie points to @isymm :sparkles: :thumbsup: :sparkles:
:warning: frogmorton already gave isymm points
Chris Dalton
@manwithgills
Apr 01 2016 00:49
This message was deleted
Duncan T
@dtweedle
Apr 01 2016 00:50
@frogmorton just as a tip for finishing the rest of your challenge, your first if statement is going to cause you some problems, you will need to rethink your if statement layouts. Good luck.
Craig Morrison
@frogmorton
Apr 01 2016 00:50
gotcha
Leslie Covington
@LesCov610
Apr 01 2016 00:52
I'm SO excited!!! I FINALLY got "Title Case A Sentence" to work!!!! Woo hooo!!!
rphares
@rphares
Apr 01 2016 00:52
Congratulations, @LesCov610 !
Duncan T
@dtweedle
Apr 01 2016 00:52
@LesCov610 Grats
Kevin Anderson
@LemonStain
Apr 01 2016 00:53
what am i missing here - when the value is called it should give the value...

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

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

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

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

Blake Harris
@bharris62
Apr 01 2016 00:54

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

//Try it out here
var myCar = function(wheels, seats, engines){
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

var myCar = new myCar(3,1,2);
```
I am having trouble figuring out what is wrong with this for challenge 'make unique objeects by passing parameter to our constructor' it returns the correct values..

CamperBot
@camperbot
Apr 01 2016 00:54
:bulb: to format code use backticks! ``` more info
Leslie Covington
@LesCov610
Apr 01 2016 00:54
@rphares @Isymm Thanks!!!
CamperBot
@camperbot
Apr 01 2016 00:54
lescov610 sends brownie points to @rphares and @isymm :sparkles: :thumbsup: :sparkles:
Blake Harris
@bharris62
Apr 01 2016 00:54
ah crap

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

//Try it out here
var myCar = function(wheels, seats, engines){
this.wheels = wheels;
this.seats = seats;
this.engines = engines;
};

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

CamperBot
@camperbot
Apr 01 2016 00:55
:star: 3672 | @rphares | http://www.freecodecamp.com/rphares
:star: 281 | @isymm | http://www.freecodecamp.com/isymm
Blake Harris
@bharris62
Apr 01 2016 00:55
var Car = function() {
  //Change this constructor
  this.wheels = 4;
  this.seats = 1;
  this.engines = 1;
};

//Try it out here
var myCar = function(wheels, seats, engines){
  this.wheels = wheels;
  this.seats = seats;
  this.engines = engines;
};

var myCar = new myCar(3,1,2);
Duncan T
@dtweedle
Apr 01 2016 00:56
So looking forward to the day we can exchange brownie points for frequent flyer miles... can someone add this as an enhancement to the github repo.. XD
Henry Parson
@Hparson
Apr 01 2016 00:56

Hi. I'm trying to do the Local Scope and Functions challenge on FCC, but nothing I do seems to be working. I've googled this challenge and it seems other people have had problems with it too.

Here's my code:

function myFunction() {
myVar='use strict';

console.log(myVar);
}
myFunction();

// run and check the console
// myVar is not defined outside of myFunction

// now remove the console log line to pass the test

also, apologies if there is a better way to format that.
Duncan T
@dtweedle
Apr 01 2016 00:58
@Hparson What happens when you remove console.log(myVar);?
rphares
@rphares
Apr 01 2016 00:58
@Hparson , you will just two things--
Carlos Hernandez
@juancarloshg
Apr 01 2016 00:58
hey guys, i have a comparison error all the time and i dont know what to try next :( anyone can help? code in https://jsfiddle.net/f6yf93jf/
rphares
@rphares
Apr 01 2016 00:59
when you use myVar in that function, you probably want to use the var key word, as you haven't declared it anywhere else (and int this case, you aren't supposed to declare it anywhere else) @Hparson
Kevin Anderson
@LemonStain
Apr 01 2016 00:59

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

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

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

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

rphares
@rphares
Apr 01 2016 00:59
second, when you do that.... you will probably need t refresh your page after running tests, then run tests again (a common error is maximum call stack after you fail the challenge once... refreshing will take care of that) @Hparson
@LemonStain , so we have a few things to do, step by step : )
First, good start on that table!
But, the directions say something like "create a table called lookup to..."
So, instead of result =
your table should probably say something like var lookup = {
Henry Parson
@Hparson
Apr 01 2016 01:01
wait... i'm confused. I should declare it as a var? I thought that would make it a global variable, which i'm not supposed to do.
rphares
@rphares
Apr 01 2016 01:01
@Hparson -- if you do that outside the function, it is global
if you do it inside the function, its local. Thats why you had to delete the extra console.log--
that was outside the function,
so he couldn't get to what you are declaring inside the function
Henry Parson
@Hparson
Apr 01 2016 01:02
I see. I misunderstood. Thanks for the help. that did it.
rphares
@rphares
Apr 01 2016 01:02
Anytime! Happy coding~
@LemonStain , you get that first part? : )
Kevin Anderson
@LemonStain
Apr 01 2016 01:02
@rphares yes - i reset it to var lookup
rphares
@rphares
Apr 01 2016 01:02
@bharris62 , sorry , whats the name of that one again, oi can try and toggle between you and lemon : )
@LemonStain , cool, so next-- that last line of the table, including the last comma after frank, , "": undefined
you dont need it
i know the editor will scream at you
but when the whole code is correct, it'll be quiet
so you can just remove that addition for now : )
Kevin Anderson
@LemonStain
Apr 01 2016 01:04
sweet - good to know
rphares
@rphares
Apr 01 2016 01:04
then, we have just two, slightly more complicated steps left
lets check out the example in the instructions:
their table is named var alpha and they want to get what is associated with 2 ("Y" is associated with 2)... so they type alpha[2], right?
Kevin Anderson
@LemonStain
Apr 01 2016 01:05
correct
rphares
@rphares
Apr 01 2016 01:05
Your table is now named var lookup and you want what is associated with val
so, how could you write that part?
César
@ICesarI
Apr 01 2016 01:05
@bharris62, don't override the function. Just make a new instance of Car function (myCar) and change the properties.
rphares
@rphares
Apr 01 2016 01:06
(thanks, @ICesarI ... i dont remember the instructions on that one at all, heh)
CamperBot
@camperbot
Apr 01 2016 01:06
rphares sends brownie points to @icesari :sparkles: :thumbsup: :sparkles:
:star: 348 | @icesari | http://www.freecodecamp.com/icesari
Kevin Anderson
@LemonStain
Apr 01 2016 01:06
lookup[val];?
rphares
@rphares
Apr 01 2016 01:07
Yay! Almost there!!
But, you have probably noticed that doesn't solve it yet--
Kevin Anderson
@LemonStain
Apr 01 2016 01:07
right
rphares
@rphares
Apr 01 2016 01:07
the thing is, if you just plunk that in under the table.... its not doing you any good, right? It just sits there... What is are you going to return, at that end of the function?
Kevin Anderson
@LemonStain
Apr 01 2016 01:09
we want to return the the 2nd value in the lookup in the result. so do we need to define result?
rphares
@rphares
Apr 01 2016 01:11
pretty much : ) Put that nice lookup you built in result after the table and you should be good to go : )
Kevin Anderson
@LemonStain
Apr 01 2016 01:12
I am getting an error for the line lookup[val];

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

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

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

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

rphares
@rphares
Apr 01 2016 01:13
ooops, not quite--
you want the whole thing in result,
you want to combine these two lines: lookup[val];
result = lookup;
bitgrower
@bitgrower
Apr 01 2016 01:14
what error did you get @LemonStain ?
Kevin Anderson
@LemonStain
Apr 01 2016 01:14
expected an assignment or function call and instead saw an expression @bitgrower
GO TIT!
GOT IT
rphares
@rphares
Apr 01 2016 01:15
<-- still doesn't understand most errors : ) Finally learned a few that make her look for forgetting to close things, but... : )
Kevin Anderson
@LemonStain
Apr 01 2016 01:15
result = lookup[val];
bitgrower
@bitgrower
Apr 01 2016 01:15
taaa daaa !!!! congrats @LemonStain
Kevin Anderson
@LemonStain
Apr 01 2016 01:15
thanks @rphares @bitgrower
CamperBot
@camperbot
Apr 01 2016 01:15
lemonstain sends brownie points to @rphares and @bitgrower :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Apr 01 2016 01:15
yay! Congratulations~ Now, i pass you to the wonderful @bitgrower for any in depth questions on the whys, as I'm still terrible at that stuff : )
CamperBot
@camperbot
Apr 01 2016 01:16
:star: 3673 | @rphares | http://www.freecodecamp.com/rphares
:star: 954 | @bitgrower | http://www.freecodecamp.com/bitgrower
rphares
@rphares
Apr 01 2016 01:16
Anytime~
bitgrower
@bitgrower
Apr 01 2016 01:16
hahahahahahah ...
Kevin Anderson
@LemonStain
Apr 01 2016 01:17
awesome
Rex Smith Jr.
@rsmith731
Apr 01 2016 01:18
may i get some input please…how can i make JavaScript stick? I know repetition is the key, but after I an exercise i’m still lost…is there an easier way that may have helped some of you all?
Coy Sanders
@coymeetsworld
Apr 01 2016 01:20
repetition is important, but also being aware of the code you're writing and how it all works @rsmith731.
i know there's people out there that just copy and paste code they find on stack overflow, if that's all you end up doing then you don't learn much, not saying thats what you're doing but just giving an example
bitgrower
@bitgrower
Apr 01 2016 01:23
@rsmith731 -- I have gone and used other resources ... there's lots of freely available resources, in the form of free (very good) books, videos (often excellent), sites where you can practice coding skills (eg codewars, I think, hackerrank) ... there are js "playgrounds" like repl.it and codepen and pythontutor.com/javascript.html where you can take your code and play with it ... see how it works ...
feel free to review challenges you've already done ... and even if you pass them, you can ask questions ... the CodeReview room is really good for posting completed (passed) challenges and getting additional suggestions/information ...
Kevin Anderson
@LemonStain
Apr 01 2016 01:26
how do I call the property's value of an Object?
Rex Smith Jr.
@rsmith731
Apr 01 2016 01:27
@coymeetsworld well my ideal would be to actually learn it, to be able to code from scratch, but i recently found out that most companies now just use templates like handlebars.js
@bitgrower thanks i really appreciate that and i will definitely look into those!…I just get frustrated when i read a book or watch a tutorial and 5 mins later i’m asking myself what did i just watch or read
CamperBot
@camperbot
Apr 01 2016 01:28
rsmith731 sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
Coy Sanders
@coymeetsworld
Apr 01 2016 01:28
the projects here youll have to build from scratch and there's quite a few so you'll get experience that way
CamperBot
@camperbot
Apr 01 2016 01:28
:star: 955 | @bitgrower | http://www.freecodecamp.com/bitgrower
RyanEnright
@RyanEnright
Apr 01 2016 01:32
Any hints on the correct syntax to push this <i class="wi wi-day-sunny icons"></i>? Here is exactly what Im trying to do, its commented out at the bottom of the JS.
http://codepen.io/RyanlEnright/pen/bprWBY
César
@ICesarI
Apr 01 2016 01:35
@LemonStain, object[property]?
Esteban Morales
@Bandito11
Apr 01 2016 01:39
``
in order to put code under that black box I have to use `` right?

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

function lookUp(firstName, prop){
// Only change code below this line
if(prop == 'firstName' || prop == 'lastName' || prop == 'number' || prop == 'likes'){
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName == 'Kristian' && prop == 'lastName'){
return contactsi;
}else if(contacts[i].firstName == 'Sherlock' && prop == 'likes'){
return contactsi;
}else if(contacts[i].firstName == 'Harry' && prop == 'likes' ){
return contactsi;
}else if(contacts[i].firstName !== 'Bob' && prop == 'number'){
return 'No such contact';
}else if(contacts[i].firstName == 'Akira' && prop == 'address'){
return 'No such property';
}
}
}
// Only change code above this line
}

lookUp("Sherlock", "likes");
``

Where I have to get [

where I have to get the Sherlock array
César
@ICesarI
Apr 01 2016 01:41
help format
CamperBot
@camperbot
Apr 01 2016 01:41

: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

Theresa
@decgal
Apr 01 2016 01:42
can anyone help me figure out how to tweet my random quote? http://codepen.io/decgal/pen/dMzzbq?editors=1010
Esteban Morales
@Bandito11
Apr 01 2016 01:43
//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUp(firstName, prop){
// Only change code below this line
    if(prop == 'firstName' || prop == 'lastName' || prop == 'number' || prop == 'likes'){
     for(var i = 0; i < contacts.length; i++){
       if(contacts[i].firstName ==  'Kristian' && prop == 'lastName'){
         return contacts[i][prop];
       }else if(contacts[i].firstName == 'Sherlock' && prop == 'likes'){
         return contacts[i][prop];
       }else if(contacts[i].firstName == 'Harry' && prop == 'likes' ){
         return contacts[i][prop];
       }else if(contacts[i].firstName !== 'Bob' && prop == 'number'){
         return 'No such contact';
       }else if(contacts[i].firstName == 'Akira' && prop == 'address'){
         return 'No such property';
       }
     }
    }
// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");

I am supposed to get the array of likes where the first name is equal. But I get the array where the firstName is Harry.

I don' even know what happens. Can somebody help

help format
CamperBot
@camperbot
Apr 01 2016 01:43

: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

Tiani Ball
@Tiani91
Apr 01 2016 01:45
I seem to need help with challenge "Iterate Through an Array with a For Loop" I know I am missing something, because it comes back with "total should equal 20" still being red and the rest of it comes back just fine. can someone help me figure out where i'm going wrong, please?
```js
.-. and it isn't letting me post it. :|
Esteban Morales
@Bandito11
Apr 01 2016 01:47
your supposed to write code goes here like this.
like two sets ``` of these
PHPman
@dmitrikonnikov
Apr 01 2016 01:53
can someone help me with "Understand String Immutability" in basic js
Esteban Morales
@Bandito11
Apr 01 2016 01:53
ok I just made it work. Took the Harry property checked and it worked. Pretty sure it is a buf
Tiani Ball
@Tiani91
Apr 01 2016 01:55
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

for (var i = 0; i < ourArr.length; i++) {
  ourTotal += ourArr[i];
}

// Setup
var myArr = [ 2, 3, 4, 5, 6];


// Only change code below this line
var total=0;
for(var i=0; i < myArr.legnth; i++) {
  total += myArr[i];
}
rphares
@rphares
Apr 01 2016 01:55
@dmitrikonnikov , sure-- could you paste what you tried, please?
PHPman
@dmitrikonnikov
Apr 01 2016 01:55
o i figured it out
rphares
@rphares
Apr 01 2016 01:56
cool, congrats and happy coding : )
Hsin Chih Wang
@hsinwang5
Apr 01 2016 02:00
@Tiani91 u have a typo legnth
Tiani Ball
@Tiani91
Apr 01 2016 02:02
..........well don't i feel just ridiculous. LOL thank you @hsinwang5
CamperBot
@camperbot
Apr 01 2016 02:02
tiani91 sends brownie points to @hsinwang5 :sparkles: :thumbsup: :sparkles:
:star: 129 | @hsinwang5 | http://www.freecodecamp.com/hsinwang5
it seems like there's a more concise way that uses regexp
Jay Kleine
@JKleine
Apr 01 2016 02:33
Has anyone done "Truncate a string" recently
I'm having difficulty getting the last 2 requirements
It seems like they contradict the rest, but I'm not sure
Natalie Walker
@nattiewalker
Apr 01 2016 02:34
hi I am on the Title Case a Sentence in the Beginning JS Algorithm section. Can someone look at my code an tell me what I am doing wrong/over-thinking? In the exercise you are called to turn the first letter of all of the words in string to UpperCase.
LHuChemE
@LHuChemE
Apr 01 2016 02:35
@JKleine add a new else if condition where the length of the string is shorter than 3
Natalie Walker
@nattiewalker
Apr 01 2016 02:35

function titleCase(str) {
str = str.split(" ");
for(i = 0; i < str.length; i++) {
var j = str.charAt(0).toUpperCase();
str[i] = j + str[i].charAt(0).toUpperCase() + str.slice(1);
}
return str.join(" ");
}

titleCase("I'm a little tea pot");

Ramana Venkata
@vramana
Apr 01 2016 02:37
@NattieWalker I think j is redundant
Natalie Walker
@nattiewalker
Apr 01 2016 02:37
@vramana that's what I was thinking
when i reworded it another way i did not get it. I will keep trying.
Robert Richey
@0x0936
Apr 01 2016 02:38
@decgal were you able to get the tweet button working?
Ramana Venkata
@vramana
Apr 01 2016 02:40
@NattieWalker After you delete j, what is your code??
Robert Richey
@0x0936
Apr 01 2016 02:40
@NattieWalker your str.slice(1) needs an index value on str. otherwise, str is the entire array of words
Jay Kleine
@JKleine
Apr 01 2016 02:43
@LHuChemE truncateString("Absolutely Longer", 2) should return "Ab...". What about that req?
Ramana Venkata
@vramana
Apr 01 2016 02:44
@JKleine If you mean 'req', the return value is also 'req' I think
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 02:44
Hello everyone. I am new here and cannot figure out the "Standing in Line" exercise.
Jay Kleine
@JKleine
Apr 01 2016 02:44
I meant requirement
LHuChemE
@LHuChemE
Apr 01 2016 02:44
@JKleine that's the case where you want an else if where num < 3
Jay Kleine
@JKleine
Apr 01 2016 02:45

function truncateString(str, num) {
if (str.length <= 3) {
var lilStr = str.slice(0, -1).concat("...");
return lilStr;
}
if (str.length > num) {
str = str.slice (0, num-3).concat('...');
}
return str;
}

truncateString("Absolutely Longer", 2);

LHuChemE
@LHuChemE
Apr 01 2016 02:45
num - 3 where num < 3 doesn't work
so you need to add a new else if for when num < 3
Jay Kleine
@JKleine
Apr 01 2016 02:46
str.length?
if (str.length <= 3) at the top?
LHuChemE
@LHuChemE
Apr 01 2016 02:46
nah actual num where you want to slice it
Jay Kleine
@JKleine
Apr 01 2016 02:46
I thought thats what lines 2-4 did
LHuChemE
@LHuChemE
Apr 01 2016 02:48
str = str.slice(0, num - 3).concat('...');
doesn't work when num = 2
so think about a new else if condition to take care of that
Robert Richey
@0x0936
Apr 01 2016 02:48
@KungFuDrafter Stand in Line is creating a queue. A new item gets pushed onto an array and the first item gets shifted off. Here is an example - not a copy/paste solution
// example
var arr = [1, 2, 3];

// let's push the number 4
arr.push(4);

// arr now looks like this: [1, 2, 3, 4]

// now let's get the first item
var firstItem = arr.shift();

// arr now looks like this: [2, 3, 4]
Jay Kleine
@JKleine
Apr 01 2016 02:49
Thanks
how do you paste your code window in here like that
LHuChemE
@LHuChemE
Apr 01 2016 02:51
the ```
rphares
@rphares
Apr 01 2016 02:51
explain format
CamperBot
@camperbot
Apr 01 2016 02:51

:point_right: code formatting [wiki]

Multi line Code

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

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

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

Single line Code

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

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

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

Robert Richey
@0x0936
Apr 01 2016 02:51
img
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 02:52
@0x0936 Thanks. I will give it another try!
CamperBot
@camperbot
Apr 01 2016 02:52
kungfudrafter sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star: 1256 | @0x0936 | http://www.freecodecamp.com/0x0936
Robert Richey
@0x0936
Apr 01 2016 02:52
:+1: :)
Jay Kleine
@JKleine
Apr 01 2016 02:54
function truncateString(str, num) {
  if (str.length <= num) {
    return str;
  } else if (num === 2) {
    return "Ab...";
  //if 
  } else if (str.length <= 3) {
    return str.slice(0, num) + '...'; 
  } else {
    return str.slice(0, num - 3) + '...';
  }
}
Robert Richey
@0x0936
Apr 01 2016 02:56
@JKleine try editing your post - you have up to 5 minutes before it's permanent. wrap code in triple backticks. triple backticks need their own line
Eric Murta
@murtinha
Apr 01 2016 02:57
function unite(arr1, arr2, arr3) {

 Array.prototype.slice.call(arguments).reduce(function(a,b){
   for(j=0;j<b.length;j++){   
   if(a.indexOf(b[j])==-1){
     a.push(b[j]);
   }
     }

 });


  return arr1;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Guys, my indexOf() is wrong, its saying cannot read property "indexof" of undefined... Thats Sorte Uniion Challenge
can anybody help?
LHuChemE
@LHuChemE
Apr 01 2016 02:57
@JKleine isn't that cheating to just set the return to ab...
Jay Kleine
@JKleine
Apr 01 2016 02:58
lol yeah Im still working on it
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 03:01
Wait, is that a thing? How do I send points?
Or was that just a euphamism?
LHuChemE
@LHuChemE
Apr 01 2016 03:02
@murtinha it took me a while to figure that one out, but use lots of console.log() and typeof calls to figure it out
Natalie Walker
@nattiewalker
Apr 01 2016 03:02

@vramana ``` str = str.toLowerCase().split(' ');

for(var i = 0; i < str.length; i++){
str[i] = str[i].split('');
str[i][0] = str[i][0].toUpperCase();
str[i] = str[i].join('');
}
return str.join(' '); ```

I got it to work.
Ramana Venkata
@vramana
Apr 01 2016 03:03
Congrats!!
devonwilson1
@devonwilson1
Apr 01 2016 03:03
can someone tell me how this is wrong

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line
testObj ["an entree"]; // hamburger
testObj ["the drink"]; // water

rphares
@rphares
Apr 01 2016 03:03
@KungFuDrafter , you say thank you or thanks, and it will give a point to the person you mention with @username in the same message. (for example, this will send you and @username a brownie point)
CamperBot
@camperbot
Apr 01 2016 03:03
rphares sends brownie points to @kungfudrafter and @username :sparkles: :thumbsup: :sparkles:
:warning: could not find receiver for kungfudrafter
:warning: could not find receiver for username
devonwilson1
@devonwilson1
Apr 01 2016 03:04
for accessing objects properties with bracket notation
Brandon Dean
@thedeany
Apr 01 2016 03:05
@devonwilson1 What output are you seeing?
rphares
@rphares
Apr 01 2016 03:05
@devonwilson1 , i believe you has some vars there, that you have deleted?
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 03:05
Oh ok. Thanks @0x0936 for the help
CamperBot
@camperbot
Apr 01 2016 03:05
kungfudrafter sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:warning: kungfudrafter already gave 0x0936 points
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 03:06
Woohoo. I learned one thing tonight. Have a great evening.
devonwilson1
@devonwilson1
Apr 01 2016 03:06
water @thedeany
rphares
@rphares
Apr 01 2016 03:06
You were meant to set them to what you have now.... : )
Kung Fu Drafer
@KungFuDrafter
Apr 01 2016 03:07
Oh and thanks @camperbot for explaining brownie points
CamperBot
@camperbot
Apr 01 2016 03:07
kungfudrafter sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:star: 1469 | @camperbot | http://www.freecodecamp.com/camperbot
Alex
@ACVis
Apr 01 2016 03:08
So, what is the usefulness of charCodeAt() and fromCharCode() vs other functions? For context, I'm starting Caesars Cipher and I'm confused why those are listed as helpful links when it seems like I could probably do this bonfire without them.
CamperBot
@camperbot
Apr 01 2016 03:08
type bonfire name to get some info on that bonfire. And check HelpBonfires chatroom
LHuChemE
@LHuChemE
Apr 01 2016 03:09
@ACVis charCodeAt returns unicode, and "a" and "b" are right next to each other
so it makes cipher which is shifting by 13 letters easier
Theresa
@decgal
Apr 01 2016 03:09
@0x0936 nope. i have no idea what to do with the twitter button
Brandon Dean
@thedeany
Apr 01 2016 03:09
@devonwilson1 I believe there are variables declared at the bottom by default. You're supposed to set those variables equal to the values of the properties you're reading, as @rphares alluded to.
Eric Murta
@murtinha
Apr 01 2016 03:10
@ACVis its easier to do it by getting the char code number, just thing about it
devonwilson1
@devonwilson1
Apr 01 2016 03:11
thank you @thedeany
CamperBot
@camperbot
Apr 01 2016 03:11
devonwilson1 sends brownie points to @thedeany :sparkles: :thumbsup: :sparkles:
devonwilson1
@devonwilson1
Apr 01 2016 03:11
thank you @rphares
CamperBot
@camperbot
Apr 01 2016 03:11
devonwilson1 sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
:star: 300 | @thedeany | http://www.freecodecamp.com/thedeany
:star: 3678 | @rphares | http://www.freecodecamp.com/rphares
Alex
@ACVis
Apr 01 2016 03:11
So, it looks like "A" is unicode 65, I could just add 13 to it to get its cipher and then use fromCharCode to convert it back to something alphanumeric?
Brandon Dean
@thedeany
Apr 01 2016 03:11
@ACVis The great thing about coding is there are any number of ways you could complete the task! I had the same though when I started that one as well, though. Ended up being more useful than I thought when it came to doing the math of shifting the letters.
rphares
@rphares
Apr 01 2016 03:12
Sure thing-- happy coding!
Brandon Dean
@thedeany
Apr 01 2016 03:12
Sure thing, @devonwilson1!
Eric Murta
@murtinha
Apr 01 2016 03:12
function unite(arr1, arr2, arr3) {

 Array.prototype.slice.call(arguments).reduce(function(a,b){
   for(j=0;j<b.length;j++){   
   if(a.indexOf(b[j])==-1){
     a.push(b[j]);
   }
     }

 });


  return arr1;
}

unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);
Guys, my indexOf() is wrong, its saying cannot read property "indexof" of undefined... Thats Sorte Uniion Challenge
can anybody help?
Brandon Dean
@thedeany
Apr 01 2016 03:15
@ACVis Yep.
RyanEnright
@RyanEnright
Apr 01 2016 03:18
How do I go about correcting this issue?
Mixed Content: The page at 'https://s.codepen.io/RyanlEnright/debug/bprWBY#' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://api.openweathermap.org/data/2.5/weather?lat=47.353446899999994&lon=-122.04689250000001&units=imperial&APPID=4e7d5dda4d85376156a6eff11da28faa'. This content should also be served over HTTPS.
Ariel
@abibliophile
Apr 01 2016 03:21
Hi everyone! I'm working on the Title Case a Sentence challenge and I just can't seem to figure this out
function titleCase(str) {
  var strTwo=str.toLowerCase();
  var stringArray=strTwo.split (" ");
  for (var i=0;i<stringArray.length;i++){

    for (var j=0;j<stringArray[i].length;j++){
      if (j===0) {
        stringArray[i].charAt(j).toUpperCase();
      }
      else {stringArray[i].charAt(j).toLowerCase();}
    }
  }
  return stringArray;
}



titleCase("I'm a little tea pot");
Alex
@ACVis
Apr 01 2016 03:21
@thedeany I agree, that is the great thing about coding.
tjhpae
@tjhpae
Apr 01 2016 03:24
can anyone here explain this?
1 != true // false
0 != false // false
why are these two statements false?
shouldn't they be true?
Duncan T
@dtweedle
Apr 01 2016 03:27
@abibliophile You can't change the value of a string directly. they are immutable. You need to create a new string.
Ghost
@ghost~56a18e6ae610378809bd9384
Apr 01 2016 03:27
Anyone know of a document viewer I can embed in HTML and lets you browse files on your desktop to display?
Duncan T
@dtweedle
Apr 01 2016 03:28
@abibliophile stringArray[i].charAt(j).toUpperCase(); is not changing the value of the first letter in your string. Trying saving this to a variable and working with that.
Ariel
@abibliophile
Apr 01 2016 03:29
here's what I've got now:
function titleCase(str) {
  var strTwo=str.toLowerCase();
  var stringArray=strTwo.split (" ");
  var firstLetters=[];
  var otherLetters=[];
  for (var i=0;i<stringArray.length;i++){
    firstLetters.push(stringArray[i].charAt(0).toUpperCase());
    for (var j=1;j<stringArray[i].length;j++)
    otherLetters.push(stringArray[i].charAt(j));
  }

  return firstLetters;
}



titleCase("I'm a little tea pot");
I think I'm closer
ManBearPigg
@ManBearPigg
Apr 01 2016 03:29
@tjhpae 0 is falsy
@tjhpae much like nil, '' , etc. 1 is true because it's an int
@tjhpae 0 is not considered true because it's an int in this context, it's falsy
Duncan T
@dtweedle
Apr 01 2016 03:30
@abibliophile Getting closer, you have the right idea to break the string apart and then recombine it.
Ariel
@abibliophile
Apr 01 2016 03:31
now for the recombining bit..
Duncan T
@dtweedle
Apr 01 2016 03:34
@abibliophile yup goodluck :|
tjhpae
@tjhpae
Apr 01 2016 03:34
@ManBearPigg not sure i get your explanation
i thought because one is an int and one is a boolean value, it'd be true?
Duncan T
@dtweedle
Apr 01 2016 03:37
@tjhpae
1 is binary for true
0 is binary for false

@tjhpae

0 = false //true
0!= false //false

ManBearPigg
@ManBearPigg
Apr 01 2016 03:39
@tjhpae undefined, empty string, null, 0, all return false
@nruck1 Adobe offers something like that. Sorry, don't remember what it's called and not sure if it's free. Hope that's a good lead for you.
Ollie
@ogough
Apr 01 2016 03:53
So I'm trying to do one of the scripting challenges and I get the following error. "type error cannot assign to readonly property". Can anyone see why??
function titleCase(str) {
  //return str;
  var array1 = str.split(" ");
  for (i=0; i < array1.length; i++) {
    array1[i].split("");
    array1[i][0] = array1[i][0].toUpperCase;
    for (j=1; j < array1[i].length; j++) {
      array1[i][j] = array1[i][j].toLowerCase;
    }
    array1[i].join("");
  }
  var upperStr = array1.join(" ");
  return upperStr;


}

titleCase("I'm a little tea pot");
devonwilson1
@devonwilson1
Apr 01 2016 04:03
someone wanna help me?

// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = [16]
var player = testObj [16]; // Montana

whats wrong with accessing this objects properties with variables?
RyanEnright
@RyanEnright
Apr 01 2016 04:05
Would appreciate some feedback on my weather app. A couple issues I'm having are an https error and it doesn't load on safari on my laptop but works great on my iphone?
http://codepen.io/RyanlEnright/pen/bprWBY
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:08
@RyanEnright Well it gives me the weather info for Seattle , I think it should be giving me the weather where I live
This message was deleted
devonwilson1
@devonwilson1
Apr 01 2016 04:08
can any one help me?
RyanEnright
@RyanEnright
Apr 01 2016 04:12
@hsinwang5 I'm using chrome and safari and it loads my location, weather, and icon for said weather. I'm not sure what the issue is.
@hsinwang5 I do know it doesnt load anything while in the editor view
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:14
@RyanEnright It was my mistake it works fine and loads my location
RyanEnright
@RyanEnright
Apr 01 2016 04:15
@hsinwang5 did you get an https error?
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:15
@RyanEnright No just had to open it in a new tab and it gave me the weather for my city
RyanEnright
@RyanEnright
Apr 01 2016 04:17
@hsinwang5 Thanks for taking a look
CamperBot
@camperbot
Apr 01 2016 04:17
ryanenright sends brownie points to @hsinwang5 :sparkles: :thumbsup: :sparkles:
:star: 137 | @hsinwang5 | http://www.freecodecamp.com/hsinwang5
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:19
@RyanEnright Oh I think you're getting the error b/c your laptop is blocking the app from accessing its location...that's the error I'm getting when I look at the console after opening your app on the current tab
Paul Borawski
@iAmNawa
Apr 01 2016 04:21
@RyanEnright looks good!
RyanEnright
@RyanEnright
Apr 01 2016 04:22
@hsinwang5 Thats what I originally thought, but I still get it after changing my location settings.
@iAmNawa Thanks
CamperBot
@camperbot
Apr 01 2016 04:23
ryanenright sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
:star: 290 | @iamnawa | http://www.freecodecamp.com/iamnawa
Paul Borawski
@iAmNawa
Apr 01 2016 04:23
@RyanEnright except it said rain and it’s not even close to raining here
RyanEnright
@RyanEnright
Apr 01 2016 04:24
@iAmNawa hmm that would be on the API right? Or could that be an issue on my end?
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:24
@RyanEnright If you open the console in codepen on chrome do you see it give you a warning? Might be related to that
RyanEnright
@RyanEnright
Apr 01 2016 04:24
@iAmNawa did it also load a raining icon?
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:24
Help Where art thou
CamperBot
@camperbot
Apr 01 2016 04:24
no wiki entry for: where art thou
RyanEnright
@RyanEnright
Apr 01 2016 04:25
@hsinwang5 yeah trying to figure out how to resolve it
Hsin Chih Wang
@hsinwang5
Apr 01 2016 04:25
@RyanEnright getCurrentPosition() and watchPosition() are deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details. (that's the warning I'm seeing)
Paul Borawski
@iAmNawa
Apr 01 2016 04:26
@RyanEnright it just says light rain no icon
i check my local weather and it says no rain though
RyanEnright
@RyanEnright
Apr 01 2016 04:27
@hsinwang5 Yeah I noticed that earlier I just hav'nt been able to figure out what do with said info.
Paul Borawski
@iAmNawa
Apr 01 2016 04:27
the city was correct though
Josh Bivens
@joshbivens
Apr 01 2016 04:29
Can I ask a quick question?
Paul Borawski
@iAmNawa
Apr 01 2016 04:29
@joshbivens yes
Josh Bivens
@joshbivens
Apr 01 2016 04:29
Ok ;)
I'm trying to convert seconds to the 24:58 format, and it's working for minutes, but seconds wont. Here's the code:
RyanEnright
@RyanEnright
Apr 01 2016 04:30
@iAmNawa ok thanks. The icon is my issue. I forgot to set an if statement for the value light rain. But I think the inaccurate weather forecast is out of my hands.
CamperBot
@camperbot
Apr 01 2016 04:30
ryanenright sends brownie points to @iamnawa :sparkles: :thumbsup: :sparkles:
:warning: ryanenright already gave iamnawa points
Josh Bivens
@joshbivens
Apr 01 2016 04:31
minutes() {
      var minutes = Math.floor(this.time / 60); 
      var seconds = this.time - 60 * minutes;

      if (minutes < 10) {
        minutes = "0" + Math.floor(this.time / 60);
      } else if (minutes === 0) {
        minutes = "00";
      } else if (seconds < 10) {
        seconds = "0" + this.time - 60 * minutes;
      } else if (seconds === 0) {
        seconds = "00"
      }

      return minutes + ":" + seconds;
    }
Ramana Venkata
@vramana
Apr 01 2016 04:31
@joshbivens minutes === 0 case should be above minutes < 10
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:32
I need help on the where art thou
Ramana Venkata
@vramana
Apr 01 2016 04:32
@djcase001 Show what you tried.
Josh Bivens
@joshbivens
Apr 01 2016 04:33
@vramana That's not it unfortunately
Ramana Venkata
@vramana
Apr 01 2016 04:33
@joshbivens Is that even necessary??
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:33
```
Ramana Venkata
@vramana
Apr 01 2016 04:33
@joshbivens What is the test case that's failing ??
Josh Bivens
@joshbivens
Apr 01 2016 04:33
Well how else would I convert 1500 seconds to minutes and seconds?
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:34
@vramana Catastrophic code 😝😝😝
Josh Bivens
@joshbivens
Apr 01 2016 04:35
When it gets to less than 10 seconds, the minutes are proper 00:... but the seconds display like this: 00:9, 00:8, etc.
TyRy1
@TyRy1
Apr 01 2016 04:35
var myObj = {};

myObj.__proto__ === Object.prototype 

// is true...
I thought it was FUNCTIONS that have prototype properties... is Object a function? If not, which function's prototype is myObj inherited from?
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:35
@vramana I used a for loop to iterate through the arrays in the first argument
@vramana
Ramana Venkata
@vramana
Apr 01 2016 04:37
@joshbivens Ahh I see. You have seperate the seconds based if case other wise they never get executed.
if (minutes < 10) {
  minutes = "0" + Math.floor(this.time / 60);
} else if (minutes === 0) {
  minutes = "00";
} 

if (seconds < 10) {
  seconds = "0" + this.time - 60 * minutes;
} else if (seconds === 0) {
  seconds = "00"
}
Josh Bivens
@joshbivens
Apr 01 2016 04:38
@vramana Ok I'll try it! Thanks @vramana !
CamperBot
@camperbot
Apr 01 2016 04:38
joshbivens sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:star: 244 | @vramana | http://www.freecodecamp.com/vramana
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:39
@vramana here is the code: for(var i=0; i<collection.length; i++)
Ramana Venkata
@vramana
Apr 01 2016 04:40
@djcase001 Do you know how to print keys of an object ??
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:40
@vramana sorry I'm using my phone
Josh Bivens
@joshbivens
Apr 01 2016 04:40
@vramana Actually I needed to add a Math.floor to seconds: seconds = "0" + Math.floor(this.time - 60 * minutes);
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:40
Wait til I get on my computer
Josh Bivens
@joshbivens
Apr 01 2016 04:41
@vramana But it works fully now. Thanks again.
CamperBot
@camperbot
Apr 01 2016 04:41
joshbivens sends brownie points to @vramana :sparkles: :thumbsup: :sparkles:
:warning: joshbivens already gave vramana points
TyRy1
@TyRy1
Apr 01 2016 04:41
If anyone's available to answer a question or two about prototype and inheritance, please shoot be a private chat
Ramana Venkata
@vramana
Apr 01 2016 04:41
@joshbivens Wierd. That shouldn't change anything. Since everything is an integer.
TyRy1
@TyRy1
Apr 01 2016 04:41
Thx :)
Lucky charm
@luckycharm223
Apr 01 2016 04:47
I can't seem to get pass this challenge https://www.freecodecamp.com/challenges/stand-in-line
kirbyedy
@kirbyedy
Apr 01 2016 04:49
@luckycharm223 you have to use the push() and shift() method
Sidharth Kriplani
@sidkrip
Apr 01 2016 04:49
wiki pairwise
CamperBot
@camperbot
Apr 01 2016 04:49

:point_right: algorithm pairwise [wiki]

Explanation:

The program should look for the numbers in the array which would add to make the number from the arg. Then instead of adding those numbers up, you will add their indices which is the reason why you get 11 on the example from detail.

Remember that arrays start at index 0 and go from there so from [1,4,2,3,0,5] if we switch to their indices it would be [0,1,2,3,4,5] then we add indices 1 + 2 + 3 + 5 and we get 11. That is what we need to return.

:pencil: read more about algorithm pairwise on the FCC Wiki

Sidharth Kriplani
@sidkrip
Apr 01 2016 04:50
wiki no repeats please
CamperBot
@camperbot
Apr 01 2016 04:50

:point_right: algorithm no repeats please [wiki]

Problem Explanation:

  • This task requires us to look at each possible permutation of a string. This is best done using a recursion function. Being able to build a function which collects all permutations of a string is a common interview question, so there is no shortage of tutorials out there on how to do this, in many different code languages.
  • This task can still be daunting even after watching a tutorial. You will want to send each new use of the function 3 inputs: 1. a new string (or character array) that is being built, 2. a position in your new string that's going to be filled next, and 3. an idea of what characters (more specifically positions) from the original string have yet to be used. The pseudo code will look something like this:

    ```
    var str = ???;
    perm(current position in original string, what's been used in original string, current string build thus far){
    if(current string is finished) {
    print current string;
    }else{
    for(var i = 0; i < str.length; i++) {

    if(str[i] has not been used) {
      put str[i] into the current position;
      mark str[i] as used
      perm(current position in original string, what's been used in original string, current string build thus far)
      unmark str[i] as used because another branch in the tree for i + 1 will still likely use it;
    }

    }
    }
    }
    :pencil: read more about algorithm no repeats please on the FCC Wiki

Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:51
This message was deleted
@vramana
 for(var index=0; index<collection.length; index++){
    var key_sou = Object.keys(source);
    var key_col = Object.keys(collection[index]);

        console.log(collection[index][key_col]+' index: '+index);
        console.log(source[key_sou]+' index: '+index);

        if(collection[index][key_col] === source[key_sou] && key_sou === key_col){
            arr.push(collection[index]);
        }

  }
  return arr;
Sidharth Kriplani
@sidkrip
Apr 01 2016 04:54
wiki make a person
CamperBot
@camperbot
Apr 01 2016 04:54

:point_right: algorithm make a person [wiki]

Explanation:

When I started the program I figured I just had to create the six functions mentioned in the details. However, it was not that simple. Creating them as a function was not the right way, I had to create them in a different way to make them a key.

There is also a tricky part as you need six keys no more or less, so at first I had the variable that store the original name as a key too which was wrong.

As for the usage of array, that is optional, you could also create new variable to hold the separated string if you wish but an array is easier to deal with as strings are immutable.

Read the instructions carefully, it is always a good hint in itself to run the code and check what the test results were so you know what to expect but do not fixate yourself on that. Once you understand what you need to do, this problem is very easy and straightforward.

:pencil: read more about algorithm make a person on the FCC Wiki

Sidharth Kriplani
@sidkrip
Apr 01 2016 04:54
wiki inventory update
CamperBot
@camperbot
Apr 01 2016 04:54

:point_right: algorithm inventory update [wiki]

Problem Explanation:

  • Look through an array of new products, in the format: [quantity, name]
  • Return an array containing updated quantities for each item that already existed, and any new products
:pencil: read more about algorithm inventory update on the FCC Wiki
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:54
It worked for the first two function calls
Sidharth Kriplani
@sidkrip
Apr 01 2016 04:55
wiki symmetric difference
CamperBot
@camperbot
Apr 01 2016 04:55

:point_right: algorithm symmetric difference [wiki]

Problem Explanation:

Symmetric Difference is the difference between two sets.

So in the Symmetric Difference Algorithm you would work through the arrays of numbers something like this -

sym(A, B, C) Translates to sym(sym(A,B),C)

Or in plain English - First find the Symmetric Difference of Set A and Set B. Then find the Symmetric Difference of this new set and Set C.

So -

sym([1, 2, 5], [2, 3, 5], [3, 4, 5])

would equal

[1,4,5]

Here's a nice video tutorial (with an awful fake British accent!) -

YouTube - Symmetric Difference
:pencil: read more about algorithm symmetric difference on the FCC Wiki

Sidharth Kriplani
@sidkrip
Apr 01 2016 04:55
wiki exact change
CamperBot
@camperbot
Apr 01 2016 04:55

:point_right: algorithm exact change [wiki]

Problem Explanation:

  • You have to create a program that will handle when the register does not have
    enough cash or will have no cash after the transaction. Other than that it
    needs to return an array of the change in the form of an array, so that will
    be a 2D array.
:pencil: read more about algorithm exact change on the FCC Wiki
Arnaud Casamé
@arnaudcasame
Apr 01 2016 04:57

@vramana can you help me?

for(var index=0; index<collection.length; index++){
    var key_sou = Object.keys(source);
    var key_col = Object.keys(collection[index]);

        console.log(collection[index][key_col]+' index: '+index);
        console.log(source[key_sou]+' index: '+index);

        if(collection[index][key_col] === source[key_sou] && key_sou === key_col){
            arr.push(collection[index]);
        }

  }
  return arr;

It works for the first two function calls

Ramana Venkata
@vramana
Apr 01 2016 04:59
@djcase001 key_col is an array. so collection[index][key_col] is meaningless key_col should be a string for that expression to make sense.
@djcase001 The hint is you need another for loop.
Arnaud Casamé
@arnaudcasame
Apr 01 2016 05:02
@vramana Haha, I had another for loop. I erased it cause I wasn't sure
Imma put it back

@vramana here is what it was like:

for(var index=0; index<collection.length; index++){
    var key_sou = Object.keys(source);
    var key_col = Object.keys(collection[index]);

    for(var i=0; i<key_sou.length; i++){
        console.log(collection[index][key_col]+' index: '+index);
        console.log(source[key_sou]+' index: '+index);

        if(collection[index][key_col[i]] === source[key_sou[i]] && key_sou[i] === key_col[i]){
            arr.push(collection[index]);
        }
    }
  }

What's wrong with it???

Ramana Venkata
@vramana
Apr 01 2016 05:07
@djcase001 You have to push into the array only if all the keys and values of source are inside collection[index] But you are pushing if one key matches.
Arnaud Casamé
@arnaudcasame
Apr 01 2016 05:09
@vramana Ok Imma check it out.
Ramana Venkata
@vramana
Apr 01 2016 05:11
@djcase001 You can use functions like Array.every and Array.some to simplify your solution.
Arnaud Casamé
@arnaudcasame
Apr 01 2016 05:12
Ok @vramana
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:20
@vramana help needed with symmetric difference.
this has been hardcoded for now, for just getting the symmetric difference between two arrays. I dont know why its not working:
function sym(args) {

  var arr=[];

  for(var i=0; i<arguments[0].length; i++) {
    for(var j=0; j<arguments[1].length; j++) {
      if(arguments[0][i]!==arguments[1][j]) {
        arr.push(arguments[0][i]);
      }
    }
  }

  for(var k=0; k<arguments[0].length; k++) {
    for(var l=0; l<arguments[1].length; l++) {
      if(arguments[1][l]!==arguments[0][k]) {
        arr.push(arguments[1][l]);
      }
    }
  }
  return arr;
}
Ramana Venkata
@vramana
Apr 01 2016 05:22
@sidkrip If you have harded code it for two arrays. Why not be nice and call them arr1 and arr2 as parameters. Makes code some much more readable.
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:23
well, yes it does
LHuChemE
@LHuChemE
Apr 01 2016 05:24
function sumFibs(num) {

  var prev = 1;
  var ans = 1;
  var prev2 = 0;
  var sumOdd = 1;

  for (var i = 1; i < num; i++) {  
    ans = prev + prev2;
    prev2 = prev;
    prev = ans;
    if (ans % 2 == 1) {
      sumOdd = sumOdd + ans;
    }
  }

  return sumOdd;
}
I'm having problem with this sum all odd Fibonacci numbers challenge, this doesn't work, but I've checked with my own test values up to 10 and it's fine
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:25

@vramana also, one more problem. this statement:

var args = Array.prototype.slice.call(arguments);

creates an array out of the available arguments.
I returned the args as the output to see what exactly I would get but its returning just the first array.

Markus Kiili
@Masd925
Apr 01 2016 05:25
@sidkrip You are pushing an element if there is an element in the other array that is not the same. You should be pushing if the element differs from all the element in the other array.
Ramana Venkata
@vramana
Apr 01 2016 05:25
@sidkrip I don't how this happening but it is the same mistakes I have seen 3 or 4 times from different people. You have to check that arr[i] not present is arr2 and then push what you are doing is checking equality against each element and just inserting into the array
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:26
how do I make the checking code different?
Markus Kiili
@Masd925
Apr 01 2016 05:26
@sidkrip You should try .filter() method.
Ramana Venkata
@vramana
Apr 01 2016 05:26
You can use Array.prototype.every.
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:27
I mean, is there any way other than using the equality operator?
Markus Kiili
@Masd925
Apr 01 2016 05:27
@sidkrip indexOf method.
Ramana Venkata
@vramana
Apr 01 2016 05:27
@sidkrip You have to use equality check but you should and them
@Masd925 Interesting. :+1:
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:28

@Masd925 I was gonna do that. I am having this problems though
also, one more problem. this statement:

var args = Array.prototype.slice.call(arguments);

creates an array out of the available arguments.
I returned the args as the output to see what exactly I would get but its returning just the first array.

Markus Kiili
@Masd925
Apr 01 2016 05:29
@sidkrip It should have the argument arrays as elements.
Ramana Venkata
@vramana
Apr 01 2016 05:29
@sidkrip remove args as the parameter may be.
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:30
the input is sym([1, 2, 3], [5, 2, 1, 4])
Markus Kiili
@Masd925
Apr 01 2016 05:30
@sidkrip You can use args, because the function parameter is meaningless, but it can be confusing usage.
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:31
@Masd925 @vramana gotcha. thanks
CamperBot
@camperbot
Apr 01 2016 05:31
sidkrip sends brownie points to @masd925 and @vramana :sparkles: :thumbsup: :sparkles:
:star: 1265 | @masd925 | http://www.freecodecamp.com/masd925
:star: 245 | @vramana | http://www.freecodecamp.com/vramana
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:32
now I was thinking of this approach. I get the array, I concat it into one and remove the duplicate elements. For more than two arrays, I use recursion
it should work shouldnt it?
Markus Kiili
@Masd925
Apr 01 2016 05:32
@sidkrip You have to remove duplicates from individual arrays first on that approach.
@sidkrip Then after concat totally remove those element that are not single.
LHuChemE
@LHuChemE
Apr 01 2016 05:33
wow I figured the problem, the description for the algorithm problem is wrong
Markus Kiili
@Masd925
Apr 01 2016 05:33
@sidkrip It is easier to use .reduce() than recursion on this, I think. Both work of cource.
Sidharth Kriplani
@sidkrip
Apr 01 2016 05:34
@Masd925 didnt get the first line.
will that make it a one line code? and I wouldnt have to concat the arrays as well?
using reduce() i.e
Ramana Venkata
@vramana
Apr 01 2016 05:34
@Masd925 Isn't reduce indirectly a recursive function ??
Markus Kiili
@Masd925
Apr 01 2016 05:35
@vramana You tell .reduce() how to symDiff two arrays and it symmDiffs variable number of arrays. It is not recursion.
Ramana Venkata
@vramana
Apr 01 2016 05:38
@Masd925 This is how I look at reduce
function reduce(array, fn, acc) {

    if (array.length === 0) {
        return acc
    } 

    return reduce(array.slice(1), fn, fn(acc, array[0]))
}
Markus Kiili
@Masd925
Apr 01 2016 05:39
@vramana You can make any recursion with loop and vice versa, so it is meaningless to ponder which one is used under the hood.
@vramana The reduce algorithm is explained on Ecmascript standard. Reduce loops the array elements and runs the callback function once for each element. It doesn't call itself.
Ramana Venkata
@vramana
Apr 01 2016 05:44
@Masd925 Okay. That's why I said "I look at reduce" like this.
Markus Kiili
@Masd925
Apr 01 2016 05:46
@vramana The functional programming way of looking at it.
Ramana Venkata
@vramana
Apr 01 2016 05:47
Yup
Markus Kiili
@Masd925
Apr 01 2016 05:49
@sidkrip You can use filter and indexOf first to remove the duplicates from arrays.
hobohiggs
@hobohiggs
Apr 01 2016 05:52
Hi guys - how is everyone? My first help question - I'm on FCC exercise 193 "Comparison with the Less Than Operator". I have the answer correct but I'm wondering why the console doesn't return the answer of BOTH "Under 25" and "Under 55" ?

function myTest(val) {
if (val < 25) { // Change this line
return "Under 25";
}

if (val < 55) { // Change this line
return "Under 55";
}

return "55 or Over";
}

// Change this value to test
myTest(10);

rphares
@rphares
Apr 01 2016 05:55
This message was deleted
This message was deleted
hobohiggs
@hobohiggs
Apr 01 2016 05:56
@rphares perfect explanation thank you!
CamperBot
@camperbot
Apr 01 2016 05:56
hobohiggs sends brownie points to @rphares :sparkles: :thumbsup: :sparkles:
rphares
@rphares
Apr 01 2016 05:56
This message was deleted
CamperBot
@camperbot
Apr 01 2016 05:56
:star: 3689 | @rphares | http://www.freecodecamp.com/rphares
rphares
@rphares
Apr 01 2016 05:56
sure thing~
Lateef Oseni
@knglateef
Apr 01 2016 06:01
@hobohiggs console.log(myTest(10));
parvinder30
@parvinder30
Apr 01 2016 06:06
Hey, Guyz
Lateef Oseni
@knglateef
Apr 01 2016 06:07
Hey guyz, it feels good to here.
I'm unable to complete this exercise . Can you please tell me where's the problem
kirbyedy
@kirbyedy
Apr 01 2016 06:10
@parvinder30 copy paste your code here
parvinder30
@parvinder30
Apr 01 2016 06:10

// Initialize these three variables
var a=6;

var b= 15;

var c="I am a String";
// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";

César
@ICesarI
Apr 01 2016 06:10
help format
CamperBot
@camperbot
Apr 01 2016 06:10

: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

kirbyedy
@kirbyedy
Apr 01 2016 06:11
why did you write a=6 ?
what does the instruction say ?
parvinder30
@parvinder30
Apr 01 2016 06:12
Instructions said to initialize a with 6 b with 15 and c with that string
rphares
@rphares
Apr 01 2016 06:12
This message was deleted
kirbyedy
@kirbyedy
Apr 01 2016 06:12
no
rphares
@rphares
Apr 01 2016 06:13
This message was deleted
parvinder30
@parvinder30
Apr 01 2016 06:15
Fine , lemme see my code once again
rphares
@rphares
Apr 01 2016 06:15
This message was deleted
parvinder30
@parvinder30
Apr 01 2016 06:17
Cleared the exercise
Thanks for helping ...
rphares
@rphares
Apr 01 2016 06:19
anytime, congrats and happy coding
parvinder30
@parvinder30
Apr 01 2016 06:19
@rphares Do I need to take a reference book as well, along with these exercises or these exercise alone are enough
rphares
@rphares
Apr 01 2016 06:21
@parvinder30 , i would definitely recommend outside study
parvinder30
@parvinder30
Apr 01 2016 06:21
Source ...??
rphares
@rphares
Apr 01 2016 06:21
For me, i found three online books helpful so far
a) at the beginning, close to where you are now, javascript for cats was very simple and helped a little.
b) eloquent javascript was very dry (boring) and uneven, but-- very helpful by the time you get to algorithims
parvinder30
@parvinder30
Apr 01 2016 06:22
Yeah javascript for cats is a good book
rphares
@rphares
Apr 01 2016 06:22
c) once in algorithm, the you dont know javascript called YDKJS, series is excellent
but a little harder
Markus Kiili
@Masd925
Apr 01 2016 06:23
@parvinder30 I like "Speaking Javascript" a lot. It is free to read online.
parvinder30
@parvinder30
Apr 01 2016 06:23
Fine then i'll start with JS for Cats followed by eloquent javascript
rphares
@rphares
Apr 01 2016 06:24
Good luck! And-- if you dont like one, give it a few tries and then move on--
you dont want to hop, hop, hop though sources,
but not everyone learns the same way, so if it isn't for you... try to find something better, there are a lot of options : )
parvinder30
@parvinder30
Apr 01 2016 06:24
@Masd925 Is Speaking JavaScript a beginer level book ...??
thisjustgotreel
@thisjustgotreel
Apr 01 2016 06:25
I’m struggling grasping this stand in line challenge
Markus Kiili
@Masd925
Apr 01 2016 06:25
@parvinder30 Not really good for beginner, but goes to depths so maybe as a second book.
parvinder30
@parvinder30
Apr 01 2016 06:26
@rphares What is this multiline and single line code formatting
Markus Kiili
@Masd925
Apr 01 2016 06:26
@rphares Good morning.
parvinder30
@parvinder30
Apr 01 2016 06:26
I'm not getting it, How this thing works
rphares
@rphares
Apr 01 2016 06:27
@parvinder30 :
explain format
CamperBot
@camperbot
Apr 01 2016 06:27

: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

rphares
@rphares
Apr 01 2016 06:27
Good morning, @Masd925 -- i shall hand the room back to your expertise : )
Markus Kiili
@Masd925
Apr 01 2016 06:28
@rphares Ok, I tell my boss.
rphares
@rphares
Apr 01 2016 06:29
hahaha, i wish i could tell them about how great a help you are to the community as well : )
parvinder30
@parvinder30
Apr 01 2016 06:31
I've seen here in many chat rooms you guyz use to share the code from the exercises . HOw can I share my exercises in the same way .
Markus Kiili
@Masd925
Apr 01 2016 06:31
help format
CamperBot
@camperbot
Apr 01 2016 06:31

: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

parvinder30
@parvinder30
Apr 01 2016 06:34
Capture.PNG
I want to share my code Like this
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:35
there are no react or d3 lessons to learn from. how will one build those projects?
rphares
@rphares
Apr 01 2016 06:35
right-- the post he and i sent :point_up: March 31, 2016 11:31 PM explains how to do that...
Mithlesh Upadhyay
@csegate2
Apr 01 2016 06:35
Explain format
CamperBot
@camperbot
Apr 01 2016 06:35
no wiki entry for: format
Mithlesh Upadhyay
@csegate2
Apr 01 2016 06:36
Dub maro :smile:
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:38
@rphares how did you link that though?
rphares
@rphares
Apr 01 2016 06:38
alt click on the time stamp : ) @sidkrip
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:40
not happening
anyway, how to build the react projects?
any other source to learn it from?
kirbyedy
@kirbyedy
Apr 01 2016 06:40
I found couple of tutorials on pluralsight
youtube also has couple
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:42
@kirbyedy I will check em out. Do you know about egghead.io?
kirbyedy
@kirbyedy
Apr 01 2016 06:42
no
parvinder30
@parvinder30
Apr 01 2016 06:43
// Declarations
var StUdLyCapVaR;
var properCamelCase;
var TitleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:43
@kirbyedy there is the link ^
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:46
anone done arguments optional lately? trying to figure out how to deal with add(2)(3) - specically how to access second num since it doesntt seem to count as an arugment
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:46
@Brigette-Eckert just finished it yesterday
you will need recursion
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:47
@sidkrip do you? I thought its closure you need?
and I think I understand that its passing in the 2nd num that is confusing
Markus Kiili
@Masd925
Apr 01 2016 06:48
@Brigette-Eckert When only one argument is passed, like add(2), you need to return a function. When you invoke that function add(2)(3) it should return a number 5.
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:49
well, if the first arg is a number, you will need to pass the function to ask for a second number
*a funciton
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:49
@Masd925 and @sidkrip okay -ty I think thats what was trippng me up
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:49
and sorry, I was quoting steamroller again. Its driving me mad :D
for recursion I mean
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:49
lol np.
the two are pretty similar
Markus Kiili
@Masd925
Apr 01 2016 06:50
@Brigette-Eckert For creating the returned function, you can use manual labor, recursion or add.bind().
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:51
@Masd925 knows everything. He had helped me out with arguments optional.
@Brigette-Eckert
:D
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:52
Awesome :) @Masd925 I think I'm going to try closure manually just b//c I want/need the pratice
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:54
@Masd925 do you know about React? I mean have you done those projects as well?
cant figure out how to install react
Markus Kiili
@Masd925
Apr 01 2016 06:55
@sidkrip Don't know React at all.
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 06:56
@sidkrip using npm?
I havent done it yet but my partner has and it looks like the github for react has the install command
Sidharth Kriplani
@sidkrip
Apr 01 2016 06:58
yep. watching a video on youtube to figure out things :D
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 07:00
cool :)
Brigette Eckert
@Brigette-Eckert
Apr 01 2016 07:13
if you get stuck @lawlietblack likes helping peeps out and knows react just miight take him a bit to answer
@sidkrip
Emil Aasa
@emilaasa
Apr 01 2016 07:22
@sidkrip use some module system that uses the CommonJS pattern, like webpack or browserify
Ramana Venkata
@vramana
Apr 01 2016 07:24
@sidkrip I work with React
Sidharth Kriplani
@sidkrip
Apr 01 2016 07:35
@Brigette-Eckert thank you :)
@emilaasa yeah I head about it in the video. thank you :)
@vramana we have got a lot of talking to do then :D
CamperBot
@camperbot
Apr 01 2016 07:35
sidkrip sends brownie points to @brigette-eckert and @emilaasa and @vramana :sparkles: :thumbsup: :sparkles:
:star: 328 | @emilaasa | http://www.freecodecamp.com/emilaasa
:star: 190 | @brigette-eckert | http://www.freecodecamp.com/brigette-eckert
:star: 246 | @vramana | http://www.freecodecamp.com/vramana
Ramana Venkata
@vramana
Apr 01 2016 07:35
@sidkrip Sure
thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:36
How do I send my editor in here? I’m in need of help
Sidharth Kriplani
@sidkrip
Apr 01 2016 07:37
send you editor? I didnt get that
RyanEnright
@RyanEnright
Apr 01 2016 07:37
before your code and after @thisjustgotreel
Sidharth Kriplani
@sidkrip
Apr 01 2016 07:37
*your
thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:37
what do I put before and after ?
Markus Kiili
@Masd925
Apr 01 2016 07:37
help format
CamperBot
@camperbot
Apr 01 2016 07:37

: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

thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:38
function queue(arr, item) {
  // Your code here

  testArr.push(item);// // add item to the end of the array
  testArr.shift([0]);// then remove array0
  return testArr[0];// then queue should return deleted element
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue([], 1));
console.log(queue([2], 1));
console.log(queue([5,6,7,8,9], 1));// Modify this line to test
console.log("After: " + JSON.stringify(testArr));
its for stand in line
César
@ICesarI
Apr 01 2016 07:43
@thisjustgotreel, what is your question?
Markus Kiili
@Masd925
Apr 01 2016 07:44
@thisjustgotreel .shift() method doesn't take any arguments, and it returns the shifted element you need to store or return.
thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:45
Should I use .pop instead?
Markus Kiili
@Masd925
Apr 01 2016 07:46
@thisjustgotreel No, just return what .shift() returns.
Elizabeth Fine
@elizabethfinedev
Apr 01 2016 07:46
hoping someone can help me stop this from being an infinite loop
César
@ICesarI
Apr 01 2016 07:46
@thisjustgotreel, read your comments. How can you get the element that you already remove?
Elizabeth Fine
@elizabethfinedev
Apr 01 2016 07:48
var numberIndex =[]; 
var normalNumbers = [1, 5, 10, 50, 100, 500, 1000];
var romanNumbers = ["I", "V", "X", "L", "C", "D", "M"];
var numCopy = num;
  //while numCopy is greater than zero, look for the biggest number in the array less than or equal to that number and report its index.

  while (numCopy < 1000)  {
     for (var i = 0; i < normalNumbers.length; i++)  {
       if ((normalNumbers[i] <= numCopy) && (normalNumbers[i + 1] > numCopy))  {
             numberIndex = normalNumbers.indexOf(i);
       }

     }
  } 
  return numberIndex;
}
convert(10);
that while loop is infinite but i dont kno whow to stop it
Emil Aasa
@emilaasa
Apr 01 2016 07:49
@BananaHavana you are not doing anything to modify numCopy
Elizabeth Fine
@elizabethfinedev
Apr 01 2016 07:49
okay
thnaks @emilaasa
Emil Aasa
@emilaasa
Apr 01 2016 07:49
So if it’s less than 1000 you will never exit your while loop
Elizabeth Fine
@elizabethfinedev
Apr 01 2016 07:50
hmm. so i guess maybe a while loop is the wrong type of loop to use there
Markus Kiili
@Masd925
Apr 01 2016 07:51
@BananaHavana I believe, you should use the basis of roman numerals: 1,4,5,9,10,...
Elizabeth Fine
@elizabethfinedev
Apr 01 2016 07:51
okay thanks @Masd925
CamperBot
@camperbot
Apr 01 2016 07:51
bananahavana sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1267 | @masd925 | http://www.freecodecamp.com/masd925
Sandeep Prasad Bhatt
@sandy100
Apr 01 2016 07:55
can anyone tell me , what's wrong with that ?
function queue(arr, item) {
  // Your code here

  arr.push(10);
  item = arr.shift();
  console.log(item);
  return item;  // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
error : queue([], 1) should return 1
thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:57
well I was way off..
César
@ICesarI
Apr 01 2016 07:57
@sandy100, you are always pushing 10.
Sandeep Prasad Bhatt
@sandy100
Apr 01 2016 07:58
oh !!
i get it
thisjustgotreel
@thisjustgotreel
Apr 01 2016 07:58
I never would’ve figured that out
dammit
Sandeep Prasad Bhatt
@sandy100
Apr 01 2016 07:58
thanks @ICesarI
CamperBot
@camperbot
Apr 01 2016 07:58
sandy100 sends brownie points to @icesari :sparkles: :thumbsup: :sparkles:
:star: 350 | @icesari | http://www.freecodecamp.com/icesari
Thommoperth
@Thommoperth
Apr 01 2016 08:20
hi y all, call me dumb but what the heck does this mean? and how do I solve it? I have no idea

Instructions

Assign the value 7 to variable a.

Assign the contents of a to variable b.

Vivek
@vivek28111992
Apr 01 2016 08:21
@Thommoperth var a = 7;
var b = a;
Thommoperth
@Thommoperth
Apr 01 2016 08:22
ha ok thank you @vivek28111992
CamperBot
@camperbot
Apr 01 2016 08:22
thommoperth sends brownie points to @vivek28111992 :sparkles: :thumbsup: :sparkles:
:star: 440 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992
Adole Samuel
@int-elligentSam
Apr 01 2016 08:30
Hello world
CamperBot
@camperbot
Apr 01 2016 08:30

welcome to FreeCodeCamp @samconnor!

Adole Samuel
@int-elligentSam
Apr 01 2016 08:32
Hello everyone
V Arun Kumar
@arunvkumr
Apr 01 2016 08:36
@samconnor welcome to FCC!
Clare Dickerson
@claredickerson
Apr 01 2016 08:40

Combine the two if statements into one statement which will return "Yes" if val is less than or equal to 50 and greater than or equal to 25. Otherwise, will return "No".

function myTest(val) {
if (val <= 50 && >= 25) {
      return "Yes";
    }
  return "No";
}

Is this a sign that I need to close up and go to sleep, or? I don't get how this isn't working.

Adole Samuel
@int-elligentSam
Apr 01 2016 08:40
@arunkumrv thanks and happy first April's day
CamperBot
@camperbot
Apr 01 2016 08:40
samconnor sends brownie points to @arunkumrv :sparkles: :thumbsup: :sparkles:
:star: 412 | @arunkumrv | http://www.freecodecamp.com/arunkumrv
Coy Sanders
@coymeetsworld
Apr 01 2016 08:43
@claredickerson you have it almost right
should be
if (val <= 50 && val >= 25)
you need to specify val another time
Clare Dickerson
@claredickerson
Apr 01 2016 08:44
ooooooooooooooooooooooooooooh geeze
ok thank you @coymeetsworld
CamperBot
@camperbot
Apr 01 2016 08:44
claredickerson sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 433 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 01 2016 08:44
@claredickerson :thumbsup:
Clare Dickerson
@claredickerson
Apr 01 2016 08:44
it doesn't have the second val in the example one so i was like WHAT IS GOING ON.
MarkHR
@MarkH16
Apr 01 2016 08:45
can someone help me with this?

var oldArray = [1,2,3,4,5];

// Only change code below this line.
var addThree= oldArray.map(function(val){
return val+3;
});
var newArray = oldArray;

Coy Sanders
@coymeetsworld
Apr 01 2016 08:45
yep lol
Clare Dickerson
@claredickerson
Apr 01 2016 08:45
i've been doing javascript for so long :astonished:
have a good night/morning/whatever everyone!
Coy Sanders
@coymeetsworld
Apr 01 2016 08:46
i know lol, it does wear on you :) @claredickerson
Adole Samuel
@int-elligentSam
Apr 01 2016 08:46
@claredickerson goodnight to you too
Coy Sanders
@coymeetsworld
Apr 01 2016 08:46
gd night
Svetlana Linuxenko
@linuxenko
Apr 01 2016 08:47
Does someone use react for backend projects ? I think , i do something wrong by handling client <-> server communications with redux (http rest) with project (https://github.com/b37t1td/votingapp-freecodecamp) . Now i think about it and technologie to use next back-end challenge, react + redux + restapi feels like wrong solution .. What do you think about it and , maybe you can help me with decission of frameworks to use ?
Coy Sanders
@coymeetsworld
Apr 01 2016 08:47
whats the problem @MarkHgit :?
MarkHR
@MarkH16
Apr 01 2016 08:49
@coymeetsworld This is in the "Iterate over Array with .map" challenge.I don't understand exactly how the .map method works?How do i modify my code to add 3 to every number in the oldArray and store those values in the newArray?
Saturnino Abril
@saturninoabril
Apr 01 2016 08:49
@MarkHgit Don't assign newArray to oldArray. Try this code if it works for you.
var oldArray = [1,2,3,4,5];
// Only change code below this line.
return oldArray.map(function(val) {
  return val + 3;
});
Coy Sanders
@coymeetsworld
Apr 01 2016 08:50
should just give the code out @saturninoabril :/
Saturnino Abril
@saturninoabril
Apr 01 2016 08:51
oops, sorry @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 01 2016 08:51
the real problem is that you assigned the variable to the addThree variable, which you don't do anything w/ @MarkHgit
its ok no big deal @saturninoabril :)
he had the right idea just a minor problem
MarkHR
@MarkH16
Apr 01 2016 08:53
@coymeetsworld aah fixed it,thank you very much
CamperBot
@camperbot
Apr 01 2016 08:53
markhgit sends brownie points to @coymeetsworld :sparkles: :thumbsup: :sparkles:
:star: 434 | @coymeetsworld | http://www.freecodecamp.com/coymeetsworld
Coy Sanders
@coymeetsworld
Apr 01 2016 08:54
nice job @MarkHgit :thumbsup:
Adole Samuel
@int-elligentSam
Apr 01 2016 08:56
What framework does FCC use?
Javascript to be precise.
Vivek
@vivek28111992
Apr 01 2016 08:57
@samconnor react
Markus Kiili
@Masd925
Apr 01 2016 08:57
@samconnor React, Node.
Yinka Adesesan
@yadesesan
Apr 01 2016 09:00
Hi guys
Need some help... Again!
Brendan Kinahan
@BKinahan
Apr 01 2016 09:01
@yadesesan 'sup?
Adole Samuel
@int-elligentSam
Apr 01 2016 09:01
@vivek28111992 and @Masd925 k
How can one tell the difference between these frameworks by viewing a project design with them?
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:04
Read the values of the properties "an entree" and "the drink" of testObj using bracket notation.

var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

var entreeValue = testObj; // Change this line
var drinkValue = testObj; // Change this line

Markus Kiili
@Masd925
Apr 01 2016 09:06
@samconnor I am not using either, but to my knowledge, Node is for server programming and React for programming dynamic web pages (similar to Angular).
Coy Sanders
@coymeetsworld
Apr 01 2016 09:06
whats the problem @TanyaGarg317 ?
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:06

// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

testObj["an entree"]; // Change this line
testObj["the drink"]; // Change this line

its is not working or my solution is wrong @coymeetsworld
Yinka Adesesan
@yadesesan
Apr 01 2016 09:07
@BKinahan trying the chunky monkey challenge and Im having a problem
Let me post my code
Coy Sanders
@coymeetsworld
Apr 01 2016 09:08
looks fine to me @TanyaGarg317, should return hamburger and water
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:08
its nt working @coymeetsworld
Coy Sanders
@coymeetsworld
Apr 01 2016 09:09
which challenge is this @TanyaGarg317 ?
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:09
Accessing Objects Properties with Bracket Notation
Accessing Objects Properties with Bracket Notation
@coymeetsworld
Yinka Adesesan
@yadesesan
Apr 01 2016 09:09
/help
CamperBot
@camperbot
Apr 01 2016 09:10

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

Adole Samuel
@int-elligentSam
Apr 01 2016 09:10
@Masd925 thanks, but are you really a front end developer?
CamperBot
@camperbot
Apr 01 2016 09:10
samconnor sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1268 | @masd925 | http://www.freecodecamp.com/masd925
Coy Sanders
@coymeetsworld
Apr 01 2016 09:10
ah @TanyaGarg317 you need to assign those values to variables, i.e entreeValue and drinkValue
but the logic is all good, just missing a minor detail
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:11
whts tht detail..nt able to get it @coymeetsworld
Markus Kiili
@Masd925
Apr 01 2016 09:12
@samconnor Yes. I like backend stuff more, but work with front end. A good way to learn things you don't like.
Coy Sanders
@coymeetsworld
Apr 01 2016 09:12
you need to create 2 variables @TanyaGarg317
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:12
oki
Yinka Adesesan
@yadesesan
Apr 01 2016 09:12
function chunkArrayInGroups(arr, size) {
  // Break it up.
  var arr2 = [];
  for(var i = 0; i < arr.length / size; i++){
    var newArr = [];
    for(var j = 0; j < size; j++){
      newArr = arr.slice(i, i+size);
      //console.log(j);
    }
    arr2.push(newArr);
  }
  arr = arr2;
  //console.log(arr2);
  return arr;
}

chunkArrayInGroups(["a", "b", "c", "d"], 2);
Coy Sanders
@coymeetsworld
Apr 01 2016 09:12
one called entreeValue, other drinkValue
Vivek
@vivek28111992
Apr 01 2016 09:12
@TanyaGarg317 you just have to create 2 diff variable and assign them
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:12
let me try @coymeetsworld
Yinka Adesesan
@yadesesan
Apr 01 2016 09:13
@BKinahan code is above
Adole Samuel
@int-elligentSam
Apr 01 2016 09:13
@Masd925 I really want to be
A front end developer
What are the frameworks you advice I learn
parvinder30
@parvinder30
Apr 01 2016 09:16
Go For Bootstrap @samconnor
Adole Samuel
@int-elligentSam
Apr 01 2016 09:17
@parvinder30, why bootstrap?
Codemzy
@codemzy
Apr 01 2016 09:17
@samconnor css frameworks or js frameworks?
Brendan Kinahan
@BKinahan
Apr 01 2016 09:18
@yadesesan looks like your output is [ [ 'a', 'b' ], [ 'b', 'c' ] ], so you must be adding 'b' twice instead of moving onto 'c'
Yinka Adesesan
@yadesesan
Apr 01 2016 09:19
@yadesesan looks like your output is [ [ 'a', 'b' ], [ 'b', 'c' ] ], so you must be adding 'b' twice instead of moving onto 'c' maybe im not slicing the array properly? Ive tried various things but havent found the solution
parvinder30
@parvinder30
Apr 01 2016 09:19
Bootstrap Is a framework based on CSS Html and javascript
Adole Samuel
@int-elligentSam
Apr 01 2016 09:19
@codemzy the both, css and js
Markus Kiili
@Masd925
Apr 01 2016 09:20
@samconnor JS related ones are a safe bet, because JS is not going away. You should also understand something about everything around the field you specialize into. Takes a lot of work.
Codemzy
@codemzy
Apr 01 2016 09:21
@yadesesan total guess but maybe because your loop just goes up one each time, and then creates a new chunk starting one up... either try for(var j = 0; j < size; j + size) in your loop or you could use splice instead of slice to actually remove the chunk from the array ? But then you prob need to change your loop anyway if you do that
@samconnor bootstrap is a good css framework to learn, because of the grid system its really good for responsive design. JS frameworks... React is really hot right now... and Angular is also popular
Vivek
@vivek28111992
Apr 01 2016 09:22
@yadesesan I thinking of same your loop increment one each time, you need to change that
Brendan Kinahan
@BKinahan
Apr 01 2016 09:22
@Masd925 well, JS might go away when DeepMind learns how to program better than any human and takes over the internet :P
Vivek
@vivek28111992
Apr 01 2016 09:23
@BKinahan what is DeepMind?
Adole Samuel
@int-elligentSam
Apr 01 2016 09:23
@Masd925 sure it really is lot of work to do
Dennis Borghoff
@borghoffd
Apr 01 2016 09:24
Hey guys, quick question. In the challenge "Check for Palindromes" is the test case "palindrome("1 eye for of 1 eye.") should return false." But shouldn't it return true? It says in the challenge that I should replace all punctuation, spaces and symbols. If i remove all those from "1 eye for of 1 eye" i get a palindrom, or am i missing something?
Yinka Adesesan
@yadesesan
Apr 01 2016 09:24
@codemzy @vivek28111992 Lets me modify my code with your suggestions and get back to you
Brendan Kinahan
@BKinahan
Apr 01 2016 09:24
@vivek28111992 the google neural net that recently learned how to be better than humans at playing the highly complex game Go
Adole Samuel
@int-elligentSam
Apr 01 2016 09:24
@codemzy so I should go with react and bootstrap, right?
Brendan Kinahan
@BKinahan
Apr 01 2016 09:24
@borghoffd you were answered in the main room about this already. it starts with 1 and ends with e
Dennis Borghoff
@borghoffd
Apr 01 2016 09:25
@BKinahan oh, haven't seen that, sorry
Codemzy
@codemzy
Apr 01 2016 09:25
@samconnor you could start with those... if you follow the FCC map, you will learn bootstrap and React, and then maybe after you could pick up a few others aswell. But they are good ones to have under your belt
Adole Samuel
@int-elligentSam
Apr 01 2016 09:26
Ok @codemzy
Codemzy
@codemzy
Apr 01 2016 09:26
@samconnor :thumbsup:
Olawale Akinseye
@brainyfarm
Apr 01 2016 09:26
:+1:
Vivek
@vivek28111992
Apr 01 2016 09:27
@BKinahan ya, I heard about that just didn't know the term is called DeepMind, then we must start moving to develop DeepMind
Danilo
@sennator
Apr 01 2016 09:27
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
Vivek
@vivek28111992
Apr 01 2016 09:27
computers have defeated every best players in all games
Danilo
@sennator
Apr 01 2016 09:27
can you help me with this one
what should be my return?
Vivek
@vivek28111992
Apr 01 2016 09:28
@sennator what is asked in challenge?
Danilo
@sennator
Apr 01 2016 09:28
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:28
```
js
function palindrome(str) {
  // Good luck!
  var str3=[];
  var str2=str;
  str2.replace("\\s+","");
  str2.toLowerCase();

  str3= str2.split('').reverse().join("");

    if (str2== str3) {

      return true;
    }                  



  return false;
}



palindrome("A man, a plan, a canal. Panama");
not sure why its not switching to lowercase or removing the spaces...
Brendan Kinahan
@BKinahan
Apr 01 2016 09:29
@sennator yup, return the property of myObj with the property name matching the value of the checkProp variable. Use bracket notation.
Vivek
@vivek28111992
Apr 01 2016 09:30
@sennator then you must return myObj[checkProp];
Brendan Kinahan
@BKinahan
Apr 01 2016 09:30
@V1ad1m1r .toLowerCase() doesn't change the string you call it on, since strings are immutable.
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:31
@BKinahan so it would only chance a console.log?
Brendan Kinahan
@BKinahan
Apr 01 2016 09:31
@V1ad1m1r same for .replace() but you have the right idea when you assign the value returned by str2.split('').reverse().join('') to a variable to store it.
@V1ad1m1r even a console log on the next line wouldn't show the change. If you don't do anything with the value returned by the method, it vanishes.
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:32
@BKinahan yea the reverse seems to be working pretty well. its the spaces and punctuation and case that are preventing my true parameter.
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:33

whts d mistake in ds code
// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};

// Only change code below this line

var entreeValue = "hamburger"; // Change this line
var drinkValue = "water"; // Change this line

Danilo
@sennator
Apr 01 2016 09:33
// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

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

// Test your code by modifying these values
checkObj("gift");
TanyaGarg317
@TanyaGarg317
Apr 01 2016 09:33
anybody have ans of this question
Accessing Objects Properties with Bracket Notation
Danilo
@sennator
Apr 01 2016 09:33
now it wont rreturn not found?
Vivek
@vivek28111992
Apr 01 2016 09:33
@sennator use bracket notation []
Danilo
@sennator
Apr 01 2016 09:34
for?
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:34
@BKinahan ah. hmmm. strings being immutable makes this a thinker. Hmm..
Tomáš Kalný
@Sleepy-guy
Apr 01 2016 09:34
// Setup
var testObj = {
  12: "Namath",
  16: "Montana",
  19: "Unitas"
};

// Only change code below this line;

var playerNumber1 = 16;       // Change this Line
var player = testObj[playerNumber1];   // Change this Line
it works but its saying that my playernumber isnt number and that i didnt use bracked notation its just a bug or do I have wrong code ?
Vivek
@vivek28111992
Apr 01 2016 09:35
@TanyaGarg317 you are directly assign value to variable, earlier was correct one, you just had to assign to variable
@sennator accessing value
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:35
@sennator myobject[checkprop] <--- bracket vs. myobject(checkprop) <---- parenthesis .
I believe. Please correct me if im wrong.
Brendan Kinahan
@BKinahan
Apr 01 2016 09:35
@Sleepy-guy why did you change playerNumber to playerNumber1?
Danilo
@sennator
Apr 01 2016 09:36
@vivek28111992 @V1ad1m1r thanks guys
CamperBot
@camperbot
Apr 01 2016 09:36
sennator sends brownie points to @vivek28111992 and @v1ad1m1r :sparkles: :thumbsup: :sparkles:
Vivek
@vivek28111992
Apr 01 2016 09:36
@V1ad1m1r you are right
CamperBot
@camperbot
Apr 01 2016 09:36
:star: 441 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992
:star: 254 | @v1ad1m1r | http://www.freecodecamp.com/v1ad1m1r
Danilo
@sennator
Apr 01 2016 09:36
why is that the case/
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:36
:) @vivek28111992 hooray! Im learning things :)
Tomáš Kalný
@Sleepy-guy
Apr 01 2016 09:36
oh I did ? I didn't notice I thought it was there before
Vivek
@vivek28111992
Apr 01 2016 09:37
@sennator that is how js works
it is syntax, every language have such syntax
Brendan Kinahan
@BKinahan
Apr 01 2016 09:37
@Sleepy-guy I guess you are true to your name :)
Vivek
@vivek28111992
Apr 01 2016 09:38
@BKinahan lol
@V1ad1m1r keep it up :+1:
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:44
js
function palindrome(str) {
  // Good luck!
  var str3=[];
  var str2=str.replace("\\s+","");
  str2.toLowerCase();

  str3= str2.split('').reverse().join("");

    if (str2== str3) {

      return true;
    }                  



  return false;
}



palindrome("A man, a plan, a canal. Panama");
This is still kicking my ass. if strings are immutable, how do I remove the spaces? I am using code from the link they provide in the exercise, but it doesnt seem to be helping. hmm.
Codemzy
@codemzy
Apr 01 2016 09:45
@V1ad1m1r I think if you wanted to keep it in the same var you could do str2 = str2.toLowerCase(); or you could assign str2.toLowerCase(); to a new variable
Dennis Borghoff
@borghoffd
Apr 01 2016 09:45

@V1ad1m1r i'm using

function palindrome(str) {
    str=str.toLowerCase().replace(/[^\w]*[\s]*[_]*/g,'');
    strRev=str.split("").reverse().join("");
    console.log(strRev);

    if(str==strRev){
          return true;
    } else {
        return false;
    }
}

you remove spaces with the \s in replace

Brendan Kinahan
@BKinahan
Apr 01 2016 09:46
@borghoffd your regex could be quite a bit simpler, but that works
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:47
@codemzy Hooray! my characters are now lowercase. :)
@borghoffd interesting, though i'm not sure i completely understand whats happening in /[^\w][\s][_]*/g,''
Codemzy
@codemzy
Apr 01 2016 09:48
@V1ad1m1r :thumbsup:
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:48
@codemzy Thanks :) I didnt realize I needed to assign it to itself.
CamperBot
@camperbot
Apr 01 2016 09:48
v1ad1m1r sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 813 | @codemzy | http://www.freecodecamp.com/codemzy
Craig Banach
@CraigBanach
Apr 01 2016 09:50
Dennis Borghoff
@borghoffd
Apr 01 2016 09:50
@BKinahan maybe i'll make it simpler...one day... :D
@V1ad1m1r with [^/w] you replace the non-alphanumeric characters. with \s you replace the spaces and [_] is a little trick to get pass one testcase :D
Brendan Kinahan
@BKinahan
Apr 01 2016 09:52
@borghoffd [^\w] is equivalent to \W, spaces are included in that anyway, and yes _ is needed because it's included as a word character. But \W|_ is sufficient for all of this.
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:53

@borghoffd so to break it down, just to be sure I have it right...

[^w]- alpha numeric target
[\s] - white space target
[_]- targets underscore
/g- makes it global ?

Vivek
@vivek28111992
Apr 01 2016 09:54
@V1ad1m1r right
Craig Banach
@CraigBanach
Apr 01 2016 09:54
@V1ad1m1r global means it won't stop once the condition is met once, It will go through the entire string and keep matching.
Brendan Kinahan
@BKinahan
Apr 01 2016 09:55
@V1ad1m1r you have to escape the w, also
Dennis Borghoff
@borghoffd
Apr 01 2016 09:55
@V1ad1m1r yes +1
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:55

@BKinahan so under that i could just go with...

(/[^\w|_]*/g,'') correct?

thanks for bearing with me guys, wanna make sure I understand the building blocks :)
Brendan Kinahan
@BKinahan
Apr 01 2016 09:56
@V1ad1m1r the * is unnecessary; it'll match one character at a time, but globally, so it'll keep going after finding one. and using a capital W in \W will invert the selection to non-word characters, so you don't need the ^
here are some great resources for getting started with regex: https://regexone.com https://regex101.com @V1ad1m1r
V1ad1m1r
@V1ad1m1r
Apr 01 2016 09:58

@BKinahan @borghoffd @CraigBanach @vivek28111992 Thanks Guys! Ok that makes much more sense :)

I appreciate you guys helping me break it down. :)

CamperBot
@camperbot
Apr 01 2016 09:58
v1ad1m1r sends brownie points to @bkinahan and @borghoffd and @craigbanach and @vivek28111992 :sparkles: :thumbsup: :sparkles:
:star: 442 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992
:star: 1215 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 394 | @craigbanach | http://www.freecodecamp.com/craigbanach
:star: 262 | @borghoffd | http://www.freecodecamp.com/borghoffd
Ankit Panwar
@coderNoob
Apr 01 2016 10:04
In my Truncate a string bf, only one condition is not satisfying but the reset are working fine and I do not know why. Help needed.
function truncateString(str, num) {
  // Clear out that junk in your trunk
  var newStr;
  if(str.length > num){
    newStr =  str.slice(0, num-3);
    if(newStr.length < 3){
      return str.charAt(0)+"...";
    }
    return newStr+"...";
  }
  else 
    return str;
}

truncateString("Absolutely Longer", 2);
Vivek
@vivek28111992
Apr 01 2016 10:06
@coderNoob what is that condition?
Ankit Panwar
@coderNoob
Apr 01 2016 10:07
truncateString("Absolutely Longer", 2) should return "Ab..."
but its returning Absolutely Longe...
@vivek28111992
Blauelf
@Blauelf
Apr 01 2016 10:08
@coderNoob The condition should be if (num <= 3), and can be evaluated before you slice (as you have to slice differently)
Duncan T
@dtweedle
Apr 01 2016 10:09
@coderNoob Look at what happens when you go 2 - 3
@coderNoob You are slicing the string from the [-1] position.
Vivek
@vivek28111992
Apr 01 2016 10:09
@coderNoob newStr = str.slice(0, num-3); //this is giving you 2-3 like @Isymm said
Ankit Panwar
@coderNoob
Apr 01 2016 10:10
@Blauelf @Isymm @vivek28111992 Thanks
CamperBot
@camperbot
Apr 01 2016 10:10
codernoob sends brownie points to @blauelf and @isymm and @vivek28111992 :sparkles: :thumbsup: :sparkles:
:star: 443 | @vivek28111992 | http://www.freecodecamp.com/vivek28111992
:star: 1502 | @blauelf | http://www.freecodecamp.com/blauelf
:star: 282 | @isymm | http://www.freecodecamp.com/isymm
Danilo
@sennator
Apr 01 2016 10:19
// 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(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(5439, "artist", "ABBA");
After update(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
can someone help?
Markus Kiili
@Masd925
Apr 01 2016 10:22
@sennator You should set the property value if value is not an empty string and prop is not "tracks".
Danilo
@sennator
Apr 01 2016 10:25
@Masd925 thanks a lot
Ali
@yxorP
Apr 01 2016 10:31
Hey people, I'm started a Skype group dedicated to FCC a week ago and we have over 30 members who are active everyday. We also have a Slack team area which you will be invited too after you enter the Skype group. If you would like to join please add me on Skype @ "Kindredbay".
Sidharth Kriplani
@sidkrip
Apr 01 2016 10:54
@vramana
Alexander Sääf
@alexsaaf
Apr 01 2016 11:21
Hey guys! I am trying to solve the "Steamroller " algorithm problem, and all my testcases seem to return the right value when I run them in my code, but I am not passing any of them. Is there a problem with this task?
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 11:26
Passes for me
@alexsaaf are you removing all empty arrays?
Alexander Sääf
@alexsaaf
Apr 01 2016 11:27
Yeah, I am
I am however using a global variable... is that a bad idea?
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 11:28
@alexsaaf Can you post your code
Shuldn't affect your outcome if used corectly but yeah generally that's a bad idea
Alexander Sääf
@alexsaaf
Apr 01 2016 11:29

var result = [];

function steamroller(arr) {
for(var i = 0; i < arr.length; i++){
if(!Array.isArray(arr[i])){
result.push(arr[i]);
}else{
steamroller(arr[i]);
}
}
return result;
}

steamroller([1, [], [3, [4]]]);

Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 11:32
@alexsaaf Ah I see, but don't you find it weird to return a value neither declared or an argument in the function?
@alexsaaf move your results variable inside steamroller then create a secondary function that uses your code where that one is the recursively called one
Alexander Sääf
@alexsaaf
Apr 01 2016 11:35
Yeah I do, I just didn't get it to work any other way. I tried doing it recursively and returning the values up, but then I ended up getting the same thing I started with
Ok, will try, thanks
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 11:40
I just tried modifying your code with an inner function and that works, I suggest though that you try doing it with Array.map() instead of a foor loop :)
Alexander Sääf
@alexsaaf
Apr 01 2016 11:42
Yeah that worked, thanks! Ok, will look into map() then! :smile:
Blauelf
@Blauelf
Apr 01 2016 11:49

@alexsaaf If you are using a variable that is outside your function, you'll have to do something else, put both the variable and the recursive function inside another function (as those are function-scope, the array will exist only for the runtime).

function steamroller(arr) {
  var result = [];
  function recursiveFunction(arr) {
    // (this arr hides the outer function's arr, but you also could use another name)
    // Here, do whatever your recursive function does
  }
  return recursiveFunction(arr);
}

The reason for that is that the result variable initialization is done once, while your function might be called multiple times, re-using the old variable, which already has some content. Variables declared inside functions start fresh on each call :)
Another way is to use recursion not in the "walking the tree" style, but as pure functions, returning information not via side effects (result.push), but via return only. Those returned arrays then can be combined using Array.concat.

Karina Machado
@karinamachado
Apr 01 2016 11:55
I am have a challenge to do that I never do andI have a doubt what function I can use to this exercise at my college .

Here’s a simple strategy to encode a message: before each letter of the message, add a number and series of letters. The number should correspond to the number of letters that will precede the message's actual, meaningful letter.

For example, the word “hey” could be coded with “0h2abe1zy”. To read the message, you would:

skip 0, find the ‘h’
skip 2 (‘a’ and ‘b’), find ‘e’
skip 1 (‘z’), find ‘y’
Write a function called “decode”, which takes a string in this code format and returns the decoded word. You may assume that coded strings are always legally encoded with this system.

Blauelf
@Blauelf
Apr 01 2016 11:57
Are those numbers always single digits?
Karina Machado
@karinamachado
Apr 01 2016 11:58
yes
Blauelf
@Blauelf
Apr 01 2016 11:58
Yesterday I read something about Haskell and now I want to do the iteration using recursion :worried:
Karina Machado
@karinamachado
Apr 01 2016 12:00
Blauelf what means Haskell
Blauelf
@Blauelf
Apr 01 2016 12:00
@karinamachado One way would be to use a variable to store the position you are at in the string. As long as that is not at the end of the string, skip 1+ +str[pos] bytes, take one character, increase pos by one, rinse, repeat. Concatenate strings using the + operator.
Markus Kiili
@Masd925
Apr 01 2016 12:01
@Blauelf I have found out that the more I refactor solutions to these problems, the more they evolve towards functional (programming) solutions.
Karina Machado
@karinamachado
Apr 01 2016 12:03
@Blauelf ah ok I get now.
Blauelf
@Blauelf
Apr 01 2016 12:09

Haskell is a functional programming language. It's quite odd, as about everything is a list, and recursion is the way to do iteration. A Haskell-like iteration would be somewhat like

function decode(str) {
  return str.length? str[1+ +str[0]] + decode(str.slice(2+ +str[0])) : "";
}

(might burst your stack if you do that on long strings, but functional programming languages usually have tail recursion optimization, converting that to some type of loop)

Irfan Syed
@syedirfan7
Apr 01 2016 12:11
Hello All I am unable to reload the page here is my pen can some one help in this http://codepen.io/shaafiirfan7/full/qZjYRL/ @sludge256 can you look into it ?
Savio Jomton
@enigma0160
Apr 01 2016 12:12
else if(collection[id][prop]=="tracks" && value!==""){
  collection[id].tracks.push(value);
is this the correct way to push a value into an array in an object?
Karina Machado
@karinamachado
Apr 01 2016 12:12
@Blauelf very interesting I never speak that language
robkozak
@robkozak
Apr 01 2016 12:13

Hello, im wondering if someone can spot the issue with the following:

if ((form == 112) && (deptcode != 'ASA')) {
alert('Enter a Valid Item for Asia Form');
return false;
} else if ((form == 109) && (deptcode != 'BUS' || deptcode != 'UNF') && (city == '')) {
alert('Enter a Valid Item for Event Form');
return false;
} else if ((form == 111) && (costcode != 'GTG' || 
costcode != 'MTC' || costcode != 'MTK' || costcode != 'WAW' || costcode != 'EWE' || costcode != 'GMB' || costcode != 'GGS' || costcode != 'GWG')) {
alert('Enter a Valid Item for Guide Form');
return false;
} else if ((form == 124) && (deptcode != 'BUC' || deptcode != 'UNF' || deptcode != 'GWP' || deptcode != 'BUS') && (costcode != 'DIR' || 
costcode != 'ONL' || costcode != 'GWP' || costcode != 'ECM')){
alert('Enter a Valid Item for Online Form');
return false;
} else if ((form == 121) && (deptcode != 'QSI')) {
alert('Enter a Valid Item for QSIU Form');
return false;
}
return true;
}

the criteria seems to work fine for form id 112 and 109 but im struggling with form 111 and 124. it only works part of the time and im guessing it is the way the and/or statements are set up. is there something glaringly wrong? for form 111 for example i want to return an alert when a costcode doesnt match either of the following: 'GTG', 'MTC', 'MTK', 'WAW' etc

Blauelf
@Blauelf
Apr 01 2016 12:14
You are testing several things with if (A!=B || A!=C). If B and C are not the same, at least one of them is unequal to A, so the condition is always true. Use && instead.
Karina Machado
@karinamachado
Apr 01 2016 12:15
@Blauelf very interesting I never speak that language
Vivek
@vivek28111992
Apr 01 2016 12:15
This message was deleted
Blauelf
@Blauelf
Apr 01 2016 12:18
@robkozak There might be other parts wrong, some && might be || instead (in that case remember that && has higher precedence than ||, as && behaves more like multiplying, while || behaves like addition in some mathematical sense, so you might have to add parentheses)
robkozak
@robkozak
Apr 01 2016 12:21
@Blauelf ok i think i understand. i have tried various && and || scenarios but your comments help, thanks. i didnt know && had the higher precedence
CamperBot
@camperbot
Apr 01 2016 12:21
robkozak sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:star: 1504 | @blauelf | http://www.freecodecamp.com/blauelf
Blauelf
@Blauelf
Apr 01 2016 12:22
It has, and it makes sense if you understand the analogy (having studied physics, I had some fun with boolean algebra)
robkozak
@robkozak
Apr 01 2016 12:34

@Blauelf took a closing parentheses away and changed || to && and it seems to have done the trick, thanks

else if (form == 111 && (costcode != 'GTG' && costcode != 'MTC' && costcode != 'MTK' && costcode != 'WAW' && costcode != 'EWE' && costcode != 'GMB' && costcode != 'GGS' && costcode != 'GWG')) { alert('Enter a Valid Item for Guide Form');

CamperBot
@camperbot
Apr 01 2016 12:34
robkozak sends brownie points to @blauelf :sparkles: :thumbsup: :sparkles:
:warning: robkozak already gave blauelf points
General956
@General956
Apr 01 2016 12:40
anybody on?
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 12:41
yes
General956
@General956
Apr 01 2016 12:42

function queue(arr, item) {
testArr.push(6);
testArr.shift(1);// Your code here

return item; // Change this line
}

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

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

What is the deal with queue???
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 12:43
what assignment is this_
General956
@General956
Apr 01 2016 12:43
stand in line
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 12:44
you should use arr in your function since that is an argument not testArr
also you should .push(item) //also an argument
and return arr.shift()
General956
@General956
Apr 01 2016 12:46
let me try again
Hafsteinn Már Heimisson
@haddi77
Apr 01 2016 12:47
the way you have it now you always push 6 to testArr but what if I used the function like this: queue( otherArr, 9)
bot code