These are chat archives for FreeCodeCamp/HelpJavaScript

17th
Apr 2017
David Amanze
@GodKingShogun
Apr 17 2017 00:01
@JLuboff it says second edition. do i have to do the first edition to understand the secon
Jason Luboff
@JLuboff
Apr 17 2017 00:01
No
You don't even have to use that course just what i'm ging through right now
David Amanze
@GodKingShogun
Apr 17 2017 00:03
@JLuboff what do you mean i dont have to go through it
Jason Luboff
@JLuboff
Apr 17 2017 00:03
What do you not understand from that statement?
barki mustapha
@barkinet
Apr 17 2017 00:03
I have to understand how to 1 and 3
Stephen James
@sjames1958gm
Apr 17 2017 00:04
@barkinet if you do gear = set in setGear it should work
David Amanze
@GodKingShogun
Apr 17 2017 00:05
@JLuboff you said the current iteration of fcc node js is not that good and then you recommended the udemy course and then you said i shouldn't use the udemy :worried:
barki mustapha
@barkinet
Apr 17 2017 00:05
Thank you @sjames1958gm
CamperBot
@camperbot
Apr 17 2017 00:05
barkinet sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6742 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Jason Luboff
@JLuboff
Apr 17 2017 00:05
No, I never said you shouldn't use it, I just said you don't have to use that course.... @GodKingShogun
barki mustapha
@barkinet
Apr 17 2017 00:06
@Chris thanks
CamperBot
@camperbot
Apr 17 2017 00:06
:cookie: 145 | @chris |http://www.freecodecamp.com/chris
barkinet sends brownie points to @chris :sparkles: :thumbsup: :sparkles:
David Amanze
@GodKingShogun
Apr 17 2017 00:07
@JLuboff which course should i use then :smile:
@JLuboff you are scaring me lol
Jason Luboff
@JLuboff
Apr 17 2017 00:07
@GodKingShogun Um...that one...if you want to.
barki mustapha
@barkinet
Apr 17 2017 00:08

Iterate over Arrays with map
The map method is a convenient way to iterate through arrays. Here's an example usage:

var oldArray = [1, 2, 3];
var timesFour = oldArray.map(function(val){
return val * 4;
});
console.log(timesFour); // returns [4, 8, 12]
console.log(oldArray); // returns [1, 2, 3]
The map method will iterate through every element of the array, creating a new array with values that have been modified by the callback function, and return it. Note that it does not modify the original array.

In our example the callback only uses the value of the array element (the val argument) but your callback can also include arguments for the index and array being acted on.

Use the map function to add 3 to every value in the variable oldArray, and save the results into variable newArray. oldArray should not change.

Kevin0920
@Kevin0920
Apr 17 2017 00:09
Hi guys I am having trouble to pass Free code camp JS question 22
the title is Escape Sequences in strings
David Amanze
@GodKingShogun
Apr 17 2017 00:09
@JLuboff why does the fcc node js pale in comparison to the udemy course
Stephen James
@sjames1958gm
Apr 17 2017 00:09
@Kevin0920 Show what you have.
David Amanze
@GodKingShogun
Apr 17 2017 00:09
or how
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:09
@JLuboff lol just did a silly work around i think is kinda working, ppl said its cus sound autoplay dont work in ios without an interactive click or something to operate the sound, to just made it play all the sounds at once when you switch the game on
pretty ugly but feck it
Stephen James
@sjames1958gm
Apr 17 2017 00:10
@GodKingShogun There is really no instruction at all in the node stuff on FCC.
Kevin0920
@Kevin0920
Apr 17 2017 00:10
var myStr ="FirstLine\n\SecondLine\rThirdLine";
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:10
@GodKingShogun and i take it @JLuboff already answered your question
Kevin0920
@Kevin0920
Apr 17 2017 00:10
this is what I have
the window just keeps showing this
myStr should have encoded text with the proper escape sequences and no spacing.
Stephen James
@sjames1958gm
Apr 17 2017 00:10
@Kevin0920 There should be two places where you inserted \\ I only see one
David Amanze
@GodKingShogun
Apr 17 2017 00:11
@sjames1958gm ah okay. so how did you learn node js
Stephen James
@sjames1958gm
Apr 17 2017 00:12
@GodKingShogun You tube videos, mostly I have been using nodejs for about a year and 1/2
barki mustapha
@barkinet
Apr 17 2017 00:12

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

// Only change code below this line.

var newArray = oldArray;
newArray.map(function(val){
return val+3;
});

Kevin0920
@Kevin0920
Apr 17 2017 00:12
@sjames1958gm still showing the same thing
@sjames1958gm can you show me what you have ? thanks
CamperBot
@camperbot
Apr 17 2017 00:13
kevin0920 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6743 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:13
@barkinet you need assign the map over the oldarray to the newArray variable
David Amanze
@GodKingShogun
Apr 17 2017 00:13
@sjames1958gm you are not human lol
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:13
@barkinet map only returns a value doesnt make changes to the origional array
Stephen James
@sjames1958gm
Apr 17 2017 00:13
@Kevin0920 Show what you have if you put backticks at either end it wont hide some characters
@GodKingShogun Realize that I have been programming since 1975 -
barki mustapha
@barkinet
Apr 17 2017 00:14
Each array must be added by 3 how ??
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:14
before time even start? @sjames1958gm
David Amanze
@GodKingShogun
Apr 17 2017 00:14
@sjames1958gm i still have a long way to go :smile:
Stephen James
@sjames1958gm
Apr 17 2017 00:14
@barkinet each array element gets 3 added.
Jason Luboff
@JLuboff
Apr 17 2017 00:15
@HeebieGeeBee Sometimes you gotta take what you can get
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:15
derp sorry time started in 1970 not 1980
@sjames1958gm
Stephen James
@sjames1958gm
Apr 17 2017 00:15
@barkinet map builds a new array from the old array based on the returns
@HeebieGeeBee lol
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:15
@JLuboff indeed
Michael Baxter
@baxt01
Apr 17 2017 00:15
time start = 01-01-1970 :)
Stephen James
@sjames1958gm
Apr 17 2017 00:15
@barkinet The instructions say assign the result of map to newArray
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:15
@baxt01 lol yeah had a brain fart
barki mustapha
@barkinet
Apr 17 2017 00:18

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

// Only change code below this line.

var newArray = oldArray;
oldArray.map(function(val){
return val+3;
});

Stephen James
@sjames1958gm
Apr 17 2017 00:18
@barkinet assign the result of map to newArray
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 00:18
@barkinet no var newArray = oldArray.map(fun........
Stephen James
@sjames1958gm
Apr 17 2017 00:18
newArray = oldArray.map
Kevin0920
@Kevin0920
Apr 17 2017 00:20
@sjames1958gm I got it. Thanks
CamperBot
@camperbot
Apr 17 2017 00:20
kevin0920 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: kevin0920 already gave sjames1958gm points
barki mustapha
@barkinet
Apr 17 2017 00:20
@HeebieGeeBee thank y
CamperBot
@camperbot
Apr 17 2017 00:20
:star2: 1351 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
barkinet sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
barki mustapha
@barkinet
Apr 17 2017 00:21
@sjames1958gm I'm grateful

Condense arrays with reduce
The array method reduce is used to iterate through an array and condense it into one value.

To use reduce you pass in a callback whose arguments are an accumulator (in this case, previousVal) and the current value (currentVal).

The accumulator is like a total that reduce keeps track of after each operation. The current value is just the next element in the array you're iterating through.

reduce has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified it will be the first array element and currentVal will start with the second array element.

Here is an example of reduce being used to subtract all the values of an array:

var singleVal = array.reduce(function(previousVal, currentVal) {
return previousVal - currentVal;
}, 0);
Use the reduce method to sum all the values in array and assign it to singleVal.

Stephen James
@sjames1958gm
Apr 17 2017 00:25
@barkinet copy the sample but use + instead of -
barki mustapha
@barkinet
Apr 17 2017 00:27
+

Filter Arrays with filter
The filter method is used to iterate through an array and filter out elements where a given condition is not true.

filter is passed a callback function which takes the current value (we've called that val) as an argument.

Any array element for which the callback returns true will be kept and elements that return false will be filtered out.

The following code is an example of using filter to remove array elements that are equal to five:

Note: We omit the second and third arguments since we only need the value

array = array.filter(function(val) {
return val !== 5;
});
Use filter to create a new array with all the values from oldArray which are less than 6. The oldArray should not change.

Moisés Man
@moigithub
Apr 17 2017 00:28
im wondering IF u really learned how to use those methods.. like map or reduce @barkinet
i feel like u just copy/paste instructions and expect others people solve for you, without trying urself
(...i might be wrong too )
barki mustapha
@barkinet
Apr 17 2017 00:30
I'm wondering if you can believe in yourself @moises
Moisés Man
@moigithub
Apr 17 2017 00:31
soo if u have this ["hello", "awesome","world"] how u will create a "hello awesome world" phrase using map ? @barkinet
and also using reduce ?
barki mustapha
@barkinet
Apr 17 2017 00:31
When I set up first Thor served I'm reading about FBI care about users
Daniel Mattox
@dmattox10
Apr 17 2017 00:31
I'm still stuck on Profile Lookup, if anyone is willing to help, I threw my code up here: https://pastebin.com/74CZq5et It returns "No such property"
Christopher McCormack
@cmccormack
Apr 17 2017 00:33
@ShowStopperLED you should use bracket notation, not dot notation when calling the property of an object using a variable
barki mustapha
@barkinet
Apr 17 2017 00:33
Old function @ShowStopperLED
Stephen James
@sjames1958gm
Apr 17 2017 00:33
@ShowStopperLED You need to check for the property on the contact that has the matching first name
Daniel Mattox
@dmattox10
Apr 17 2017 00:34
Ah, yes, I didn't specify, also, I'll switch to bracket notation, thanks guys!
barki mustapha
@barkinet
Apr 17 2017 00:36
@ShowStopperLED to kill confusion try to change first name
Daniel Mattox
@dmattox10
Apr 17 2017 00:37
I don't understand.
AH!
Christopher McCormack
@cmccormack
Apr 17 2017 00:41
oops sorry I was readying that wrong, didnt see contacts was an array
Will Beethoven
@WillBeethoven
Apr 17 2017 00:42
Check for Palindromes
I found myself didn't write simple code with regular expression, but don't know how to improve. Can someone help me to refactor it? Thanks a lot!

function palindrome(str) {
  var nonUnderScoreStr = str.replace(/_/g, '');
  var nonAlphanumericStr = nonUnderScoreStr.match(/\w/g, '');
  return nonAlphanumericStr.join('').toLowerCase() === nonAlphanumericStr.reverse().join('').toLowerCase();
}

palindrome("not a palindrome");
Christopher McCormack
@cmccormack
Apr 17 2017 00:45
@WillBeethoven you can combine your regexes for one thing
and you can also chain toLowerCase to your replace function, then you don't have to do it twice
Stephen James
@sjames1958gm
Apr 17 2017 00:45
@WillBeethoven You can use a single regex
 var cleanStr = str.replace(/\W|_/g, "").toLowerCase()
 return cleanStr === cleanStr.split('').reverse().join('')
Christopher McCormack
@cmccormack
Apr 17 2017 00:46
I think it's supposed to return a Boolean
Stephen James
@sjames1958gm
Apr 17 2017 00:47
@cmccormack That is what I get for coding live :)
Christopher McCormack
@cmccormack
Apr 17 2017 00:47
haha
Will Beethoven
@WillBeethoven
Apr 17 2017 00:47
@cmccormack @sjames1958gm Thank you so much!
CamperBot
@camperbot
Apr 17 2017 00:47
willbeethoven sends brownie points to @cmccormack and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6744 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:cookie: 405 | @cmccormack |http://www.freecodecamp.com/cmccormack
Will Beethoven
@WillBeethoven
Apr 17 2017 00:48
Inspired me a lot!
Spyrantis Theodoros
@thodorisanta
Apr 17 2017 00:49
why my project height and width look different when i move from opera to chrome? :/
barki mustapha
@barkinet
Apr 17 2017 00:49

var oldArray = [1,2,3,4,5,6,7,8,9,10];

// Only change code below this line.

var newArray = oldArray.filter(function(val) {
return val <6;
});

Will Beethoven
@WillBeethoven
Apr 17 2017 00:51
@thodorisanta Is there a link for code?
Stephen James
@sjames1958gm
Apr 17 2017 00:52
@barkinet Looks correct
barki mustapha
@barkinet
Apr 17 2017 00:55

Concatenate Arrays with concat
concat can be used to merge the contents of two arrays into one.

concat takes an array as an argument and returns a new array with the elements of this array concatenated onto the end.

Here is an example of concat being used to concatenate otherArray onto the end of oldArray:

newArray = oldArray.concat(otherArray);

Use .concat() to concatenate concatMe onto the end of oldArray and assign it to newArray.

barki mustapha
@barkinet
Apr 17 2017 01:01

Split Strings with split
You can use the split method to split a string into an array.

split uses the argument you pass in as a delimiter to determine which points the string should be split at.

Here is an example of split being used to split a string at every s character:

var array = string.split('s');

Use split to create an array of words from string and assign it to array.

zunigara9
@zunigara9
Apr 17 2017 01:02
I am doing the escape sequence challenge, for some reason I can't figure out what to do.
var myStr; "FirstLine \n \SecondLine\ \r ThirdLine"
this is what I've got
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:03
@zunigara9 you need to assign the string to myStr using the assignment operator cos right now myStr is undefined
barki mustapha
@barkinet
Apr 17 2017 01:05

var string = "Split me into an array";
var array = [];

// Only change code below this line
var array = string.split('s');

Help
Will Beethoven
@WillBeethoven
Apr 17 2017 01:06

@sjames1958gm I tried to write palindrome() like this:

function palindrome(str) {
  var clearStr = str.replace(/\W|_/g, '').toLowerCase().split('');
  return clearStr === clearStr.reverse();
}

palindrome("A not a palindrome");

It always returns true.
Then I tested ["a", "b", "c"] === ["a", "b", "c"].reverse(); which returns false, so I'm being a little confused now.

Ogundele Olumide
@Lumexralph
Apr 17 2017 01:06
@WillBeethoven clearStr is an array not a string
Christopher McCormack
@cmccormack
Apr 17 2017 01:06
abc isn't a palindrome
zunigara9
@zunigara9
Apr 17 2017 01:06
got it thank you!
Stephen James
@sjames1958gm
Apr 17 2017 01:07
@WillBeethoven comparing arrays is difficult i n js - unless they are the exact same array it will always be false (why join is used first)
barki mustapha
@barkinet
Apr 17 2017 01:07
@sjames1958gm thank you
CamperBot
@camperbot
Apr 17 2017 01:07
barkinet sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 6745 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Apr 17 2017 01:07
@WillBeethoven .reverse() reverses the array in place and returned it
clearStr === clearStr.reverse();
this will always return true because they are the same array
barki mustapha
@barkinet
Apr 17 2017 01:08

@sjames1958gm
var string = "Split me into an array";
var array = [];

// Only change code below this line
var array = string.split('s');

Stephen James
@sjames1958gm
Apr 17 2017 01:08
@barkinet What do the instructions say to split the string on?
barki mustapha
@barkinet
Apr 17 2017 01:08
split the string by its spaces.
Stephen James
@sjames1958gm
Apr 17 2017 01:09
@barkinet 's' is the letter s not a space
barki mustapha
@barkinet
Apr 17 2017 01:09
Ok
@sjames1958gm god bless you always
Stephen James
@sjames1958gm
Apr 17 2017 01:11
@barkinet yw
barki mustapha
@barkinet
Apr 17 2017 01:11

Join Strings with join
We can use the join method to join each element of an array into a string separated by whatever delimiter you provide as an argument.

The following is an example of using join to join all of the elements of an array into a string with all the elements separated by word and:

var veggies = ["Celery", "Radish", "Carrot", "Potato"];
var salad = veggies.join(" and ");
console.log(salad); // "Celery and Radish and Carrot and Potato"

Stephen James
@sjames1958gm
Apr 17 2017 01:13
@barkinet Where split is string -> array join is array->string basically the opposite behaviour.
so str.split(' ').join(' ') would result in the original string
jhobotuck
@jhobotuck
Apr 17 2017 01:14

So I'm struggling using javascript notation when using a loop. Coming from Python which gives significance to space. How can I iterate through a return statement once?

Here's the code:

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = 0;

  for (var i = 0; i < contacts.length; i++)
    if (contacts[i].firstName == firstName){
        if (contacts[i].hasOwnProperty(prop)){
          value += 1;
          return contacts[value];
        } else {
          return "No such property";
        }
     } else {
       return "No such contact";
     }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:14
@jhobotuck this will return an object return contacts[value];
@jhobotuck you're to return the value of the property name stored in propin contacts[i]
HN
@haydennorthcott
Apr 17 2017 01:15
is this close:

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

myObj.hasOwnProerty(checkProp);

}

// Test your code by modifying these values
checkObj("gift");
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:16
@haydennorthcott yes but use it with an if statement myObj.hasOwnProerty(checkProp)
barki mustapha
@barkinet
Apr 17 2017 01:17
@sjames1958gm done
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:17
@haydennorthcott you check if the property name held by checkProp parameter is in the object myObj then you return the value from that object
Stephen James
@sjames1958gm
Apr 17 2017 01:17
@barkinet :+1:
barki mustapha
@barkinet
Apr 17 2017 01:17
Our algorithm challenges will teach you how to think like a programmer.
Will Beethoven
@WillBeethoven
Apr 17 2017 01:17

@WillBeethoven .reverse() reverses the array in place and returned it
clearStr === clearStr.reverse();
this will always return true because they are the same array

@sjames1958gm Is there something wrong with this test?

function testReverseArray() {
  return ["a", "b", "c"] === ["a", "b", "c"].reverse();
}

testReverseArray(); // returns false

function palindrome(str) {
  var clearStr = str.replace(/\W|_/g, '').toLowerCase().split('');
  return clearStr === clearStr.reverse();
}

palindrome("A not a palindrome"); // returns true
Christopher McCormack
@cmccormack
Apr 17 2017 01:17
@haydennorthcott Do the tests require a Boolean response? If so you can just return myObj.hasOwnProerty(checkProp);
Stephen James
@sjames1958gm
Apr 17 2017 01:18
@WillBeethoven You cannot compare arrays like that - arrays only will be equal if they are the same array
Will Beethoven
@WillBeethoven
Apr 17 2017 01:18
@sjames1958gm Got it.
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:18
@WillBeethoven ["a", "b", "c"] and the other ["a", "b", "c"] are to separate arrays
barki mustapha
@barkinet
Apr 17 2017 01:18
Our previous challenges introduced you to programming concepts. But for these algorithm challenges, you'll now need to apply what you learned to solve open-ended problems.
Stephen James
@sjames1958gm
Apr 17 2017 01:18
@haydennorthcott hasOwnProerty spelling is important
anderson
@anderson2825
Apr 17 2017 01:18
blob
why is false??
Stephen James
@sjames1958gm
Apr 17 2017 01:19
@barkinet Yes - you may need to refer back to these often
@anderson2825 Spacing is important
Khalid Anthony
@kanthony98
Apr 17 2017 01:19
I'm having trouble with the 'Slasher Flick' problem:

Here's my code:
function slasher(arr, howMany) {

var newArr = [];

for(i = 0; i < arr.length; i++){
newArr.push(arr.splice(0, howMany));
}
return arr;
}

slasher(["burgers", "fries", "shake"], 1);

Will Beethoven
@WillBeethoven
Apr 17 2017 01:19
@sjames1958gm @Lumexralph Thank you. I do understand with comparing arrays.
CamperBot
@camperbot
Apr 17 2017 01:19
willbeethoven sends brownie points to @sjames1958gm and @lumexralph :sparkles: :thumbsup: :sparkles:
:warning: willbeethoven already gave sjames1958gm points
:star2: 1521 | @lumexralph |http://www.freecodecamp.com/lumexralph
anderson
@anderson2825
Apr 17 2017 01:19
what should i do??
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:19
@anderson2825 you need to put spaces Yes, that was true not Yes, that was true
Khalid Anthony
@kanthony98
Apr 17 2017 01:20
I'm getting ['shake'] as my output and I don't know why
Christopher McCormack
@cmccormack
Apr 17 2017 01:20
@anderson2825 missing spaces
Stephen James
@sjames1958gm
Apr 17 2017 01:20
@anderson2825 Compare the strings you returned to the ones from the instructions
anderson
@anderson2825
Apr 17 2017 01:20
okay ! @ @sjames1958gm thanks !
CamperBot
@camperbot
Apr 17 2017 01:20
:star2: 6746 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
anderson2825 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
barki mustapha
@barkinet
Apr 17 2017 01:20
A cute dog jumping over a hurdle and winking and pointing his paw at you.
When you get stuck, just use the Read-Search-Ask methodology.
Don't worry - you've got this.
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:20
@kanthony98 what're you trying to do?
Stephen James
@sjames1958gm
Apr 17 2017 01:21
@kanthony98 having splice inside of a for loop can be troublesome because the size of the array changes
barki mustapha
@barkinet
Apr 17 2017 01:21

Reverse a String
Reverse the provided string.

You may need to turn the string into an array before you can reverse it.

Your result must be a string.

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

Here are some helpful links:

Global String Object
String.prototype.split()
Array.prototype.reverse()
Array.prototype.join()

Khalid Anthony
@kanthony98
Apr 17 2017 01:22
I'm trying to return the remaining elements of an array after removing 'howMany' elements
@sjames1958gm what do you suggest doing?
HN
@haydennorthcott
Apr 17 2017 01:23
This appears to be a bit closer, but still seems wrong:

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here

if (myObj.hasOwnProperty(checkProp)) {
  return  "pony" ;
}
  else {
    return "Not Found";
  }
}

// Test your code by modifying these values
checkObj("house");
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:23
@kanthony98 do you need a for loop?
jhobotuck
@jhobotuck
Apr 17 2017 01:23
@Lumexralph I tried "return contacts[prop]" looking at "Using Objects for Lookup" I thought I had nailed it. No luck.
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:24
@haydennorthcott use checkProp to access the object myObj to get the value
@jhobotuck can you show your code?
HN
@haydennorthcott
Apr 17 2017 01:25
@Lumexralph what does that mean in simple talk?
jhobotuck
@jhobotuck
Apr 17 2017 01:25

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

function lookUpProfile(firstName, prop){
// Only change code below this line
var value = 0;

for (var i = 0; i < contacts.length; i++)
if (contacts[i].firstName == firstName){
if (contacts[i].hasOwnProperty(prop)){
return contacts[prop];
} else {
return "No such property";
}
} else {
return "No such contact";
}

// Only change code above this line
}

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

Khalid Anthony
@kanthony98
Apr 17 2017 01:25
@Lumexralph I think so, it worked for the other trials.
jhobotuck
@jhobotuck
Apr 17 2017 01:25

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = 0;

  for (var i = 0; i < contacts.length; i++)
    if (contacts[i].firstName == firstName){
        if (contacts[i].hasOwnProperty(prop)){
          return contacts[prop];
        } else {
          return "No such property";
        }
     } else {
       return "No such contact";
     }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Khalid Anthony
@kanthony98
Apr 17 2017 01:26
@Lumexralph I added 'i < arr.length' to account for the array changing size
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:27

@jhobotuck

else {
return "No such contact";
}

can not stand alone without an if statememnt preceding it, just simply return without using else

@kanthony98howMany is the number of items to be removed from arr, right?
barki mustapha
@barkinet
Apr 17 2017 01:28
x = reverseString("Howdy");
array = reverseString(x).split('').reverse().join('');
final = "\"" + array + "\"";
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:29
@haydennorthcott return myObj[checkProp];
jhobotuck
@jhobotuck
Apr 17 2017 01:29
@haydennorthcott your first return statement should not be a string instead your code your access myObj. If you look at the test run by the FreeCodeCamp compiler it will use your code to try return "kitten" and "sleigh".
Khalid Anthony
@kanthony98
Apr 17 2017 01:30
@Lumexralph yes
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:30
@kanthony98 starting from index 0, right?
Khalid Anthony
@kanthony98
Apr 17 2017 01:30
yes
jhobotuck
@jhobotuck
Apr 17 2017 01:31
@Lumexralph I thought the second else was connected to the first if statement? Or is there a mistake in my code>
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:32
@jhobotuck the if statement is in the for loop, your last else statement is outside the for loop scope
CamperBot
@camperbot
Apr 17 2017 01:33
haydennorthcott sends brownie points to @lumexralph and @jhobotuck :sparkles: :thumbsup: :sparkles:
:cookie: 217 | @jhobotuck |http://www.freecodecamp.com/jhobotuck
:star2: 1522 | @lumexralph |http://www.freecodecamp.com/lumexralph
Christopher McCormack
@cmccormack
Apr 17 2017 01:33
@haydennorthcott Try to avoid sharing full solutions if you can
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:33
@kanthony98 i'll suggest you just slice the array using howMany and returning it
HN
@haydennorthcott
Apr 17 2017 01:33
@cmccormack roger.
barki mustapha
@barkinet
Apr 17 2017 01:34

function reverseString(str) {
var split1 = str.split("");
var reverse = split1.reverse();
return reverse.join("");
}

reverseString("hello");

Ogundele Olumide
@Lumexralph
Apr 17 2017 01:34
@kanthony98 so your code should return [ 'fries', 'shake' ] right?
Khalid Anthony
@kanthony98
Apr 17 2017 01:34
yes that's right
barki mustapha
@barkinet
Apr 17 2017 01:34
👍
Nada
@NadaKhamis
Apr 17 2017 01:35
Hi, How do i display a value to the console?
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:35
@kanthony98 what I think you need to do is return arr.slice(howMany);
@NadaKhamis console.log(value);
Roxroy
@roxroy
Apr 17 2017 01:35
@NadaKhamis . console.log(name);
Nada
@NadaKhamis
Apr 17 2017 01:35
Than ls
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:36
@barkinet you can also chain your methods
jhobotuck
@jhobotuck
Apr 17 2017 01:37
@Lumexralph I have tried removing the second else statement, all it does is remove one of the ticks from the objectives that says ""Akira", "address" should return "No such property""
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:38
@jhobotuck let's see your code
@jhobotuck see here contacts[prop] should be the object not array contacts[i][prop]
Nada
@NadaKhamis
Apr 17 2017 01:40
i cannot display a value to the console . I mean the freecodecamp console. the only thing showing the the return of the function false
jhobotuck
@jhobotuck
Apr 17 2017 01:40

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


function lookUpProfile(firstName, prop){
// Only change code below this line
  var value = 0;

  for (var i = 0; i < contacts.length; i++)
    if (contacts[i].firstName == firstName){
      if (contacts[i].hasOwnProperty(prop)){
          return contacts[prop];
        } else {
          return "No such property";
        }
     }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:40
@NadaKhamis you can't, FCC is not a console.... try using the console of your browser
Moisés Man
@moigithub
Apr 17 2017 01:40
@jhobotuck contacts is an array
if u wanna access some object ELEMENT prop.. first u need to get the OBJECT element from the array
contacts[x][prop]
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:41
@NadaKhamis or use this site https://repl.it/languages/JavaScript
Khalid Anthony
@kanthony98
Apr 17 2017 01:42
@Lumexralph lol thank you so much. I tried too hard to make it complicated
CamperBot
@camperbot
Apr 17 2017 01:42
kanthony98 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1523 | @lumexralph |http://www.freecodecamp.com/lumexralph
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:43
@kanthony98 :smile: it doesn't have to be most times
Michael Baxter
@baxt01
Apr 17 2017 01:44
ok i think i am going to call it for this night i have worked through to "Manipulating Complex Objects" and now i have become so tired that i cant even make no sense of the task
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:45
@baxt01 :smile:
@baxt01 what's the matter buddy?
Michael Baxter
@baxt01
Apr 17 2017 01:45
well it is 2:45am
i'm thinking my brain just stopped
stopped processing
stopped giving a shit
Ogundele Olumide
@Lumexralph
Apr 17 2017 01:46
@baxt01 maybe you sleep then
Michael Baxter
@baxt01
Apr 17 2017 01:47
yeah thats the only process i can manage :D
so i entered with "Hello World" now for tonight i say "Good Night Worl"
jhobotuck
@jhobotuck
Apr 17 2017 01:49
Thank you @Lumexralph . I am getting the right object returned but not passing the exericise grrrr! Oh well. Come back to it later.
CamperBot
@camperbot
Apr 17 2017 01:49
jhobotuck sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1524 | @lumexralph |http://www.freecodecamp.com/lumexralph
jhobotuck
@jhobotuck
Apr 17 2017 01:50
@moigithub thanks for your description. I now know how to describe that problem.
CamperBot
@camperbot
Apr 17 2017 01:50
jhobotuck sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3116 | @moigithub |http://www.freecodecamp.com/moigithub
barki mustapha
@barkinet
Apr 17 2017 01:51

function factorialize(num) {
var x = 0;
var product = 1;
var array = [];
while (x < num){
x++;
array.push(x);
}
for (var i=0; i<array.length;i++){
product *= array[i];
}
return product;
}

factorialize(5);

👍

Check for Palindromes
Return true if the given string is a palindrome. Otherwise, return false.

A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.

Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.

We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.

We'll also pass strings with special symbols, such as "2A33a2", "2A3 3a2", and "2_A33#A2".

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

Here are some helpful links:

String.prototype.replace()
String.prototype.toLowerCase()

barki mustapha
@barkinet
Apr 17 2017 01:59

function palindrome(str) {
// Good luck!
var newStr = str.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
var newArr = newStr.split("");
if(newArr[0] == newArr[newArr.length - 1]) {
return true;
} else {
return false;
}
}

palindrome("almostomla");

Help if return false
How to got it true ???
Moisés Man
@moigithub
Apr 17 2017 02:11
a345g345jg345ja
u only comparing first vs last character, thats NOT a palindrome
barki mustapha
@barkinet
Apr 17 2017 02:17

function palindrome(str) {
var replaced_result = str.replace(/[^a-zA-Z]/g, '').toLowerCase();

//a loop to detect palindrome
var ret = false;
for (var idx1 = 0; idx1 < replaced_result.length/2; idx1++) {
    if (replaced_result[idx1] != replaced_result[replaced_result.length - idx1 - 1])
        return false;
}

return true;
}

palindrome("1 eye for of 1 eye.");

Help
Moisés Man
@moigithub
Apr 17 2017 02:18
u need to KEEP numbers too
rmanaswi
@rmanaswi
Apr 17 2017 02:25
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold" how to solve this
??
Ogundele Olumide
@Lumexralph
Apr 17 2017 02:27
@rmanaswi you'll need to check the value held in the card parameter of the function provided to increment or decrement count, then you'll later check if count is positive or not to return count + string required
MiguelM47
@MiguelM47
Apr 17 2017 02:29
I am supposed to have at least two if statements. I keep receiving a red x in the first line and I can't figure out what's incorrect
function testElseIf(val) {
  if (val > 10) {
    return "Greater than 10";
  } else if (val < 5) {
    return "Smaller than 5";
  } else {

  return "Between 5 and 10";
}

// Change this value to test
testElseIf(7);
Ogundele Olumide
@Lumexralph
Apr 17 2017 02:31
@MiguelM47 maybe you should change else if to if statement
barki mustapha
@barkinet
Apr 17 2017 02:34
@moigithub thanks
CamperBot
@camperbot
Apr 17 2017 02:34
barkinet sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 3117 | @moigithub |http://www.freecodecamp.com/moigithub
Christopher McCormack
@cmccormack
Apr 17 2017 02:37
@MiguelM47 Because you are returning in your first conditional, you do not need an else if, the instruction would move on if the test failed and return if it succeeded
gulptech
@gulptech
Apr 17 2017 02:38
@MiguelM47 and your did not close the function (either remove the else { or add another } at the end
Ken Haduch
@khaduch
Apr 17 2017 02:38
@MiguelM47 - this looks like the exact same solution that I have, except that you need a closing } on your last else statement, after return "Between 5 and 10"; - add another }
@MiguelM47 - the red "X" on the first line of your code? Is that what you mean? If you hover over that, you see it mention an error Unmatched '{' - that is a way to figure out what it is trying to tell you.
Vicky Lai
@vickylai
Apr 17 2017 02:42
Regarding displaying search results... I can use JS to iterate through x number of objects in a list, and for each one run a function that creates a new "search result div" and appends that to my page. Is that the way to go about it generally or am I totally overthinking it/missing something simpler?
Ken Haduch
@khaduch
Apr 17 2017 02:43
@barkinet - if you are properly replacing the non-alphabetic characters (and maybe you also need to keep the numeric values in there?) you can then just compare the reversed version of the string with the "forward version" of the string that you will have in replaced_result - no need to try and make some complicated for loop to check character-by-character. It makes it a lot simpler. (Oh, I didn't see that @moigithub replied above, since he didn't tag you...) But you can simplify your comparison.
Christopher McCormack
@cmccormack
Apr 17 2017 02:45
@vickylaixy Sure that would work, although I would recommend building all of the results together before appending the new set of elements to the DOM
Darth Skywalker
@adityaparab
Apr 17 2017 02:47
@vickylaixy : Yes! Totally overthinking! Just get started and improvise on your way...
Vicky Lai
@vickylai
Apr 17 2017 02:48
@cmccormack Cool beans. Thanks!
CamperBot
@camperbot
Apr 17 2017 02:48
vickylaixy sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 406 | @cmccormack |http://www.freecodecamp.com/cmccormack
MiguelM47
@MiguelM47
Apr 17 2017 02:51
orderMyLogic is not returning "Less than 5". What is incorrect?
function orderMyLogic(val) {
  if (val < 10) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";
  }
}

// Change this value to test
orderMyLogic(4);
Ogundele Olumide
@Lumexralph
Apr 17 2017 02:52
@MiguelM47 if val < 10, else if (val < 5) will not be executed. you have to bring that first before checking if val < 10
Bob Potter
@bobpotter
Apr 17 2017 02:53
Hi, I'm stuck on the Celsius conversion exercise. This is what I have figured out so far - fahrenheit = convertToF(celsius) * 9/5 + 32; . Can anyone please give me a tip on how to solve this? Thanks.
Christopher McCormack
@cmccormack
Apr 17 2017 02:54
@bobpotter What do you have so far?
Ogundele Olumide
@Lumexralph
Apr 17 2017 02:54
@bobpotter fahrenheit = convertToF(celsius) * 9/5 + 32; you don't need the function name convertToF remove that
Bob Potter
@bobpotter
Apr 17 2017 02:55
I just have the one line: fahrenheit = convertToF(celsius) * 9/5 + 32; I'm sorry but I don't know how best to display my code.
Vicky Lai
@vickylai
Apr 17 2017 02:55
Can I create a new instance of a predefined html element with the createElement() method? Say I have a div with id=apples which itself contains other html bits. Can I use JS to create a new apples div?
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 02:55
@bobpotter you are inside the function, your job is to code what that function will do, if you call the same function, it will be a infinite loop x)
Ogundele Olumide
@Lumexralph
Apr 17 2017 02:56
@bobpotter fahrenheit = celsius * 9/5 + 32;
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 02:56
@vickylaixy yeah, you need firsst to create it, and then add the attributes
@vickylaixy then with DOM, you can append the other elements inside it
Vicky Lai
@vickylai
Apr 17 2017 02:58
@NahuelOvejero Swell. :thumbsup: Thanks! It's research time.
CamperBot
@camperbot
Apr 17 2017 02:58
vickylaixy sends brownie points to @nahuelovejero :sparkles: :thumbsup: :sparkles:
:cookie: 321 | @nahuelovejero |http://www.freecodecamp.com/nahuelovejero
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 02:59
@vickylaixy check .setAttribute() and .appendChild() . No problem
Ken Haduch
@khaduch
Apr 17 2017 03:01
@bobpotter - to display your code, use "Markdown" format - here is an article on the forum that explains how to do it: https://forum.freecodecamp.com/t/markdown-code-formatting/18391
Vicky Lai
@vickylai
Apr 17 2017 03:01
Sometimes I get started learning about something to do with code and "Whole New World" just pops into my head.
Bob Potter
@bobpotter
Apr 17 2017 03:01
Thanks everyone for your help!!
Darth Skywalker
@adityaparab
Apr 17 2017 03:02
@Lumexralph :wave:
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 03:02
@vickylaixy I know your feel x) programming is like almost an infinite world
Techonologies in general tbh
Darth Skywalker
@adityaparab
Apr 17 2017 03:03
It's like that for everything in this world... Read book called Transurfing ;)
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:06

I need help on the challenge Global vs local scope in functions. Here is my code. I need to figure out how to return the "sweater" without changing the var outerwear. Here is my code:
// Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var myOutfit = "sweater";

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

myOutfit();

Ogundele Olumide
@Lumexralph
Apr 17 2017 03:06
@adityaparab :wave:
Darth Skywalker
@adityaparab
Apr 17 2017 03:07
@jakepie123 : outerWear = "sweater"; ?
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 03:07
@jakepie123 you are returning outerWear... not myOutfit... and if you can not change the return statmente, what you have to do?
@adityaparab try to don't give the answer rigth away...
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:07
@adityaparab You can't change the var outerWear
Julio Roman
@jroman123
Apr 17 2017 03:07

On the Mutation Exercise
function mutation(arr) { return arr[1].toLowerCase().split('').map( function(item){ return (arr[0].toLowerCase().indexOf(item)<0)?1:0;} ).sort().reverse()[0]===0; }

can some one explain to me in a visual form, why this code which is correct by the way, if
the if statement is evaluating the return of the method indexOf(item) and the -1 is the return
for the index that did not matched, why the if statement tells it to say is true?

shouldn't be the opposite? if statement < 0 ? 0 : 1;....

Jacob Pieczynski
@jakepie123
Apr 17 2017 03:08
@NahuelOvejero I can't change the code above it. It says so in the comments, and in order to complete the challenge, I cannot do that
Darth Skywalker
@adityaparab
Apr 17 2017 03:08
@jakepie123 : You can't change the outerWear as in your can't change it outside of your function.
that's the whole point of having a local scope
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:09

But here is what it says for the criteria to complete the challenge, and I quote: Do not change the value of the global outerWear

myOutfit should return "sweater"

Do not change the return statement

Darth Skywalker
@adityaparab
Apr 17 2017 03:10
if you redeclare var outerWear inside your function, you won't be affecting your outerWear that is declared outside of your function.
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 03:10
you can't change the value , but you can reasign it inside
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:11

I did, but it is not going through. Here is my code now, and the last to criteria are fulfilled, but not the first: Do not change the value of the global outerwear: // Setup
var outerWear = "T-Shirt";

function myOutfit() {
// Only change code below this line

var myOutfit = "sweater";
outerWear = myOutfit;

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

myOutfit();

Darth Skywalker
@adityaparab
Apr 17 2017 03:11
You can't reassign value to outerWear... You have to redefine it using var... If you don't define it with a var, it will overwrite the outer variable.
@jakepie123 : Even this is wrong...
outerWear = myOutfit;
you need to do var outerWear = myOutfit;
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:12
@adityaparab What do you mean? What is the difference between adding var and not adding var?
Julio Roman
@jroman123
Apr 17 2017 03:12
all variables need to be declared before initializing them.
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:12
@adityaparab I got it to work, but why didn't it work before? What does adding var do differently than not?
Julio Roman
@jroman123
Apr 17 2017 03:13
@jakepie123 all variables need to be declared before initializing them.

Anyone, please

function mutation(arr) {
return arr[1].toLowerCase().split('').map(
  function(item){  return (arr[0].toLowerCase().indexOf(item)<0)?1:0;}
  ).sort().reverse()[0]===0;
}

can some one explain to me in a visual form, why this code which is correct by the way, if
the if statement is evaluating the return of the method indexOf(item) and the -1 is the return
for the index that did not matched, why the if statement tells it to say is true?

shouldn't be the opposite? if statement < 0 ? 0 : 1;....

Darth Skywalker
@adityaparab
Apr 17 2017 03:15

@jakepie123 :smile:

You have defined outerWear first out side of the function. Javascript has a think called scope. If a variable is not found in current scope, it will look at it's parent scope for that variable. If found, it will use it...

Now your entire script, in this case, is a parent scope. Now you create a new scope using function myOutfit. All the variables in the parent scope are available to your myOutfit function scope.

What you are asked to do is create a new variable with same name in your local function scope. If you define outerWear with a var, the js will use it from the local scope. If you don't use var, js will use the variable from the parent scope and uupdated the value of outerWear in parent scope..

that is why you need to define new variable outerWear with a var that is local to your function.
Joseph
@revisualize
Apr 17 2017 03:19
Hello.
Christopher McCormack
@cmccormack
Apr 17 2017 03:21
@jroman123 if I'm reading it correctly, it's basically just creating a new array of 1's and 0's based on the input array, then sorting that array so all 1's will be on one side and all 0's on the other, then reversing it to ensure the first position will determine the truthyness. If there were any 1's at all, it would fail. This seems overly complicated and hard to read, where did you get it?
Julio Roman
@jroman123
Apr 17 2017 03:23
So it will replaced on the element all the values with-1 to 1 and 0,1,2.... to all zeroes?
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:23
@adityaparab Just saw your reply. Thank you so much for that, it really helped
CamperBot
@camperbot
Apr 17 2017 03:23
jakepie123 sends brownie points to @adityaparab :sparkles: :thumbsup: :sparkles:
:star2: 1007 | @adityaparab |http://www.freecodecamp.com/adityaparab
Jacob Pieczynski
@jakepie123
Apr 17 2017 03:24
How would you assign processArg (a function) to processed (a var)?
Christopher McCormack
@cmccormack
Apr 17 2017 03:25
@jroman123 I'm not certain what you mean by 0,1,2
Julio Roman
@jroman123
Apr 17 2017 03:25
@cmccormack So it will replaced on the element all the values with-1 to 1 and 0,1,2.... to all zeroes? [-1, 0, -1, 1, 2]
to [1, 0, 1, 0, 0]?
Christopher McCormack
@cmccormack
Apr 17 2017 03:26
my understanding is these are strings being broken into characters, but yes they should be turned into something similar to the latter array
Julio Roman
@jroman123
Apr 17 2017 03:26
@cmccormack well does the indexOf() method returns -1 if is no match and the index position if their is a match?
Christopher McCormack
@cmccormack
Apr 17 2017 03:26
yes
which makes me wonder why you didn't just loop through one of the array's, and return false if any check was -1, else return true if no check was -1
Julio Roman
@jroman123
Apr 17 2017 03:28
so what I could get from your explanation is that the statement is design to replace those values into true and false by switching 1 on no match and zero on the matched?
Christopher McCormack
@cmccormack
Apr 17 2017 03:28
@jroman123 yeah that's about it
it could have been swapped to have 0 on no match and then compared === 1 I guess
Julio Roman
@jroman123
Apr 17 2017 03:30
Well to be sincere I got this code online, so I took all day to day to broke it down and make my own little research summery and I got stuck in this part trying to figure out what it is virtually going on the indexOf method.
true......
rmanaswi
@rmanaswi
Apr 17 2017 03:30

var count = 0;

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

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
cc(3); cc(7); cc('Q');cc(8);cc('A');
where am I doing wrong?

Julio Roman
@jroman123
Apr 17 2017 03:30
@cmccormack thanks
Christopher McCormack
@cmccormack
Apr 17 2017 03:30
@jroman123 np
Nahuel Ovejero
@NahuelOvejero
Apr 17 2017 03:30
@rmanaswi you need to use the globar var, you need to count multiple cards, not just 1
Julio Roman
@jroman123
Apr 17 2017 03:31
@cmccormack thanks
CamperBot
@camperbot
Apr 17 2017 03:31
jroman123 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 407 | @cmccormack |http://www.freecodecamp.com/cmccormack
rmanaswi
@rmanaswi
Apr 17 2017 03:31
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold" only this case is not able to pass
Julio Roman
@jroman123
Apr 17 2017 03:31
there you go..lol
Christopher McCormack
@cmccormack
Apr 17 2017 03:32
haha thanks
Joseph
@revisualize
Apr 17 2017 03:32
@rmanaswi You're not returning the correct thing.
@rmanaswi Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
rmanaswi
@rmanaswi
Apr 17 2017 03:32
Whats the correct way
m not getting it
Joseph
@revisualize
Apr 17 2017 03:33
@rmanaswi You haven't written your case statements correctly. Nor have you written a condition for the value of count.
@rmanaswi
var Animal = 'Giraffe';
switch (Animal) {
  case 'Cow':
  case 'Giraffe':
  case 'Dog':
  case 'Pig':
    console.log('This animal will go on Noah\'s Ark.');
    break;
  case 'Dinosaur':
  default:
    console.log('This animal will not.');
}
The other example wasn't that good. I switched it.
rmanaswi
@rmanaswi
Apr 17 2017 03:34
Ok ..Let me try :)
Joseph
@revisualize
Apr 17 2017 03:34
@rmanaswi So, you need to create switch cases for the value of the cards.
Those switch case statements need to either add 1 or subtract 1 from the global count variable.
Augusto
@hackedWifi
Apr 17 2017 03:45
Hello everyone. Happy easter. Anyways can anyone tell me why this truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) should return "A-tisket a-tasket A green and yellow basket". should be return without the eliphis
Christopher McCormack
@cmccormack
Apr 17 2017 03:50
@hackedWifi I'm assuming the function will add ellipses if the second argument is less than the length of the initial string?
so if the first string and the second string's length are the same, it would return the entire first string, correct?
Augusto
@hackedWifi
Apr 17 2017 03:51

Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.

those are the instruction ^^
Christopher McCormack
@cmccormack
Apr 17 2017 03:52
What exactly is your question? Your first question sounds like you are asking why the function does exactly what the instructions say it should
Truncate a string (first argument) if it is longer than the given maximum string length
Augusto
@hackedWifi
Apr 17 2017 03:53
Sorry i was not paying attention to very first sentence. Please disregard my input.
Christopher McCormack
@cmccormack
Apr 17 2017 03:54
no worries
playingwithinfinity
@playingwithinfinity
Apr 17 2017 03:55
In these 2 program files, what does callback(null, list) do?
var fs = require('fs')
var path = require('path')
var myModule = require('./myFile')

var dir = process.argv[2]
var fileStr = process.argv[3]

myModule(dir, fileStr, function(err,list){
  if(err) return console.error(err)

  list.forEach(function(file){
    console.log(file)
  })
})
var fs = require('fs');
var path = require('path');

module.exports = function(dir, filter, callback){
    fs.readdir(dir, function(err, list){
        if(err){
            return callback(err);
        }

        list = list.filter(function(file){
            return path.extname(file) === '.' + filter; 
        });
        callback(null, list); 
    });
};
Christopher McCormack
@cmccormack
Apr 17 2017 03:57
looks like it tells whichever function called module.exports that there is no error and the second argument is the list
Moisés Man
@moigithub
Apr 17 2017 03:57
a callback is just a function
myModule(dir, fileStr, function(err,list){
by "convention" u pass err as first parameter
Christopher McCormack
@cmccormack
Apr 17 2017 03:58
in this case, the callback is a function that was sent to the module.exports as an argument
playingwithinfinity
@playingwithinfinity
Apr 17 2017 04:00
I see
Kevin0920
@Kevin0920
Apr 17 2017 04:03
hi anyone can help me for this
result+= "My "+myAdjective+"
result+= "My "+myAdjective+" "+myNoun+" "+myVerb+" very "+myAdverb+".";

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

// Your code above this line
return result;
}

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

this is the whole codes list
jhobotuck
@jhobotuck
Apr 17 2017 04:04
@Kevin0920 Place the +'s outside the string
Kevin0920
@Kevin0920
Apr 17 2017 04:05
my question is why we need to us "+myNoun+"
why do we need + around the variable
Christopher McCormack
@cmccormack
Apr 17 2017 04:06
@Kevin0920 you just don't have spaces
@Kevin0920 the plus is both addition and concatenation, in this case concatenation
add spaces around the + and it will make a bit more sense
result+= "My " + myAdjective + " " + myNoun + " " + myVerb + " very " + myAdverb + ".";
Kevin0920
@Kevin0920
Apr 17 2017 04:08
@cmccormack thanks
CamperBot
@camperbot
Apr 17 2017 04:08
kevin0920 sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 408 | @cmccormack |http://www.freecodecamp.com/cmccormack
Kevin0920
@Kevin0920
Apr 17 2017 04:08
I thought it is just a certain way especially for variable
now I got thanks
Christopher McCormack
@cmccormack
Apr 17 2017 04:08
it does look like that without the extra padding :D
Kevin0920
@Kevin0920
Apr 17 2017 04:12
i have one more question

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

// Your code above this line
return result;
}

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

the same codes here
var result = "";
then we write result += ...........
Christopher McCormack
@cmccormack
Apr 17 2017 04:13
yes
Kevin0920
@Kevin0920
Apr 17 2017 04:13
it stands for that we just change the var again to a new value?
Christopher McCormack
@cmccormack
Apr 17 2017 04:13
basically
var result declares a new variable result
then it's assigned an empty string value ""
then we append to that empty string with our madlib
Kevin0920
@Kevin0920
Apr 17 2017 04:14
because we just sort of concatenating all the arguments of the first variable
Christopher McCormack
@cmccormack
Apr 17 2017 04:14
but if they hadn't said not to touch the code above that line, you could have also done var result = "My " + myAdjective + " " + myNoun + " " + myVerb + " very " + myAdverb + ".";
or even return "My " + myAdjective + " " + myNoun + " " + myVerb + " very " + myAdverb + ".";
@Kevin0920 almost, you are concatenating all of the arguments then appending to result
result being an empty string at first
Kevin0920
@Kevin0920
Apr 17 2017 04:16
we declare the new var as result
Christopher McCormack
@cmccormack
Apr 17 2017 04:17
right
Kevin0920
@Kevin0920
Apr 17 2017 04:17
then we write: result += "my " + so on
this result is the new variable we declare to result +=
Christopher McCormack
@cmccormack
Apr 17 2017 04:18
yup the += could be considered appending (although strings are immutable so technically you're concatenating several strings into a single new string then assigning to result)
it would be a new string that we assign to result
result is the variable, and the = or += etc.. are assigning a value to a variable
Kevin0920
@Kevin0920
Apr 17 2017 04:20
wa hoooo so clear
awesome
Christopher McCormack
@cmccormack
Apr 17 2017 04:21
sounds like you understood I just wanted to make sure the terminology was used in the right places :D
micojay020
@micojay020
Apr 17 2017 04:21
can someone help me?
Kevin0920
@Kevin0920
Apr 17 2017 04:21
hahaha you are so gooooooooood
micojay020
@micojay020
Apr 17 2017 04:21
i need help on Return Early Pattern for Functions
anyone?
Christopher McCormack
@cmccormack
Apr 17 2017 04:21
@micojay020 sure ask away
rmanaswi
@rmanaswi
Apr 17 2017 04:22
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
dis two r not working now

var count = 0;

function cc(card) {
// Only change code below this line
switch(card){
case 2:
case 3:
case 4:
case 5:
case 6:
count++;

 return count +" Bet";
case 7:
case 8: 
case 9: 
   return count +" Hold";
case 10:
case 'J':
case 'Q':
case  'K':
case  'A':
  count --;
 return count+" Hold";
case 3:
case 7:
case 'Q':
case 8:
  case 'A': 
  count--;
 return count+" Hold";

case 2:
case 'J':
case 9:
case 2:
 case 7: 
  count ++;
return count +" Bet";

case 2:
case 2:
case 10:

return count +" Bet";

case 3:
  case 2:
  case 'A':
case 10:
  case 'K': 
  count--;
  return count +" Hold";

}
return count;

// Only change code above this line
}

// Add/remove calls to test your function.
// Note: Only the last will display
//cc(3); cc(7); cc('Q');cc(8);cc('A');
//cc(2); cc(3); cc(4);cc(5);cc(6);
//cc(7);cc(8);cc(9);
cc(2);cc('J');cc (9);cc( 2);cc(7);
cc(2);cc(2);cc(10);

what i did wrong dis tym?
:worried:
Joseph
@revisualize
Apr 17 2017 04:24
@rmanaswi Okay.
@rmanaswi You have a lot wrong.
rmanaswi
@rmanaswi
Apr 17 2017 04:25
:worried:
Joseph
@revisualize
Apr 17 2017 04:25
@rmanaswi Look.
micojay020
@micojay020
Apr 17 2017 04:25
i nee help on there activity
i need help on Return Early Pattern for Functions
Christopher McCormack
@cmccormack
Apr 17 2017 04:26
@micojay020 what's your question?
micojay020
@micojay020
Apr 17 2017 04:26
on doing it
Christopher McCormack
@cmccormack
Apr 17 2017 04:26
on which part in particular?
Joseph
@revisualize
Apr 17 2017 04:26
@rmanaswi
function cc(card) {
// Only change code below this line
   switch(card){
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
            count++;
            break;
      case 10:
      case 'J':
      case 'Q':
      case 'K':
....
@rmanaswi The switch is JUST supposed to add one or subtract one from the global.
@rmanaswi There should be NO return in the switch.
Christopher McCormack
@cmccormack
Apr 17 2017 04:27
@micojay020 try to show us what you've done so far and tell us which part you need assistance with
rmanaswi
@rmanaswi
Apr 17 2017 04:27
How will he show "1 Bet" on console
Joseph
@revisualize
Apr 17 2017 04:27
@rmanaswi Counting Cards is a challenge where your function will receive a card parameter. You're supposed to increment or decrement the global count variable according to the card's value
If the value of the card parameter is 2, 3, 4, 5 or 6 you need to increment the global variable count.
If the value of the card parameter is 10, 'J', 'Q', 'K' or 'A' you need to decrement the global variable count.
...
Then the function will return a string with the current count and the string "Bet" if the count is positive, or "Hold" if the count is zero or negative.
The current count and the player's decision ("Bet" or "Hold") should be separated by a single space.
Christopher McCormack
@cmccormack
Apr 17 2017 04:27
did you read the instructions closely?
Joseph
@revisualize
Apr 17 2017 04:27
@rmanaswi You need to create a return for that.
@rmanaswi How do you concatenate a variable with a string?
rmanaswi
@rmanaswi
Apr 17 2017 04:28
should i apply if/else
Joseph
@revisualize
Apr 17 2017 04:28
YES!
rmanaswi
@rmanaswi
Apr 17 2017 04:28
ok
let me try :)
Joseph
@revisualize
Apr 17 2017 04:29
@rmanaswi You'll need to finish the switch.
micojay020
@micojay020
Apr 17 2017 04:29

var code = "function abTest(a, b) {
// Only change code below this line

// Only change code above this line

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

// Change values below to test your code
abTest(2,2);";

Joseph
@revisualize
Apr 17 2017 04:29
@rmanaswi You should have a swtich block. ... Then after that. An else block.
@micojay020 What is var code = "?
micojay020
@micojay020
Apr 17 2017 04:30
how do printscreen my code?
Christopher McCormack
@cmccormack
Apr 17 2017 04:31
you can copy/paste it directly in here, surround it with ``` and it will print pretty
Joseph
@revisualize
Apr 17 2017 04:31

If you are posting code that is large, Please use Gist - https://gist.github.com/ then please paste the link here.
...
How to do code block format: ..... PLEASE try with a small block of code before you try to make a bigger one.
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code
```js [SHIFT+ENTER]
// your code here
``` [CTRL+ENTER or CMD+ENTER to send]
Please do not confuse `s with 's.
Also note that the ```s need to each be on their own lines
The ` key can usually be found on most keyboards up next to the 1 key.
If you hit SHIFT+` it will give you the ~.
Example:
```
code
```
...
Output:

var code = undefined;

...
You can also do inline code formatting:
A string of text with a `variable` or `other bit of code`.
Output:
A string of text with a variable or other bit of code.

micojay020
@micojay020
Apr 17 2017 04:31

``
// Initialize these three variables
var a = 5;
var b = 10;
var c = "I am a";

// Do not change code below this line

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

``

jhobotuck
@jhobotuck
Apr 17 2017 04:31
I'm having trouble with looping through nested objects. I have two if statements but I believe my code does not loop through them.

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


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

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

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

      if (contacts[i].hasOwnProperty(prop)){
          return contacts[i][prop];

        } else {
          return "No such property";
        }

    } else {
       return "No such contact";
     }
  }


// Only change code above this line
}

// Change these values to test your function
lookUpProfile ("Kristian", "lastName");
Christopher McCormack
@cmccormack
Apr 17 2017 04:32
@micojay020 use 3 backticks and you should be good
you can also edit your own comments here
jhobotuck
@jhobotuck
Apr 17 2017 04:32
The current lookUpProfile returns "No such contact"
micojay020
@micojay020
Apr 17 2017 04:32
@cmccormack 3 in front and end?
Christopher McCormack
@cmccormack
Apr 17 2017 04:32
yes
micojay020
@micojay020
Apr 17 2017 04:32
// Initialize these three variables
var a = 5;
var b = 10;
var c = "I am a";

// Do not change code below this line

a = a + 1;
b = b + 5;
c = c + " String!";
its not thise one
Joseph
@revisualize
Apr 17 2017 04:33
@jhobotuck The return statement ends function execution and specifies a value to be returned to the function caller.
Syntax
return [[expression]];
expression
The expression to return. If omitted, undefined is returned instead.
micojay020
@micojay020
Apr 17 2017 04:33
thise on
this*
Joseph
@revisualize
Apr 17 2017 04:33

@jhobotuck

for ( ..... ) {
    if (evaluation) {
        return "truth";
    } else {
        return "lies";
    }
 }

This exact loop.. Does not loop.

micojay020
@micojay020
Apr 17 2017 04:33
// Setup
function abTest(a, b) {
  // Only change code below this line



  // Only change code above this line

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

// Change values below to test your code
abTest(2,2);
Makrand R
@makrandr
Apr 17 2017 04:34
Anybody up?
Christopher McCormack
@cmccormack
Apr 17 2017 04:34
@micojay020 so the instructions are to Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined.
@micojay020 you should have done conditionals by now, so set up your conditionals to return undefined if a or b are less than 0
@micojay020 there are a few ways to do that, so give some a try and let us know if you have issues
@makrandr yup only 21:30 here
micojay020
@micojay020
Apr 17 2017 04:36
do i use console.log?
Christopher McCormack
@cmccormack
Apr 17 2017 04:36
nope, unless you want to test some output in the console
which is a great way to learn, so when you're having issues, you can console.log different pieces of code to see what they might equal or return, very helpful
Makrand R
@makrandr
Apr 17 2017 04:43
@cmccormack I need some help with my UI in
http://codepen.io/makrandr/full/qrzMxJ
The image doesn't seem to fit the page height and width
Christopher McCormack
@cmccormack
Apr 17 2017 04:45
you want it to stretch both ways?
Ugh.
@gshhh
Apr 17 2017 04:46
Hello, I'm doing the Exact Change problem. What's the best way to sort my cash drawer?
Makrand R
@makrandr
Apr 17 2017 04:46
@cmccormack well it doesn't fit the bottom
Christopher McCormack
@cmccormack
Apr 17 2017 04:47
@makrandr try something like this:
body { 
  background-color: #000;
  background: url("[URL]") no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  width: 100%;
}
best I can do right now, sorry :)
Makrand R
@makrandr
Apr 17 2017 04:48
@cmccormack thanks let me try it out. :smile: Earlier it was working fine tho but apparently when I changed the bootstrap version, things kinda messed up.
CamperBot
@camperbot
Apr 17 2017 04:48
makrandr sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @cmccormack |http://www.freecodecamp.com/cmccormack
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 04:50
@makrandr you just need to change teh background size to 100%
i mean the postition center center
@makrandr
Makrand R
@makrandr
Apr 17 2017 04:54
@HeebieGeeBee Thanks! that worked.
CamperBot
@camperbot
Apr 17 2017 04:54
makrandr sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1352 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Makrand R
@makrandr
Apr 17 2017 04:55
and also on initial load the transition doesn't seem to be proper smooth. Is that because the images are loading from the source site? @HeebieGeeBee
Joseph
@revisualize
Apr 17 2017 04:57
@jhobotuck ???
Ogundele Olumide
@Lumexralph
Apr 17 2017 04:58
@HeebieGeeBee Bro!
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 04:58
@makrandr dunno
@Lumexralph yo hows you?
Ogundele Olumide
@Lumexralph
Apr 17 2017 04:59
@HeebieGeeBee me is great!.... you?
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 04:59
@Lumexralph cool
im alright
feeling hungry
Christopher McCormack
@cmccormack
Apr 17 2017 05:00
@makrandr I used the following and the transitions for your quote machine looked good:
body { 
  background-color: #000;
  background: no-repeat center center fixed;
  -webkit-transition: background-image 0.4s ease-in-out;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  width: 100%;
}
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:00
@HeebieGeeBee good you don't like eating out...so that shouldn't be difficult I think
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:00
@Lumexralph its not that i dont like eating out
just dont the oppertunity to
its expensive
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:01
@HeebieGeeBee hmm.... i prefer to cook 90% of the time
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:03
@Lumexralph cool, i do like cooking too
and im pretty good at it ;P
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:03
@HeebieGeeBee yeah..... can even do it better than some ladies
Christopher McCormack
@cmccormack
Apr 17 2017 05:04
I wish I could go back and tell my 20 yo self to learn to cook asap... Saves so much money, healthier than going out, and becomes a lot more fun when you get better at it
Annestezia
@Annestezia
Apr 17 2017 05:05
Hello , can anyone explain what i'm doing wrong here? this returns true...
function mutation(arr) {
  var word1, word2;

  word1 = arr[0].toLowerCase();
  word2 = arr[1].toLowerCase();

  for(var  i=0; i<word2.length; i++){
     return word1.indexOf(word2[i])!==-1;
  }
}

mutation(["hello", "hey"]);
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:05
@cmccormack its not that hard and can always learn
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:05
@cmccormack true..... just can be time consuming
Christopher McCormack
@cmccormack
Apr 17 2017 05:05
oh I learned, just much later than I should have
now I love it
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:06
@Annestezia you need to just have a false return inside the loop and a true return outside it
@cmccormack oh ok cool
@Annestezia youre only getting on eiteration of the loop at the moment
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:06
@cmccormack main reasons I stick to cooking my food is cos it's expensive and I worry more on the hygiene(health) part
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:07
when a function hits a return it ends the fucntion
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:07
@cmccormack hmmm..... I'm still learning to prepare more dishes when I can
Christopher McCormack
@cmccormack
Apr 17 2017 05:08
nothing better than trying and succeeding at something new
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:08
i like spicy food, grown up with indian food all my life, but the french arent so keen, and even when there is a french restaurant they have to tone it down for the french pallette
french restaurant for indian food that is
im kinda addicted to chillis
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:09
@Annestezia it'll be easier if you check if the characters in word2 doesn't exist in word1, you can return false and then return true out of the loop block, that means all the characters exist
@HeebieGeeBee :smile:
Christopher McCormack
@cmccormack
Apr 17 2017 05:10
@HeebieGeeBee same, I live in the Southwest US, that's our staple haha
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:10
@cmccormack very nice
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:10
Hi guys, I have a React Redux question. I show/hide a component depends on a state. When the component is shown (after it was hidden), react seems to render a new component, but still keep the old component and the old state, so i have like two states and components and a race condition.
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:10
you must be able to get shitloads of different varieties too
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:10
Has anyone faced the same issue?
Christopher McCormack
@cmccormack
Apr 17 2017 05:11
yeah it's very popular for tourists haha
@kuriakinzeng do you have an example of how you're hiding the Component?
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:12
<div className="App">
        {
          this.props.isRunning ?
            (
              <div className="container">
                <h3>Rogue Game</h3>
                <Controls />
                <hr />
                <World />
              </div>
            )
            : (this.props.isWon ? this.renderEndGame("YOU WON") : this.renderEndGame("YOU LOST"))
        }
      </div>
I hide <World /> when the game is won/lost
until the player presses Restart
Annestezia
@Annestezia
Apr 17 2017 05:13
@HeebieGeeBee ok thank you
CamperBot
@camperbot
Apr 17 2017 05:13
annestezia sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1353 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Keon Samuel
@keonsam
Apr 17 2017 05:14
who else have been drinking?
Annestezia
@Annestezia
Apr 17 2017 05:14
@Lumexralph thanx .. keep on trying )
CamperBot
@camperbot
Apr 17 2017 05:14
annestezia sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1525 | @lumexralph |http://www.freecodecamp.com/lumexralph
Christopher McCormack
@cmccormack
Apr 17 2017 05:15
@kuriakinzeng I don't see how you're hiding world in this code though
can you post that relevent code?
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:16
ok wait
In reducer:
[actions.PLAYER_LOST]: (state, action) => {
        return {...state, isRunning: false}
    },
Christopher McCormack
@cmccormack
Apr 17 2017 05:16
maybe you can just create a state flag and do something like {this.state.showWorld && <World />, keeping track of the state somewhere
Augusto
@hackedWifi
Apr 17 2017 05:17
can anyone give a clue as to why this code doesnt print the rest of arr?

'function chunkArrayInGroups(arr, size) {
// Break it up.
var count = 0;
var multi =[];
// var split = [];
// var concat = [];
while(count < arr.length){
if(count % size === 0){
multi.push(arr.slice(0,size));
}

count++;

}

// split = arr.slice(size);
// concat.push(multi, split);
// return multi;

return multi;
}'

Ross
@rossauusa
Apr 17 2017 05:18
On - Make Object Properties Private I get a warning "did you mean to return conditional instead of an assignment and my code passes with a result of 0 but i still dont fully understand...can anyone explain a little further
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:18
@cmccormack I think the logic is the same
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:18
@hackedWifi because your slice doesn't change multi.push(arr.slice(0,size));
Ross
@rossauusa
Apr 17 2017 05:19
var Car = function() {
  // this is a private variable
  var speed = 10;

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

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

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

var Bike = function() {

  // Only change code below this line.
var gear=0;
  this.setGear=function(value){return gear=value;};
  this.getGear=function(){return gear;};

};

var myCar = new Car();

var myBike = new Bike();
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:19
I pass in the state to the props using
const mapStateToProps = (state) => ({isRunning: state.isRunning})
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:19
@hackedWifi cos at every iteration you slice starting at 0 and endInedx size which is constant
@rossauusa setGear method is just to assign value to gear... not to return
Ross
@rossauusa
Apr 17 2017 05:21
@Lumexralph if i dont put {return gear=value;}
@Lumexralph it doesnt work ??
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:21
@rossauusa gear = value;
Christopher McCormack
@cmccormack
Apr 17 2017 05:23
@kuriakinzeng are you certain you're not looping your state by implementing another ternary in the failure condition?
Ross
@rossauusa
Apr 17 2017 05:23
@Lumexralph I dont understand?
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:24
@rossauusa that's what your setGear method should do
Ross
@rossauusa
Apr 17 2017 05:26
@Lumexralph so ```
this.setGear=function(gear=value)};
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:26
@rossauusa na, not that way, or you want to use default parameters :smile:
grantknaver
@grantknaver
Apr 17 2017 05:26
@grantknaver
does anyone know how to use an id for a link tag, and have the targeted section appear at the top the screen?
by default a targeted areas populates mid screen
im super stumped any ideas
Ross
@rossauusa
Apr 17 2017 05:27
@Lumexralph can you show me what you mean as mine passes but i dont think itsd right
Ogundele Olumide
@Lumexralph
Apr 17 2017 05:27
@rossauusa
this.setGear=function(value)  {
       gear = value;
};
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:27
@cmccormack let me try something simpler
Ross
@rossauusa
Apr 17 2017 05:29
@Lumexralph ok thanks
CamperBot
@camperbot
Apr 17 2017 05:29
rossauusa sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1526 | @lumexralph |http://www.freecodecamp.com/lumexralph
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:29
return (
    <div className="App">
        {
          this.props.isRunning && (
              <div className="container">
                <h3>Rogue Game</h3>
                <Controls />
                <hr />
                <World />
              </div>
            )
        }
      </div>
     )
grantknaver
@grantknaver
Apr 17 2017 05:32
any ideas
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:32
@cmccormack still happens
The problem seems to be that the component still lives after I hide it
And when I try to redisplay it (i.e. this.props.isRunning turns true), react chooses to render a new component?
Christopher McCormack
@cmccormack
Apr 17 2017 05:33
Do you have the react tools for the developer tools in your browser? That may help
I don't think I have enough background with React to help you though, sorry
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:34
let me install that now
Christopher McCormack
@cmccormack
Apr 17 2017 05:35
I'm out for the night but good luck!
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:35
@grantknaver so you want to be able to have an elements available in something like a string that you can utilize in js?
Kuriakin Zeng
@kuriakinzeng
Apr 17 2017 05:35
@cmccormack you're taking about the chrome extension?
thanks @cmccormack
CamperBot
@camperbot
Apr 17 2017 05:36
kuriakinzeng sends brownie points to @cmccormack :sparkles: :thumbsup: :sparkles:
:cookie: 410 | @cmccormack |http://www.freecodecamp.com/cmccormack
grantknaver
@grantknaver
Apr 17 2017 05:36
na @HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:36
@grantknaver its not clear what you want to be able to do
grantknaver
@grantknaver
Apr 17 2017 05:36
what I am trying to do is use an id in a link tag to take me to a certain section of the page
, but that section appears in the middle of the page once I click on the link
I am trying to get the targeted section to appear at the top of the page. Do you have any idea how to do that? I have been looking for awhile to avail
hopefully that is more clear
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:39
@grantknaver so just using #plustheid name at the end of the url doesnt work?
@grantknaver well that page.html#id thing
grantknaver
@grantknaver
Apr 17 2017 05:40
Ya. I takes me to the section, but that section is in the middle of the page
here I will show you my code
                  <ul id="dropDown">
                     <li id="mainTab" class="navB"><a href="#main">Main</a></li>
                     <li id="portfolioTab" class="navB"><a href="#portfolio">Portfolio</a></li>
                     <li id="contactTab" class="navB"><a href="#contact">Contact</a></li>
                  </ul>
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:45
@grantknaver not realy sure why it shows it in the middle of the page
grantknaver
@grantknaver
Apr 17 2017 05:46
damn ok
thank man
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:46
i thought they always put it at the top
i take it there is room above the id's you're linking too
@grantknaver i mean underneath
so the the page can actually scroll up
grantknaver
@grantknaver
Apr 17 2017 05:48
ya
the link just takes you to mid way through the targeted section
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:49
is this in a codepen at all?
grantknaver
@grantknaver
Apr 17 2017 05:50
na all local sorry man
here I will drop into a codepen
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:52
@grantknaver the elements dont have any particular margin or anything do they?
grantknaver
@grantknaver
Apr 17 2017 05:54
here is code
I dropped it into a codepen so it is slightly different, but not really
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:55
@grantknaver i think its cus there isnt enough room underneath the elements so it can scroll the page up that far
Roger Chavez
@RogChav
Apr 17 2017 05:55
has anyone finished the "Basic Algorithm" Seek and Destroy? If so may I please see a copy of your code?
grantknaver
@grantknaver
Apr 17 2017 05:56
hmmm ok
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:58
@grantknaver https://codepen.io/Geeheeb/pen/wdaXeZ you see when i dump a load of text at the bottom
it moves it up further
grantknaver
@grantknaver
Apr 17 2017 05:59
a little bit
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 05:59
@grantknaver by the way it also moves it to the top behind your nav bar, so would have to sort that out
grantknaver
@grantknaver
Apr 17 2017 05:59
that is error occuring in codepen when I dropped it in
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:01
@grantknaver the page cant scroll down further than the bottom of the page
but i see youre using jquery too
so maybe you can use their scroll to method instead of the href
cant remember if scroll to is jquery
they have something like that though
grantknaver
@grantknaver
Apr 17 2017 06:02
checking now
nope wont work dang
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:06
@grantknaver really think it has to be a bigger page
grantknaver
@grantknaver
Apr 17 2017 06:08
I just linked to other id's to get the desired outcome, it works
thanks man
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:08
@grantknaver cool
Flavio Jose
@Flaviofjr
Apr 17 2017 06:14
Hi everyone
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:14
@Flaviofjr hi
Flavio Jose
@Flaviofjr
Apr 17 2017 06:15
I would like to know if someone can help me with something in javascript
@HeebieGeeBee Hi
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:15
i can attempt to
Flavio Jose
@Flaviofjr
Apr 17 2017 06:15
I got stucked
Ok
I am doing an exercise and it says: "Use bracket notation to find the last character in the lastName variable."
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:16
ok
can you paste your code and say what you dont understand about it?
Flavio Jose
@Flaviofjr
Apr 17 2017 06:17
I have the following code:
var lastName = "Lovelace";
var lastLetterOfLastName = lastName[lastName.lenght - 1];
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:17
length*
Flavio Jose
@Flaviofjr
Apr 17 2017 06:17
Ohhhh yeah!
Hahahahaha
Thanks!
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:18
youre welcome
Miguel Vasquez
@mivasquez386
Apr 17 2017 06:21
:smile:
David Miller
@DavidMillerFL
Apr 17 2017 06:24
Anyone want to help me? I'm stuck creating a MadLib in java.
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:24
what you having a problem with
and btw java is different to javascript
David Miller
@DavidMillerFL
Apr 17 2017 06:25
Yes, thanks my mistake.
I haven't learned gotten to java yet, just javascript. Okay so it's instructing me to... create a madlib... hang on, here's the section I'm on.
The truth is I have absolutely no idea what to do, I even copied and pasted the solution at the bottom into my JS and the only thing I get the console to read back to me is
"TypeError: n.write is not a function."
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:27
what did you have in your code
paste it
David Miller
@DavidMillerFL
Apr 17 2017 06:27
Okay

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

// Your code above this line

return result;
}

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

HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:28
@DavidMillerFL refresh the browser page and run the test again
David Miller
@DavidMillerFL
Apr 17 2017 06:28
Alright, good idea. one sec.
Well that's infuriating
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:29
but you should really try and understand what this function is doing
Roger Chavez
@RogChav
Apr 17 2017 06:29
has anyone finished the "Basic Algorithm" Seek and Destroy? If so may I please see a copy of your code?
David Miller
@DavidMillerFL
Apr 17 2017 06:30
It worked. Now that I know the code is correct i'll try to read it and understand what's happening here. Thank you so much @HeebieGeeBee
CamperBot
@camperbot
Apr 17 2017 06:30
davidmillerfl sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1354 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
David Miller
@DavidMillerFL
Apr 17 2017 06:30
Wish I would have gotten it without having to go to the website and copied :( Oh well, I've done it cheat free thus far.
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:30
@Rochar88 if you search google there are solutions for all the challenges
but thats not always the best way to learn
@DavidMillerFL try asking here for help before just going to copy a solution
ppl will try and help you understand and get through the challenges
David Miller
@DavidMillerFL
Apr 17 2017 06:33
I'll keep that in mind, what's the name of this chat app again? I need to install it on this machine. I'm using a different one since I started.
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:33
gitter
David Miller
@DavidMillerFL
Apr 17 2017 06:33
Thank you. brb.
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:33
but you can always get to it clicking on the help button in challenge details
Roger Chavez
@RogChav
Apr 17 2017 06:38
Thanks @DavidMillerFL I have my code working, I just don't have a way to to filter the arguments past arguments[0] into the first filter, so if i saw an example which I can't find anywhere it would help me understand it anyhow because if I manually input the arguments my code works.
CamperBot
@camperbot
Apr 17 2017 06:38
:cookie: 157 | @davidmillerfl |http://www.freecodecamp.com/davidmillerfl
rochar88 sends brownie points to @davidmillerfl :sparkles: :thumbsup: :sparkles:
David Miller
@DavidMillerFL
Apr 17 2017 06:38
That’s how I was getting to it, but it doesn’t notify me of mentions. So check out this bit of info inside the instructions area of FCC @HeebieGeeBee
Roger Chavez
@RogChav
Apr 17 2017 06:38
into the first function I mean**
David Miller
@DavidMillerFL
Apr 17 2017 06:39

wordBlanks("cat", "little", "hit", "slowly") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).

The words cat, little, hit, and slowly are nowhere in my code. yet this recieved a green checkmark.

HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:40
@DavidMillerFL the testing makes their own calls to the function passing in the different arguments
David Miller
@DavidMillerFL
Apr 17 2017 06:40
This was causing me additional confusion, I thought I was meant to add these strings / variables like cat, little, hit, etc… meanwhile the code works without them.
The testing… makes their own… calls...
Huh...
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:41
wordBlanks("cat", "little", "hit", "slowly") this is a function call
David Miller
@DavidMillerFL
Apr 17 2017 06:41
Ok… does that mean these words are like triggers for a ‘’function’' ?
Abdulla
@abdull0
Apr 17 2017 06:42
Hi, Im trying to complete the arguments optional challenge and I can't seem to get it working for one case atleast
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:42
@Rochar88 the arguments abject has a scope local to the function its called in so if youre calling arguments inside the filters callback function it will try to use the arguments object of that callback function
Abdulla
@abdull0
Apr 17 2017 06:42
it returns the closure function as a string
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:43
@DavidMillerFL they are what makes the function operate its process
David Miller
@DavidMillerFL
Apr 17 2017 06:43
oh my god I’m such an idiot I thought WordBlanks was a user-written variable thing, I had no idea it was a built in feature of Java
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:43
and the words in the brackets are the arguments the function is being called with
David Miller
@DavidMillerFL
Apr 17 2017 06:43
Ok with this in mind let me re-read it.
Javascript*
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:44
no wordblanks is the function youre meant to be writing
David Miller
@DavidMillerFL
Apr 17 2017 06:44
facepalm
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:44
its not a built in function native to javascript
David Miller
@DavidMillerFL
Apr 17 2017 06:46
I may or may not be having a difficult time understanding the difference between a function and a variable
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:47
function example(num) { //this is a  function that has been written and called 'example' and has a parameter called 'num'
      return num + 5;      //this functions purpose is to return the sum of the num plus 5
}

example(2) // this is the example function being called with an argument of 2, so this function call will return the value of 7
example(3) // this will return 8
example(20) // this will return 25
@DavidMillerFL
David Miller
@DavidMillerFL
Apr 17 2017 06:48
Reading @HeebieGeeBee

Alright so ...
"This functions purpose is to return the sum of the num plus 5”

‘’return’’ the sum ?

HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:49
the result of num and 5 added together @DavidMillerFL
David Miller
@DavidMillerFL
Apr 17 2017 06:50
Right but ‘’return’’ it.
Return it where?
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:50
var testVariable = example(5);
Mushtaq
@mahalepoto
Apr 17 2017 06:50
Hi Good people......Got one question....Can you call a function simultaneously, more than one time, in same code flow.....Like one at the end of count card i.e cc(2);cc(9); cc(3); cc(7); cc('K'); cc('A');
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:50
so this would mean testVariable would have the value of 10
@DavidMillerFL
because the example function returns a value
@mahalepoto yes
Abdulla
@abdull0
Apr 17 2017 06:52
@mahalepoto I believe so
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:52
@abdull0 can you post your code and say the problem you have
Mushtaq
@mahalepoto
Apr 17 2017 06:52
Can you please tell me how that works, if that is OK... @abdull0 @HeebieGeeBee
Abdulla
@abdull0
Apr 17 2017 06:52

function addTogether(x){

if(typeof(x) == 'number' && typeof(arguments[1]) == 'number'){
return x+arguments[1];
}
else{
return undefined;
}

return function(y){

      if(typeof(x) == 'number' && typeof(y) == 'number' ){
        return x+y;
      }
      else{

        return undefined;
      }
  };

}

addTogether(12, "http://bit.ly/IqT6zt");

HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:52
@mahalepoto well javascript is a synchronous by nature
so it wouldnt be a similtanious
but yeah you can call fucntions multiple times
David Miller
@DavidMillerFL
Apr 17 2017 06:53
Hmm… I guess I get that. Kind of.
Abdulla
@abdull0
Apr 17 2017 06:54
I am meant to work with closures but the code returns the second function (the one using the variable y) as a string and does not execute the code
@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:54
@abdull0 hows the function ever going to that second function
Abdulla
@abdull0
Apr 17 2017 06:55
oh sorry I changed some things around, Ill repost
Roger Chavez
@RogChav
Apr 17 2017 06:55
thank you @HeebieGeeBee, I set my arguments to variables and I had Initially had the other function called into the main one, but decided to just move it into the main one (into the filter parenthesis) so that I could reference the variable arguments, it worked!
CamperBot
@camperbot
Apr 17 2017 06:55
rochar88 sends brownie points to @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1355 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
Mushtaq
@mahalepoto
Apr 17 2017 06:55
cheers @HeebieGeeBee
Abdulla
@abdull0
Apr 17 2017 06:56

function addTogether(x){

if(typeof(arguments[1]) !== 'undefined'){
if(typeof(x) == 'number' && typeof(arguments[1]) == 'number'){
return x+arguments[1];
}
else{
return undefined;
}

}

return function(y){

      if(typeof(x) == 'number' && typeof(y) == 'number' ){
        return x+y;
      }
      else{

        return undefined;
      }
  };

}

@HeebieGeeBee
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:57
@abdull0 what does it return?
Abdulla
@abdull0
Apr 17 2017 06:57
@HeebieGeeBee for this particular function call
addTogether("http://bit.ly/IqT6zt");
function(y){
      if(typeof(x) == 'number' && typeof(y) == 'number' ){
        return x+y;
      }
      else{

        return undefined;
      }
  }
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:58
@abdull0 let me run the code sorry hard to read in this format
one sec
David Miller
@DavidMillerFL
Apr 17 2017 06:58
brb
Abdulla
@abdull0
Apr 17 2017 06:58
@HeebieGeeBee cool
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 06:59
@abdull0 what is the y variable meant to be?
Abdulla
@abdull0
Apr 17 2017 06:59
it is meant to be a number
but it can be anything
@HeebieGeeBee i am meant to be finishing the arguments optional challenge
under intermediate algorithm scripting of the front end dev certification, if you need to see the full problem
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:01
@abdull0 well you havent assigned anything to a y variable
Abdulla
@abdull0
Apr 17 2017 07:01
@HeebieGeeBee It is variable, there may be a y variable and there may not be, so I am meant to use a closure to solve this
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:03
function addTogether(x){

if(typeof(arguments[1]) !== 'undefined'){
if(typeof(x) == 'number' && typeof(arguments[1]) == 'number'){
return x+arguments[1];
}
else{
return undefined;
}
}
return helper(x)

function helper(x){
      if(typeof(x) == 'number' && typeof(arguments[1]) == 'number' ){
        return x+arguments[1];
      }
      else{

        return undefined;
      }
  };
}

addTogether("http://bit.ly/IqT6zt");
then think you wanna do something like that
@abdull0 oops
one sec
k made the edits
Abdulla
@abdull0
Apr 17 2017 07:05
@HeebieGeeBee ill try it out!
Amanda
@amandaphoenix
Apr 17 2017 07:06
Hey guys I'm a bit confused about this one https://www.freecodecamp.com/challenges/stand-in-line
I've been staring at it for ages and still can't figure out what it wants me to do
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:06
@abdull0 might be confusing using the x parameter twice for the main function and the helper function
so might want to change that jsut for readability
Abdulla
@abdull0
Apr 17 2017 07:07
@HeebieGeeBee yeah, will do
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:07
but should still work as is
Abdulla
@abdull0
Apr 17 2017 07:07
thanks for all the help!
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:07
@amandaphoenix do you remember what the array methods push pop shift and unshift do?
Amanda
@amandaphoenix
Apr 17 2017 07:07
ah right okay
Nazar
@IsaakNazar
Apr 17 2017 07:08
hi Guys! the code logs only an array, but it should be sum all numbers in a range, where am i wrong?
function sumAll(arr){
   var myArr = arr;
  if ( arr[0] <= arr[1] ){
    return myArr;
  }else{
    return myArr.reverse();
  }
  var sum = myArr.reduce((a, b) => (a + b), 0);
  return sum;
}


console.log(sumAll([1, 4]));
console.log(sumAll([10, 5]));
Amanda
@amandaphoenix
Apr 17 2017 07:08

push = add to the end
pop = remove from the end
shift = remove from beginning
unshift = add to beginning

these words are so unintuitive to me haha

HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:09
@amandaphoenix yeah
but basically you want to use two of the methods for the challenge
@amandaphoenix wanna put item into the end of array and then return an item you remove from the front of the array
@IsaakNazar youre making returns in the if else statements
its never going to get to the reduce variable
Nazar
@IsaakNazar
Apr 17 2017 07:10
@HeebieGeeBee it sholdnt be?
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:11
when a function hits a return it stops the function
@IsaakNazar also youre missing a large part of this challenge to pass it
Nazar
@IsaakNazar
Apr 17 2017 07:12
@HeebieGeeBee which one?
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 07:12
@IsaakNazar where you populate all the numbers between the two values
Funky1234
@Funky1234
Apr 17 2017 07:13
通过关键字 var 定义一个变量 a 并且给它一个初始值 9
Jor
@joreyesl
Apr 17 2017 07:13
@IsaakNazar What is this code for? seems you are trying to find out max/min but you are instead returning an array.
if ( arr[0] <= arr[1] ){
    return myArr;
  }else{
    return myArr.reverse();
  }
Funky1234
@Funky1234
Apr 17 2017 07:14
@joreyesl 通过关键字 var 定义一个变量 a 并且给它一个初始值 9
Nazar
@IsaakNazar
Apr 17 2017 07:14
@joreyesl well, I want 0 index to be smaller than 1 index
Jor
@joreyesl
Apr 17 2017 07:15
@IsaakNazar remove the return part, return will stop function execution and return from the function, the rest of your code will not run after a return
Nazar
@IsaakNazar
Apr 17 2017 07:15
@joreyesl ok
Ogundele Olumide
@Lumexralph
Apr 17 2017 07:18
@joreyesl m :smiling_imp:
Nazar
@IsaakNazar
Apr 17 2017 07:20
@HeebieGeeBee will reduce populate a range between two numbers?
Nazar
@IsaakNazar
Apr 17 2017 07:32
@joreyesl @HeebieGeeBee finally Im done, Thx
CamperBot
@camperbot
Apr 17 2017 07:32
isaaknazar sends brownie points to @joreyesl and @heebiegeebee :sparkles: :thumbsup: :sparkles:
:star2: 1356 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
:cookie: 786 | @joreyesl |http://www.freecodecamp.com/joreyesl
Nazar
@IsaakNazar
Apr 17 2017 07:34
@camperbot thanx bot
CamperBot
@camperbot
Apr 17 2017 07:34
isaaknazar sends brownie points to @camperbot :sparkles: :thumbsup: :sparkles:
:warning: isaaknazar already gave camperbot points
Jor
@joreyesl
Apr 17 2017 07:39
@Lumexralph grandmaster :smiling_imp:
Ogundele Olumide
@Lumexralph
Apr 17 2017 07:50
@joreyesl where's ggm :smiling_imp: ?
Jor
@joreyesl
Apr 17 2017 07:51
@Manish-Giri ggm :smiling_imp:, are you here?
@Lumexralph he must be having his nap ;)
Ogundele Olumide
@Lumexralph
Apr 17 2017 07:55
@joreyesl insomniac ....that'll be good news for me if he's sleeping
Jor
@joreyesl
Apr 17 2017 07:56
@Lumexralph or he doing ggm :smiling_imp: stuff
Ogundele Olumide
@Lumexralph
Apr 17 2017 07:56
@joreyesl seems most of the Gs are enjoying the festive period
Jor
@joreyesl
Apr 17 2017 07:57
ya seems like it
kinda quite today
jacknifey
@jacknifey
Apr 17 2017 08:06

// Declarations
var studLyCapVar;
var properCamelCase;
var titleCaseOver;

// Assignments
STUDLYCAPVAR = 10;
PRoperCAmelCAse = "A String";
tITLEcASEoVER = 9000;

can someone help me out with this ?

Jor
@joreyesl
Apr 17 2017 08:09
@jacknifey you need to change each declaration and assignment to cameCase. That means each variable will start lower case and each word after that will be upper case. Ex;var thisVarIsCamelCase
Nazar
@IsaakNazar
Apr 17 2017 08:22
cbot
CamperBot
@camperbot
Apr 17 2017 08:22
you called?
Nazar
@IsaakNazar
Apr 17 2017 08:22
@camperbot yeah
@camperbot have a question
admin?
Shashank Shekhar
@ashwamegh
Apr 17 2017 08:24
@IsaakNazar need help..?
Nazar
@IsaakNazar
Apr 17 2017 08:25
@shashank7200 I have a question for Admin
Shashank Shekhar
@ashwamegh
Apr 17 2017 08:25
@IsaakNazar ohh...you can share with us also, if it's not private..
James Long
@KingJames101
Apr 17 2017 08:27

Hey guys, not quite sure how they want me to set this up
Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.

The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e.

["Chocolate Bar", 15]

There should be at least 5 sub-arrays in the list.

This is what I have:
var myList = (["Pussy", 100]["Full Body Massage", 75]["Emotional Conversation", 60]["Tradional Sad Happy Ending", 50]
Nazar
@IsaakNazar
Apr 17 2017 08:28
well, there was a task called "Title Case a Sentence" that has already solved I've never done before, So WTF is it? Somebody is solved that task? @shashank7200
Shashank Shekhar
@ashwamegh
Apr 17 2017 08:28
you should refractor your code... @KingJames101
James Long
@KingJames101
Apr 17 2017 08:28
As you can see, I'm making prices for a brothel. Aha, keeps me entertained to think of real life situstions.. xD
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:28
@KingJames101 [[.....], [.......], [.......], [..........], [.......]]
Shashank Shekhar
@ashwamegh
Apr 17 2017 08:29
@IsaakNazar If it passes the test without your intervention, you should report a bug to the site .... or look for other similar github issues ..
Nazar
@IsaakNazar
Apr 17 2017 08:31
@shashank7200 ok :+1:
James Long
@KingJames101
Apr 17 2017 08:33
@Lumexralph Okay, and what am I doing wrong here?
var myList = [["Pussy"], [100], ["Full Body Massage"], [75]["Emotional Conversation"], [60]["Tradional Sad Happy Ending"], [50], ["Kiss", 20]];
Wait sorry..

var myList = [["Pussy"], [100], ["Full Body Massage"], [75], ["Emotional Conversation"], [60], ["Tradional Sad Happy Ending"], [50], ["Kiss", 20]];

Here!

Shashank Shekhar
@ashwamegh
Apr 17 2017 08:35
You have created multidimensional arrays but , the challenge seeks consistent arrays.. with similar dimensions @KingJames101
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:35
@KingJames101 you must should not separate them into different arrays..... ["Pussy", 100]......
devpaaji
@devpaaji
Apr 17 2017 08:36
@Lumexralph
how are you friend
gm
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:36
@KingJames101 remember this from the instructions ["Chocolate Bar", 15]?
devpaaji
@devpaaji
Apr 17 2017 08:36
<img src="https://www.w3schools.com/howto/img_fjords.jpg" width="200" height="200" id="myImg"/>
<div id="myModal" class="modal">
  <span class="close" onclick="document.getElementById('myModal').style.display='none'">&times;</span>
  <!-- Modal Content (The Image) -->
  <img class="modal-content" id="img01">
</div>

trying modal on images

function modalImageZoom(){
  var getId = document.getElementById('myModal');
  getId.style.display = 'block';
  var modalImg = document.getElementById("img01");
  modalImg.src = this.src;
  (console.log(modalImg));
}

var imgId = document.querySelector('#myImg');
imgId.addEventListener('click', modalImageZoom);

I am trying to understand
modalImg.src = this.src;
so this here refers to var imgId = document.querySelector('#myImg');
ie #myImg

@Lumexralph
can you look into
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:36
@devpaaji hey Buddy :smile:
James Long
@KingJames101
Apr 17 2017 08:38
@Lumexralph Thank you so much, my good man!
CamperBot
@camperbot
Apr 17 2017 08:38
kingjames101 sends brownie points to @lumexralph :sparkles: :thumbsup: :sparkles:
:star2: 1527 | @lumexralph |http://www.freecodecamp.com/lumexralph
James Long
@KingJames101
Apr 17 2017 08:38
@shashank7200 And thank you as well. You guys were great!
CamperBot
@camperbot
Apr 17 2017 08:38
kingjames101 sends brownie points to @shashank7200 :sparkles: :thumbsup: :sparkles:
:cookie: 237 | @shashank7200 |http://www.freecodecamp.com/shashank7200
devpaaji
@devpaaji
Apr 17 2017 08:39
@Lumexralph so is it referring to var imgId = document.querySelector('#myImg');
ID with ie #myImg
<img src="https://www.w3schools.com/howto/img_fjords.jpg" width="200" height="200" id="myImg"/>
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:49
sorry my connection is messing up here
@devpaaji this is referencing the document.querySelector('#myImg');
@devpaaji what are you trying to do?
anderson
@anderson2825
Apr 17 2017 08:52
why is false??
free033.png
devpaaji
@devpaaji
Apr 17 2017 08:52
onclick of image
like a modal
of image
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:52
@devpaaji modalImg.src = this.src; the source attribute of imgId element is assigned to the the source attribute of modalImg
devpaaji
@devpaaji
Apr 17 2017 08:52
yes
done now
jhobotuck
@jhobotuck
Apr 17 2017 08:53
@revisualize thanks for pointing out returning a value break the loop. If this is the case what do I use? A switch? Use something other than return.
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:53
@devpaaji cool ?
meizaifeng
@meizaifeng
Apr 17 2017 08:53
Concatenating Strings with the Plus Equals Operator freecodecamp
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:54
@meizaifeng tried anything or you have a question?
WAINGOR
@WAINGOR
Apr 17 2017 08:54
Hi all, Im stuck at excercise called factorialize ( Basic algo scripting) have been looking at it for a long time. Can someone help ?
function factorialize(num) {
 var k = 1;
 var counter= 2;
  var factori= 0;
  for (var i=2; i<num+1; i++) {

  var verMet = i*k;


  }
  return factori;
}

factorialize(5);
HeebieGeeBee
@HeebieGeeBee
Apr 17 2017 08:54
@anderson2825 you're earlier if else statements are wrong
all except the whole in one statement should be just compairing strokes to par in some way
Ogundele Olumide
@Lumexralph
Apr 17 2017 08:55
@WAINGOR you're only returning 0
jhobotuck
@jhobotuck
Apr 17 2017 08:55
@anderson2825 you have a "+" in the statement when it should be a "-"
anderson
@anderson2825
Apr 17 2017 08:56
@jhobotuck @HeebieGeeBee thanks! I'm in check!
CamperBot
@camperbot
Apr 17 2017 08:56
:cookie: 218 | @jhobotuck |http://www.freecodecamp.com/jhobotuck
:star2: 1357 | @heebiegeebee |http://www.freecodecamp.com/heebiegeebee
anderson2825 sends brownie points to @jhobotuck and @heebiegeebee :sparkles: :thumbsup: :sparkles:
jhobotuck
@jhobotuck
Apr 17 2017 09:00
Trying to figure out how to loop through an if statement or should I be trying something else?

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


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

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

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

      if (contacts[i].hasOwnProperty(prop)){
          return contacts[i][prop];

        } else {
          return "No such property";
        }

    } else {
       return "No such contact";
     }
  }
beauty
@just111
Apr 17 2017 09:02
if(value !="" &&prop != 'tracks' ){
collectionCopy[id][prop]=value;
}else if(value !="" &&prop!= 'tracks'){
collectionCopy[id][prop].push(value);
}else(value = ''){
delete collectionCopy[id][prop];
}
jhobotuck
@jhobotuck
Apr 17 2017 09:12
Hello?
Ogundele Olumide
@Lumexralph
Apr 17 2017 09:15
@jhobotuck
else {
       return "No such contact";
     }   // is an else statement standing alone and i don't think that's allowed in JS, simply return no such contact removing the else block
Pieter Stokkink
@forkerino
Apr 17 2017 09:18
morning!
jhobotuck
@jhobotuck
Apr 17 2017 09:18
Yeah removing else had no impact.
vaishnavi prasad
@vaishnaviprasad
Apr 17 2017 09:19
how can I write custom error handling in express for every route
Ogundele Olumide
@Lumexralph
Apr 17 2017 09:19
@forkerino :smile:
@forkerino welcome back! am off to free my brain with a cool movie.... hope you're finally back?
Pieter Stokkink
@forkerino
Apr 17 2017 09:22
@Lumexralph it's looking like my internet connection will be more steady
so.... yes!
@jhobotuck looks like you are returning 'No such contact' in the wrong place. You have to do it after looking through all the contacts, not when the firstname doesn't match.
Nazar
@IsaakNazar
Apr 17 2017 09:25
I need help
function largestOfFour(arr) { //find the largest number in subarrays
  var arrM = [];
  var max;
  for (var i = 0; i < arr.length; i++) {
    var maxInArr = arr.slice(i, i+1)[i];
    if (maxInArr > max) {
      max = maxInArr;

    }arrM.push(max);
  }return arrM;
}
console.log(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]));
Pieter Stokkink
@forkerino
Apr 17 2017 09:25
@vaishnaviprasad did you look at this? https://expressjs.com/en/guide/error-handling.html
Stephen James
@sjames1958gm
Apr 17 2017 09:26
@IsaakNazar your selection of the largest in the interior arrays is not correct - you need another loop or other functino
jhobotuck
@jhobotuck
Apr 17 2017 09:27
Is the problem not with the else statements breaking the loop?
The examples of if statements in a loop I have seen only show the if statement and no else or return statements.
Pieter Stokkink
@forkerino
Apr 17 2017 09:28
@jhobotuck well, you don't want it to break the loop, no? You need to put that return outside of it.
WAINGOR
@WAINGOR
Apr 17 2017 09:28
@forkerino I just sent you a pm :)
Pieter Stokkink
@forkerino
Apr 17 2017 09:28
and no else is needed
jhobotuck
@jhobotuck
Apr 17 2017 09:28
Hmmmmmm
Pieter Stokkink
@forkerino
Apr 17 2017 09:29
@WAINGOR noted
jhobotuck
@jhobotuck
Apr 17 2017 09:29
Awww use variables!
HarrisHakeem
@HarrisHakeem
Apr 17 2017 09:29
I'm having some trouble on increment a num in js any advice?
heroiczero
@heroiczero
Apr 17 2017 09:30
@HarrisHakeem num++; increments the num by one each time in a loop
Stephen James
@sjames1958gm
Apr 17 2017 09:31
@HarrisHakeem if using ++ then don't use = as ++ assigns back to the original variable
Nazar
@IsaakNazar
Apr 17 2017 09:32
@sjames1958gm what if i slice() my subarrays into arrays?
HarrisHakeem
@HarrisHakeem
Apr 17 2017 09:32
oh i completely forgot that!
thank you @sjames1958gm