4th
Aug 2016
Santiago Gómez
@Sperkajugglite
Aug 04 2016 00:00
i like how it loads as you write
Ralph Nahra
@Rallph
Aug 04 2016 00:00
hey guys how can i take an item in an array and turn it into an array itself. for example turn ["sample", "text"] into [["s", "a", "m", "p", "l", e"], ["t", "e", "x", "t"]]?
Mike
@MikeJSchorah
Aug 04 2016 00:00
Could someone explain Palindromes to me? I have the answer. I just want to know how it works.
Santiago Gómez
@Sperkajugglite
Aug 04 2016 00:00
i would work on the design
a little
mrankins
@mrankins
Aug 04 2016 00:00

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

// Only change code below this line.
var plusThree = oldArray.map(function(val){
return val + 3;
});
var newArra
var oldArray = [1,2,3,4,5];

why is not add three to each number
llamatarianism
@llamatarianism
Aug 04 2016 00:01
@Rallph `arr[0] = arr[0].split(""); arr[1] = arr[1].split("");`
mrankins
@mrankins
Aug 04 2016 00:01

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

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

llamatarianism
@llamatarianism
Aug 04 2016 00:01
if you have an array with a lot of elements, used `map`
`arr.map(x => x.split(""))`
Ralph Nahra
@Rallph
Aug 04 2016 00:02
@llamatarianism ok thanks
CamperBot
@camperbot
Aug 04 2016 00:02
rallph sends brownie points to @llamatarianism :sparkles: :thumbsup: :sparkles:
:star2: 1119 | @llamatarianism |http://www.freecodecamp.com/llamatarianism
mrankins
@mrankins
Aug 04 2016 00:02
i got it had to delete last line
Aug 04 2016 00:03
@Sperkajugglite thanks for the review :sparkles: :smile:
CamperBot
@camperbot
Aug 04 2016 00:03
cascada1 sends brownie points to @sperkajugglite :sparkles: :thumbsup: :sparkles:
Santiago Gómez
@Sperkajugglite
Aug 04 2016 00:04
np
nice work
Mike
@MikeJSchorah
Aug 04 2016 00:04
``````function palindrome(str) {
var oldstring = str.replace(/[\W_]/g, '').toLowerCase();
var newstring = str.replace(/[\W_]/g, '').toLowerCase().split('').reverse().join('');
// Good luck!
return oldstring === newstring;

}``````
I have the answer to palindromes here. Someone please explain how it works.
Varun Sharma
@varun29
Aug 04 2016 00:05
@Chrono79 it worked...
Mike
@MikeJSchorah
Aug 04 2016 00:05
`/[\W_]/g`
Matthew Fogel
@MatthewFogel
Aug 04 2016 00:05
``
Mike
@MikeJSchorah
Aug 04 2016 00:05
What does this do?
Diego Mayer
@Chrono79
Aug 04 2016 00:05
@varun29 :+1:
Varun Sharma
@varun29
Aug 04 2016 00:05
@Chrono79 thanks
CamperBot
@camperbot
Aug 04 2016 00:05
varun29 sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1743 | @chrono79 |http://www.freecodecamp.com/chrono79
Matthew Fogel
@MatthewFogel
Aug 04 2016 00:05

``

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line
var processArg = processed;

''

// Example
var changed = 0;

function change(num) {
return (num + 5) / 3;
}

changed = change(10);

// Setup
var processed = 2;

function processArg(num) {
return (num + 3) / 5;
}

// Only change code below this line
var processArg = processed;

Diego Mayer
@Chrono79
Aug 04 2016 00:06
@MatthewFogel processed is your var and processArg the function, look at the example code they gave you
changed is the var and change the function
Puvendran Pillay
@puven12
Aug 04 2016 00:12
hello what is a breakpoint?
Aug 04 2016 00:14
@puven12 stopping your code from running past a specific place
Used for debugging purposes
Puvendran Pillay
@puven12
Aug 04 2016 00:14
@marhyorh how do i do that ?
Moisés Man
@moigithub
Aug 04 2016 00:16
mdn.io/debugger <<<< @puven12
Aug 04 2016 00:16
@puven12 Goto Sources on your Dev console ..

@puven12 That will help

mdn.io/debugger <<<< @puven12

Puvendran Pillay
@puven12
Aug 04 2016 00:16
@moigithub @marhyorh ok thanks i got it
CamperBot
@camperbot
Aug 04 2016 00:16
puven12 sends brownie points to @moigithub and @marhyorh :sparkles: :thumbsup: :sparkles:
:star2: 1803 | @moigithub |http://www.freecodecamp.com/moigithub
Tim
@x-yz
Aug 04 2016 00:27
how do i post code w/ markdown?
Aug 04 2016 00:27
wiki format
CamperBot
@camperbot
Aug 04 2016 00:27

# Multi line Code

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

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

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

# Single line Code

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

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

Tim
@x-yz
Aug 04 2016 00:28
thanks @marhyorh
CamperBot
@camperbot
Aug 04 2016 00:28
x-yz sends brownie points to @marhyorh :sparkles: :thumbsup: :sparkles:
Aug 04 2016 00:28
YWC :+1:
Tim
@x-yz
Aug 04 2016 00:31
```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 property"; } }```
oops lol
`function test() { return test; }`
Aug 04 2016 00:33
@x-yz , three backticks -> shift + enter -> paste code -> three backticks -> enter
Puvendran Pillay
@puven12
Aug 04 2016 00:34
`hi`
Josh Martin
@cjoshmartin
Aug 04 2016 00:35
hello can someone help me with "where do I belong" algorithm
Tim
@x-yz
Aug 04 2016 00:35
`````` 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 property";
}
}``````
```
Andrew Kay
@andrewjkay
Aug 04 2016 00:36
This message was deleted
This message was deleted
greg
@wearenotgroot
Aug 04 2016 00:37
@andrewjkay push is an array method
Moisés Man
@moigithub
Aug 04 2016 00:37
@x-yz 2 question..
what `return` does ?
what happen if the firstName of the first element in ur array .. its not the same as firstName ?
Andrew Kay
@andrewjkay
Aug 04 2016 00:38
This message was deleted
This message was deleted
isaacgg
@isaacgg
Aug 04 2016 00:38
Hi, I have a problem with Regex. Why this regex var r1 = new RegExp(/\b[1]?[\s]?[(]{1}[0-9]{3}[)]{1}[.-\s]?[0-9]{3}[.-\s]?[0-9]{4}\b/, 'y') is not maching this string "(555)555-5555"?
Andrew Kay
@andrewjkay
Aug 04 2016 00:38
This message was deleted
Tim
@x-yz
Aug 04 2016 00:38
thanks moises
Andrew Kay
@andrewjkay
Aug 04 2016 00:38
oh man those are objects
greg
@wearenotgroot
Aug 04 2016 00:39
@andrewjkay :+1:
Josh Martin
@cjoshmartin
Aug 04 2016 00:39
Andrew Kay
@andrewjkay
Aug 04 2016 00:39
@wearenotgroot thanks
CamperBot
@camperbot
Aug 04 2016 00:39
andrewjkay sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1268 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Josh Martin
@cjoshmartin
Aug 04 2016 00:40
``````
function getIndexToIns(arr, num) {
// Find my place in this sorted array.

if (arr.indexOf(num)== -1){
arr.push(num);
}
arr.sort();

return arr.indexOf(num);
}

getIndexToIns([2, 5, 10], 15);``````
I can't get to work
Brandon Bowers
@Bowers96
Aug 04 2016 00:40
How is this done? Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator. Help please.
Tim
@x-yz
Aug 04 2016 00:41
thanks @moigithub got it now. i made a variable to store whether or not there was a match, and if the whole for loop ran without a match, it returns "No such contact". Can the same be accomplished without a variable tracking whether or not there was a match?
CamperBot
@camperbot
Aug 04 2016 00:41
x-yz sends brownie points to @moigithub :sparkles: :thumbsup: :sparkles:
:star2: 1804 | @moigithub |http://www.freecodecamp.com/moigithub
greg
@wearenotgroot
Aug 04 2016 00:41
@cjoshmartin you need to change the sort func a bit, feed it a custom callback function so it could sort properly
Josh Martin
@cjoshmartin
Aug 04 2016 00:42
@wearenotgroot like pass in a function and compare?
greg
@wearenotgroot
Aug 04 2016 00:42
@cjoshmartin yep
Moisés Man
@moigithub
Aug 04 2016 00:42
@x-yz without variable... of course :)
Norvin Burrus
@ndburrus
Aug 04 2016 00:43
@Bowers96 this may help: :sparkles:
``````Modulo operator % returns a remainder.

i = 5 % 2; // 1
i = 8 % 3; // 2
i = 6 % 3; // 0``````
Brandon Bowers
@Bowers96
Aug 04 2016 00:43
How do you post a screenshot of your terminal? @cjoshmartin
Norvin Burrus
@ndburrus
Aug 04 2016 00:43
help format @Bowers96
• using `Shift` + `enter` will give you additional line feeds (space) for pasting your code. also, the backticks (`) key is located to the left of the number one (#1) key.
• further, you may find the two buttons (chat/compose & markdown - the chat/compose button alternates modes) to the right of the text entry area helpful.
• you can also edit text after it's been entered by clicking on the three (3) dots to the right of the text entry area (it will appear when you hover to the right of the time stamp).
CamperBot
@camperbot
Aug 04 2016 00:43

# Multi line Code

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

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

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

# Single line Code

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

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

isaacgg
@isaacgg
Aug 04 2016 00:43
Hi, I have a problem with Regex. Why this regex var r1 = new RegExp(/\b1?[\s]?[(]{1}[0-9]{3}[)]{1}[.-\s]?[0-9]{3}[.-\s]?[0-9]{4}\b/, 'y') is not maching this string "(555)555-5555"?
Moisés Man
@moigithub
Aug 04 2016 00:43
Tim
@x-yz
Aug 04 2016 00:44
thats a lot of regex
isaacgg
@isaacgg
Aug 04 2016 00:45
yeah, but it is not so complex. It worked for all the cases in the exercisse except this one
I use always the same formula
Brandon Bowers
@Bowers96
Aug 04 2016 00:45
``````var a = 3;
var b = 17;
var c = 12;

// Only modify code below this line

a = a + 12;
b = 9 + b;
c = c + 7;``````
Cool @camperbot
Ralph Nahra
@Rallph
Aug 04 2016 00:47
I'm trying to make the first letter of each word in the array uppercase, but it's not working for some reason
``````function titleCase(str) {
var arr = str.split(" ");
for (var i = 0; i < arr.length; i++) {
arr[i].charAt(0).toUpperCase();
console.log(arr[i].charAt(0));
}
return arr;
}

titleCase("I'm a little tea pot");``````
ignore the console.log
greg
@wearenotgroot
Aug 04 2016 00:49
@Rallph well you need to concatenate the rest of the letter of each word
``arr[i].charAt(0).toUpperCase(); //will only give you each letter at the start, also you need to store the new string to a variable otherwise you wont get any result outside that loop``
Norvin Burrus
@ndburrus
Aug 04 2016 00:49
@Bowers96 which lesson is this?
Moisés Man
@moigithub
Aug 04 2016 00:50
@isaacgg `-` is a special character on regex.. mean range.. do u wanna set a range ? liike [0-9] <-- match 0123456789
what `\b` does ? are for digits ??
Brendan Kinahan
@BKinahan
Aug 04 2016 00:51
@moigithub `\b` is a word-boundary
Ralph Nahra
@Rallph
Aug 04 2016 00:51
@wearenotgroot I'm trying to take care of capitalizing the first letter in each word and then doing other stuff later
Moisés Man
@moigithub
Aug 04 2016 00:51
@BKinahan soo can u apply tonumbers ?
:point_up: August 3, 2016 7:43 PM @BKinahan
Stephen James
@sjames1958gm
Aug 04 2016 00:51
@Rallph `arr[i].charAt(0).toUpperCase();` this will upper case a letter and return it but does not change the string
Brendan Kinahan
@BKinahan
Aug 04 2016 00:52
@moigithub same as `(^\w|\w\$|\W\w|\w\W)`
jeffyoo
@jeffyoo
Aug 04 2016 00:52
@Rallph You're not returning the answer to anything
Brendan Kinahan
@BKinahan
Aug 04 2016 00:52
so yeah, you can use it with numbers
Ralph Nahra
@Rallph
Aug 04 2016 00:52
so how do i get it to modify the string?
isaacgg
@isaacgg
Aug 04 2016 00:52
yes I want to match that \b would match a block @moigithub
Michael Noronha
@mtn
Aug 04 2016 00:52
@Rallph applying .toUpperCase does not modify the string
@Rallph you can make the first letters uppercase, then concat the rest of the string
Stephen James
@sjames1958gm
Aug 04 2016 00:52
@Rallph You have to rebuild the string with that and the rest of the string
greg
@wearenotgroot
Aug 04 2016 00:52
@Rallph string are immutable, you cannot modify them, you can only create new ones
jeffyoo
@jeffyoo
Aug 04 2016 00:53
@Rallph Yeah, what greg said, so return it to something
Michael Noronha
@mtn
Aug 04 2016 00:53
@Rallph concat or join are options. are you familiar with either?
Ralph Nahra
@Rallph
Aug 04 2016 00:53
yes
jeffyoo
@jeffyoo
Aug 04 2016 00:54
@Rallph this is the answer to capitalie the first letter in each word https://repl.it/CjTH
@Rallph i didnt include the rest of the string just in case u wanted to figure that out on ur own too
Mike
@MikeJSchorah
Aug 04 2016 00:55
``````function largestOfFour(arr) {
var largestOfFour = 0;

for (var i = 0; i < arr.length; i++) {
if (arr[i] > largestOfFour) {
largestOfFour = arr[i];
}
}// You can do this!
return arr;
}``````
Could someone please give me a hint.
Michael Noronha
@mtn
Aug 04 2016 00:55
@jeffyoo Giving a part of the answer someone hasn't reached yet =/= teaching
@MikeJSchorah I made a variable to hold the largest that I checked against in each loop
greg
@wearenotgroot
Aug 04 2016 00:56
@MikeJSchorah return largestOfFour; //i think if i remember correctly
Michael Noronha
@mtn
Aug 04 2016 00:56
@MikeJSchorah But that's definitely not the most elegant option
jeffyoo
@jeffyoo
Aug 04 2016 00:57
@michaeltnoronha True. But I thought that all the replies he was receiving would make it too confusing
isaacgg
@isaacgg
Aug 04 2016 00:57
Does anyone know why my regex is failing?
jeffyoo
@jeffyoo
Aug 04 2016 00:58
@isaacgg regex fails everyone
Michael Noronha
@mtn
Aug 04 2016 00:58
If anyone has a clean elegant solution to Return Largest Numbers in Arrays, please let me know :)
isaacgg
@isaacgg
Aug 04 2016 00:58
@jeffyoo hahaha that's true
Ralph Nahra
@Rallph
Aug 04 2016 00:58
anyway thanks for the help guys, really appreciate it
Michael Noronha
@mtn
Aug 04 2016 00:59
@isaacgg is there something specific?
isaacgg
@isaacgg
Aug 04 2016 00:59
@michaeltnoronha what do you mean?
jeffyoo
@jeffyoo
Aug 04 2016 00:59
@Rallph np, did u get it?
Michael Noronha
@mtn
Aug 04 2016 01:00
@isaacgg bout regex?
Ralph Nahra
@Rallph
Aug 04 2016 01:00
@jeffyoo not yet, but im getting there
jeffyoo
@jeffyoo
Aug 04 2016 01:01
@Rallph kk, if i can give one hint for that problem. the slice method helped me on that one
isaacgg
@isaacgg
Aug 04 2016 01:01
I don't know why my regex expresion `r1 = new RegExp(/^\b[1]?[\s]?[\(]{1}[0-9]{3}[\)]{1}[.-\s]?[0-9]{3}[.-\s]?[0-9]{4}\b/, 'i')` is not maching this string `"(555)555-5555"`@michaeltnoronha
greg
@wearenotgroot
Aug 04 2016 01:02
@MikeJSchorah oh it's multiple array. what you can do is
• sort each sub array
• then you can get the largest number/item on the sub array at index 0 or at the last index depending on the sorting method
• push to new array
Norvin Burrus
@ndburrus
Aug 04 2016 01:02
@michaeltnoronha :sparkles:
• extract the 4 arrays
• iterate over each array to determine largest value/s
• consolidate 4 largest values into array & return result
Giovanni
@spgiovanni
Aug 04 2016 01:04
Can anyone help me with this challenge "Stand in line" on the map, =Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Brandon Bowers
@Bowers96
Aug 04 2016 01:05
```js
``````
function convertToF(celsius) {
var fahrenheit= -22 * 9/5 + 32;

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

// Change the inputs below to test your code
convertToF(-30);``````
Stephen James
@sjames1958gm
Aug 04 2016 01:05
@isaacgg Does \b work if the first character (
Giovanni
@spgiovanni
Aug 04 2016 01:05
@Bowers96 yea Should be using the .shift?
Brandon Bowers
@Bowers96
Aug 04 2016 01:05
can anybody help with this challenge?
Stephen James
@sjames1958gm
Aug 04 2016 01:06
@Bowers96 You need to use the parameter celsius
Brandon Bowers
@Bowers96
Aug 04 2016 01:06
Can*
greg
@wearenotgroot
Aug 04 2016 01:06
@Bowers96 use the function parameter
Brandon Bowers
@Bowers96
Aug 04 2016 01:06
change the number?
change*
Change*
Michael Noronha
@mtn
Aug 04 2016 01:06
@Bowers96 use the parameter, not a hardcoded number
Stephen James
@sjames1958gm
Aug 04 2016 01:06
@Bowers96 Use celsius not -22
Brandon Bowers
@Bowers96
Aug 04 2016 01:07
Just type celsius?
isaacgg
@isaacgg
Aug 04 2016 01:07
@sjames1958gm I'm not sure. I'm gonna check it
greg
@wearenotgroot
Aug 04 2016 01:07
@Bowers96 remember the formula
T(F) = T(C) * 9/5 +32
T(C) is celsius <----- use the function param celsius
``convertToF(celsius) //<--------------------``
Stephen James
@sjames1958gm
Aug 04 2016 01:07
@Bowers96 Yes, celsius contains the number passed in to the function to convert
Brandon Bowers
@Bowers96
Aug 04 2016 01:07
Thank you! @sjames1958gm
CamperBot
@camperbot
Aug 04 2016 01:07
bowers96 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2317 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Brandon Bowers
@Bowers96
Aug 04 2016 01:08
Thank you! @wearenotgroot
CamperBot
@camperbot
Aug 04 2016 01:08
bowers96 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1269 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Stephen James
@sjames1958gm
Aug 04 2016 01:08
@Bowers96 :+1:
isaacgg
@isaacgg
Aug 04 2016 01:09
@sjames1958gm yeah, that's the problem. I gonna figure out how to solve it. thanks!
CamperBot
@camperbot
Aug 04 2016 01:09
isaacgg sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2318 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 04 2016 01:09
@isaacgg :+1: good luck
Giovanni
@spgiovanni
Aug 04 2016 01:11
Can anyone help me with this challenge "Stand in line" on the map, =Write a function nextInLine which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The nextInLine function should then return the element that was removed.
Michael Noronha
@mtn
Aug 04 2016 01:13
@spgiovanni Are you familiar with push() and shift()?
eeflores
@eeflores
Aug 04 2016 01:13
@spgiovanni what have you got so far?
Norvin Burrus
@ndburrus
Aug 04 2016 01:15
@spgiovanni this may be helpful: :sparkles:
Giovanni
@spgiovanni
Aug 04 2016 01:16
@michaeltnoronha @eeflores yea I just got done learning those was sure they wanted me use them or not thx
CamperBot
@camperbot
Aug 04 2016 01:16
spgiovanni sends brownie points to @michaeltnoronha and @eeflores :sparkles: :thumbsup: :sparkles:
Mike
@MikeJSchorah
Aug 04 2016 01:30
``````function largestOfFour(arr) {

for (var arr[i] = 0; arr[i] < arr.length; arr[i]++) {
arr[i].sort(function(a,b) {return a[0] < b[0]});
y[0] = arr[0];
arr.push(y[0]);
}
// You can do this!
return arr;
}``````

@Maggie9468
Aug 04 2016 01:33
I don't understand "Word Blanks",Who can teach me?
Norvin Burrus
@ndburrus
Aug 04 2016 01:34
This message was deleted
Mike
@MikeJSchorah
Aug 04 2016 01:34
@Maggie9468 Which part don't you understand?
artimath
@artimath
Aug 04 2016 01:35
Should I use heroku or c9 for the backend projects/

@Maggie9468
Aug 04 2016 01:35
Word Blanks
Mike
@MikeJSchorah
Aug 04 2016 01:35
@ndburrus I didn't get a chance to read it...

@Maggie9468
Aug 04 2016 01:35
@MikeJSchorah Word Blanks
Mike
@MikeJSchorah
Aug 04 2016 01:35
@Maggie9468 Which part of Word Blanks? The entire thing?
Norvin Burrus
@ndburrus
Aug 04 2016 01:36
@Maggie9468 the exercise is asking for a sentence to be built using the 4 word types given. it may be easiest to begin by making a complete (spacing & punctuation) sentence, using the 4 words. to make sense, the complete sentence will require a few "filler" words. :sparkles:

@Maggie9468
Aug 04 2016 01:36
entire,How to write can not be through the challenge
Norvin Burrus
@ndburrus
Aug 04 2016 01:37
@MikeJSchorah i think it would be easier to follow the psuedocode :point_up: August 3, 2016 9:02 PM
Mike
@MikeJSchorah
Aug 04 2016 01:37
@Maggie9468 You need to use `result` to concatenate the given variables separated by whitespace and added strings to form a full sentence.
JP
@juanp83
Aug 04 2016 01:39
I am having serious issues figuring out 'profile lookup' can someone help?
``````function lookUpProfile(firstName, prop){
for (var i = 0; i < contacts.length; i++){
if (firstName === contacts[i].firstName && contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
} else if (firstName !== contacts[i].firstName){
return "No such contact";
} else if (prop !== contacts[i].prop){
return "No such property";
}
}
}``````
greg
@wearenotgroot
Aug 04 2016 01:41
@juanp83 ok question: when do we use .(dot) and bracket notation on accessing object's property value ?
Mike
@MikeJSchorah
Aug 04 2016 01:41
``````function largestOfFour(arr) {

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

//sort each sub array
arr[i].sort(function(a,b) {return a[0] < b[0]});

//then you can get the largest number/item on the sub array at index 0 or at the last index depending on the sorting method
y[0] = arr[0];

//push to new array
arr.push(y[0]);
}
// You can do this!
return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
@ndburrus

@Maggie9468
Aug 04 2016 01:41
all wrong @MikeJSchorah
Mike
@MikeJSchorah
Aug 04 2016 01:42
greg
@wearenotgroot
Aug 04 2016 01:42

@juanp83 another question : what happens if the first if statement resulted to false

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

what happens when the above is executed? can you be certain that there isn't a contact with the given firstName?

John Magee
@jemagee
Aug 04 2016 01:45
@juanp83 The set up of this one is tricky - but you have to thik about it in the pseudocode - you're missing a test and missing a specific method for objects

@Maggie9468
Aug 04 2016 01:45
Mettcon
@Mettcon
Aug 04 2016 01:49
camperbot

@Maggie9468
Aug 04 2016 01:52
Solved @MikeJSchorah thank u
CamperBot
@camperbot
Aug 04 2016 01:52
maggie9468 sends brownie points to @mikejschorah :sparkles: :thumbsup: :sparkles:
Mike
@MikeJSchorah
Aug 04 2016 01:52
@Maggie9468 In the function, you need to concatenate the variables that are seen in the function's parameters

@Maggie9468
Aug 04 2016 01:53
ok! @MikeJSchorah
greg
@wearenotgroot
Aug 04 2016 01:54

@MikeJSchorah you need to fix your for loop
should look like

``for (var i = 0; i < arr.length; i++)``

also just create a result variable (outside and before the for loop)where you can store the largest number and use it instead of doing arr.push(...)

John Magee
@jemagee
Aug 04 2016 01:54
Ugh - bubble sorts - i hate them
greg
@wearenotgroot
Aug 04 2016 01:58
@MikeJSchorah another thing
``````y[0] = arr[0]; //this line should be

var largest = arr[i][0]; //<-----------a temp variable to store the largest of the four number in a sub array. remember arr is multidimensional array, arr[i] gives you access to the sub-array while [0] give you the element of that sub-array at index 0``````
JP
@juanp83
Aug 04 2016 02:00
@wearenotgroot Use bracket notation when we don't know the name of the property im trying to access. changed to prop !== contacts[i][prop]. Is that what you were getting at?
greg
@wearenotgroot
Aug 04 2016 02:01
@juanp83 yes, .prop doesnt exist in the property name list so using bracket is the way to go
Tab_BLee
@ivanberry
Aug 04 2016 02:01
@周欣 you can try the ```html to post your code, it's easy to read! :smile:
JP
@juanp83
Aug 04 2016 02:02
oops. Will do, sorry.
@wearenotgroot okay, cool. Had to go back and review that
Tommy567295
@Tommy567295
Aug 04 2016 02:02
can someone help me with the testing objects for properties.
Tab_BLee
@ivanberry
Aug 04 2016 02:02
@Maggie9468 just on the right bottom you can get some tips abbout it! Do some try
greg
@wearenotgroot
Aug 04 2016 02:03

@MikeJSchorah another issue is in your sort callback function, a and b are just number so no need for brackets

``function(a,b) {return a[0] < b[0]}``

should be

``function(a,b) {return a < b}``
Santiago Gómez
@Sperkajugglite
Aug 04 2016 02:05
hi guys
i know its not the right chat
but since it has to do with react
i figured it could be the problem
i am doing the markdown previewer and the react part works, however, i have not been able to make the stylesheet work
Andrew Yurkovic
@yurk23
Aug 04 2016 02:11
Hey all, trying to do the "Escape Sequences in Strings" checkpoint and receiving the error "not a function", confused as to what I'm missing here.
Mike
@MikeJSchorah
Aug 04 2016 02:11
@wearenotgroot I'm getting the error "arr[i].sort is not a function"
Stephen James
@sjames1958gm
Aug 04 2016 02:12
@yurk23 There shouldn't be any functions involved. post what you have.
Andrew Yurkovic
@yurk23
Aug 04 2016 02:12
var myStr;"FirstLine \n \SecondLine\ \r ThirdLine"
Mike
@MikeJSchorah
Aug 04 2016 02:12
@yurk23 You should be setting a value to a variable.
greg
@wearenotgroot
Aug 04 2016 02:12
@MikeJSchorah should look like this
``arr[i].sort(function(a,b) {return a < b});``
Stephen James
@sjames1958gm
Aug 04 2016 02:13
@yurk23 assign to the variable and remove blanks
Mike
@MikeJSchorah
Aug 04 2016 02:14
@yurk23 You set values to variables with an = sign, not a semicolon
greg
@wearenotgroot
Aug 04 2016 02:14
@MikeJSchorah post your updated code btw
Stephen James
@sjames1958gm
Aug 04 2016 02:15
@Sperkajugglite How are you preprocessing the sass?
Mike
@MikeJSchorah
Aug 04 2016 02:16
``````function largestOfFour(arr) {

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

//sort each sub array
arr[i].sort(function(a,b) {return a < b});

//then you can get the largest number/item on the sub array at index 0 or at the last index depending on the sorting method
var largest = arr[i][0];

//push to new array
arr.push(largest);
}
// You can do this!
return arr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
@wearenotgroot
bitgrower
@bitgrower
Aug 04 2016 02:16
@MikeJSchorah it means that it's not detecting arr[i] as a type which accepts the .sort method ...
Stephen James
@sjames1958gm
Aug 04 2016 02:17
@MikeJSchorah Why are you pushing onto the same array that you are processing?
Mike
@MikeJSchorah
Aug 04 2016 02:18
@bitgrower I tried just `arr` earlier and it seems to be pulling from 0
Stephen James
@sjames1958gm
Aug 04 2016 02:18
@MikeJSchorah You need a new array to push the results onto.
Tommy567295
@Tommy567295
Aug 04 2016 02:18
Hello. Could I get some help for "Testing Objects for Properties"
Stephen James
@sjames1958gm
Aug 04 2016 02:18
@Tommy567295 post what you have.
Mike
@MikeJSchorah
Aug 04 2016 02:19
@sjames1958gm I was trying to push onto a new array. `return arr` was given at the bottom... Didn't know if that could be changed or not
greg
@wearenotgroot
Aug 04 2016 02:19

@MikeJSchorah as i mentioned earlier and as mentioned by @sjames1958gm

``arr.push(largest); //<--------should be result.push(largest);``

declare result variable(an array) outside and before the for loop

Stephen James
@sjames1958gm
Aug 04 2016 02:20
@MikeJSchorah Yeah you should be able to change that. it was just there to make the code syntactically valid
Tommy567295
@Tommy567295
Aug 04 2016 02:21
``````var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj = checkProp;
return "Change Me!";
}``````
I'm not sure how to modify the function to test for myObj for checkProp.
Stephen James
@sjames1958gm
Aug 04 2016 02:21
@Tommy567295 You need to use myObj with hasOwnProperty (you are overwriting myObj).
Tommy567295
@Tommy567295
Aug 04 2016 02:22
so I need to have it as
myObj.hasOwnProperty(checkProp);?
Stef Busta
@DesertBugZ
Aug 04 2016 02:22
I'm stuck on the convert celsius to fahrenheit challenge. I've tried to get through this a few times but I am just stuck! Could someone walk me through this one? I'd really love to move on! lol
Stephen James
@sjames1958gm
Aug 04 2016 02:22
@Tommy567295 Yep. That becomes your test.
greg
@wearenotgroot
Aug 04 2016 02:23
@DesertBugZ post what you got?
Stephen James
@sjames1958gm
Aug 04 2016 02:23
@DesertBugZ the formula to the left has F and C the two variables fahrenheit and celsius are your F and C.
Tommy567295
@Tommy567295
Aug 04 2016 02:23
@sjames1958gm still not working once I changed it to that.
Stephen James
@sjames1958gm
Aug 04 2016 02:24
@Tommy567295 Well that was the test. What did you do with the test?
Tommy567295
@Tommy567295
Aug 04 2016 02:24
What do you mean?
greg
@wearenotgroot
Aug 04 2016 02:24
@DesertBugZ formula is
T(F) = T(C) * 9/5 + 32
Stephen James
@sjames1958gm
Aug 04 2016 02:24
@Tommy567295 I guess I meant post your code again :)
Tommy567295
@Tommy567295
Aug 04 2016 02:24
Okay.
``````var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp);
return "Change Me!";
}``````
Zach
@Moose1551
Aug 04 2016 02:25
Can someone help me out real quick? I'm trying to sync up the color change and the quote change in my random quote generator. Does anyone have any suggestions? Everything I've come across in research seems unnecessarily complex. Any tips? Here is the codepen. I've put a single line comment above the problem code. http://codepen.io/Moose1551/pen/QEVJwy
Stephen James
@sjames1958gm
Aug 04 2016 02:25
@Tommy567295 You need an if to go with that call to myOwnProperty and if true return the value and if not return Not Found
Stef Busta
@DesertBugZ
Aug 04 2016 02:25
@wearenotgroot ok, so would I just substitute the F and C with the values they give me?
I would post what I had but I reset it
Stephen James
@sjames1958gm
Aug 04 2016 02:26
@DesertBugZ Not the values, the variables
greg
@wearenotgroot
Aug 04 2016 02:26
@DesertBugZ not values but variables and parameters
Stephen James
@sjames1958gm
Aug 04 2016 02:27
@Moose1551 It seems to change the colors? What is the issue?
Stef Busta
@DesertBugZ
Aug 04 2016 02:27
so one of them is, it says convertToF(-30) should return a value of -22
Stephen James
@sjames1958gm
Aug 04 2016 02:27
@DesertBugZ inside the function the parameter celsius is set to -30 for that call.
Stef Busta
@DesertBugZ
Aug 04 2016 02:28
fahrenheit=-22
convertToF(-30) under it
Stephen James
@sjames1958gm
Aug 04 2016 02:28
@DesertBugZ for convertToF(0) celsius parameter is set to 0 the value in the () becomes the value in celsius inside the function
Tommy567295
@Tommy567295
Aug 04 2016 02:29
I need a if and else statement?
Zach
@Moose1551
Aug 04 2016 02:29
@sjames1958gm , it does, but the color changes before the quote appears. I'd like to have both happen at the same time.
Stephen James
@sjames1958gm
Aug 04 2016 02:29
@Tommy567295 yes
Tommy567295
@Tommy567295
Aug 04 2016 02:29
wait what are you talking about for MyOwnProperty?
where is that?
Mike
@MikeJSchorah
Aug 04 2016 02:30
Thanks @wearenotgroot
CamperBot
@camperbot
Aug 04 2016 02:30
mikejschorah sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1271 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Stephen James
@sjames1958gm
Aug 04 2016 02:30
@Tommy567295 if (myObj.hasOwnProperty(checkObj)) {} else {}
if I types myownproperty that was a typo
@Moose1551 put the color changing code in a function and call it from the getJSON call back.
@Tommy567295 fill in the {} :)
Zach
@Moose1551
Aug 04 2016 02:31
CamperBot
@camperbot
Aug 04 2016 02:31
moose1551 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2319 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stef Busta
@DesertBugZ
Aug 04 2016 02:31
@sjames1958gm ok that one went smoothly, there are 4 more for me to do on this challenge, yesterday someone said I hardcoded too much and should not write the same thing for each over and over. if that makes any sense. I'm sorry for being wordy, I'm just trying to grasp this
Jesus Hilario H.
@jesushilarioh
Aug 04 2016 02:32
Hello, why does this program not return each alert?
``````var morning = true;
var daytime = true;
var nightime = true;

if (morning) {
} else if (daytime){
} else if (nightime) {
} else {
alert("I just don't know what time it is!");
}``````
Stephen James
@sjames1958gm
Aug 04 2016 02:32
@DesertBugZ Your function should not have any numbers other than `* 9/5 + 32` - the number to convert (celsius) is passed into the function in the celsius parameter. You should use that as C in the formula `F = C * 9/5 + 32`
greg
@wearenotgroot
Aug 04 2016 02:32
@DesertBugZ well just remember the concept of variables and parameter, they are placeholder for values which help your function/program dynamic
Stephen James
@sjames1958gm
Aug 04 2016 02:33
@jesushilariohernandez after alert("Good Morning") the code continues at the end.
@sjames1958gm The if and else if and else if and else are alternatives and only one will execute based on the conditions.
Tommy567295
@Tommy567295
Aug 04 2016 02:34
what would be in the brackets for else?
can't figure it out
Stephen James
@sjames1958gm
Aug 04 2016 02:34
@Tommy567295 What are you to return for the property not there?
Stef Busta
@DesertBugZ
Aug 04 2016 02:35

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
F= C * 9/5 + 32;

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

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

Stephen James
@sjames1958gm
Aug 04 2016 02:35
@DesertBugZ Replace F with fahrenheit and C with celsius
@Tommy567295 `If not, return "Not Found".`
AFK3000
@AFK3000
Aug 04 2016 02:36
i need help this this problem please

The remainder operator % gives the remainder of the division of two numbers.

Example

``````5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)``````

Usage
In mathematics, a number can be checked even or odd by checking the remainder of the division of the number by 2.

``````17 % 2 = 1 (17 is Odd)
48 % 2 = 0 (48 is Even)``````

Note
The remainder operator is sometimes incorrectly referred to as the "modulus" operator. It is very similar to modulus, but does not work properly with negative numbers.
Instructions

Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator.

// Only change code below this line

var remainder;

Jesus Hilario H.
@jesushilarioh
Aug 04 2016 02:36
@sjames1958gm ahh, i see. thanks man!
CamperBot
@camperbot
Aug 04 2016 02:36
jesushilariohernandez sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2320 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
AFK3000
@AFK3000
Aug 04 2016 02:37
HUH?
anyone understand
Stephen James
@sjames1958gm
Aug 04 2016 02:37
@DesertBugZ A function contains code that can be "called" or run with different values (parameters) in this case celsius is the parameter that will contain the number to be converted. So convertToF(-30) will run the function with celsius set to -30
greg
@wearenotgroot
Aug 04 2016 02:37
@AFK3000 store the result in the remainder variable----------> 11 % 3
Stephen James
@sjames1958gm
Aug 04 2016 02:37
@AFK3000 so remainder is the variable how do you set a variable to a value say set remainder to 10?
Stef Busta
@DesertBugZ
Aug 04 2016 02:38
ok.. I replaced the F and C. it came back "referenceError: Can't find variable Celsius
thuytn
@Sophia-nguyen
Aug 04 2016 02:38
Hi, I use `try .. catch` to catch exception, and any solution to catch all errors by one function?
greg
@wearenotgroot
Aug 04 2016 02:38
@DesertBugZ small c as celsius comes from
``function convertToF(celsius) <--------that celsius``
Jesus Hilario H.
@jesushilarioh
Aug 04 2016 02:38
@sjames1958gm so, program picks first true variable...executes condition then moves on.
Stephen James
@sjames1958gm
Aug 04 2016 02:38
celsius - case is importent
Stef Busta
@DesertBugZ
Aug 04 2016 02:39
oops I should know that
Stephen James
@sjames1958gm
Aug 04 2016 02:39
@jesushilariohernandez The first true condition (in this case variable) yes
Tommy567295
@Tommy567295
Aug 04 2016 02:39
I still can't figure it out
Stef Busta
@DesertBugZ
Aug 04 2016 02:39
still isn't working..
Stephen James
@sjames1958gm
Aug 04 2016 02:39
@Tommy567295 post
@DesertBugZ post again - got to be close
AFK3000
@AFK3000
Aug 04 2016 02:39
The variable remainder should be initialized
The value of remainder should be 2
You should use the % operato
Jesus Hilario H.
@jesushilarioh
Aug 04 2016 02:40
@sjames1958gm oh ok, so, first true condition...then moves on.
AFK3000
@AFK3000
Aug 04 2016 02:40
10 % 2
20 % 2 will equal 10
Stephen James
@sjames1958gm
Aug 04 2016 02:40
@jesushilariohernandez right - kind of how it read.
if (this) {} else if (that) {} else {}
@AFK3000 The remainder will always be less than the second parameter
Tommy567295
@Tommy567295
Aug 04 2016 02:41
``````var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp);
if (myObj.hasOwnProperty(checkObj)){
}}
return "Change Me!";
}``````
AFK3000
@AFK3000
Aug 04 2016 02:42
11 % 3 = 2
greg
@wearenotgroot
Aug 04 2016 02:42
@Tommy567295
``````function checkObj(checkProp) {
myObj.hasOwnProperty(checkProp); //<---------remove me
if (myObj.hasOwnProperty(checkObj)){
else {(If not, return "Not Found"); //<---------return the property value if true
return "Change Me!";
}``````
AFK3000
@AFK3000
Aug 04 2016 02:42
11 % 3 = 0
Stephen James
@sjames1958gm
Aug 04 2016 02:42
``````if (myObj.hasOwnProperty(checkProp) {
// in here return the value of checkProp on myObj
} else {
// in here return "NotFound";
}``````
Stef Busta
@DesertBugZ
Aug 04 2016 02:42
@sjames1958gm THANK YOU! I could cry, lol I didn't do anything different than what I showed you, just retyped it and it worked. :clap:
CamperBot
@camperbot
Aug 04 2016 02:42
desertbugz sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2321 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stef Busta
@DesertBugZ
Aug 04 2016 02:43
I'm gonna have to read up on that some more though, that was the hardest thing I've encountered yet.
Stephen James
@sjames1958gm
Aug 04 2016 02:43
@DesertBugZ :+1:
AFK3000
@AFK3000
Aug 04 2016 02:43
i dont understand what your saying @sjames1958gm
Akash Chavan
@CruiseDevice
Aug 04 2016 02:43
Quoting Strings with Single Quotes
``var myStr = "<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";``
CamperBot
@camperbot
Aug 04 2016 02:43
no wiki entry for: `please quoting strings with single quotesvar mystr a hrefhttpwwwexamplecom target_blanklinka`
Stephen James
@sjames1958gm
Aug 04 2016 02:43
FCC does not explain functions well enough.
AFK3000
@AFK3000
Aug 04 2016 02:44

"
// Only change code below this line

var remainder;
11 % 3 = 2;
"

Stephen James
@sjames1958gm
Aug 04 2016 02:44
@AFK3000 assign to remainder
@CruiseDevice replace outer " with ' and remove \
Akash Chavan
@CruiseDevice
Aug 04 2016 02:45
@sjames1958gm okay. i will try.
yes that worked
greg
@wearenotgroot
Aug 04 2016 02:45
:smile:
AFK3000
@AFK3000
Aug 04 2016 02:46
11 % 3 = 1;
what is remainder
5 % 2 = 1 because
Math.floor(5 / 2) = 2 (Quotient)
2 * 2 = 4
5 - 4 = 1 (Remainder)
what the heck
?
greg
@wearenotgroot
Aug 04 2016 02:47
@AFK3000
var remainder = 11 % 3; //<-------the result of the operation will be assigned to the remainder variable
AFK3000
@AFK3000
Aug 04 2016 02:47
CamperBot
@camperbot
Aug 04 2016 02:47
afk3000 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1272 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
AFK3000
@AFK3000
Aug 04 2016 02:47
but dang
ooooohhhhhhh OKAY
Stephen James
@sjames1958gm
Aug 04 2016 02:48
@CruiseDevice :+1:
greg
@wearenotgroot
Aug 04 2016 02:48
dont worry you'll ge the hang of the terminology
AFK3000
@AFK3000
Aug 04 2016 02:48
@sjames1958gm thx
CamperBot
@camperbot
Aug 04 2016 02:48
afk3000 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2322 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Aug 04 2016 02:48
@AFK3000 :+1:
Brandon Bowers
@Bowers96
Aug 04 2016 02:49
```js
`js`
``````
var myStr = "I am a \"double quoted\" string inside \" double quotes\".";``````

What am I doing wrong? Instructions
Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see:

I am a "double quoted" string inside "double quotes".

Nevermind.
Never mind*
Never mind.*
Never mind*
Never mind*
NixonRichard
@NixonRichard
Aug 04 2016 02:53
I have 69 IQ points
Alex Rapley
@arapl3y
Aug 04 2016 02:53
Hey guys, can anyone explain why when using .map, .sort functions etc. the second bracket is outside the second curly brace like this:
``````var array = [1, 12, 21, 2];
array.sort(function(a, b) {
return a - b;
});``````
NixonRichard
@NixonRichard
Aug 04 2016 02:54
i see nothing wrong with that
Stephen James
@sjames1958gm
Aug 04 2016 02:54
@arapl3y because the function is a parameter so the entire function is in ()
Alex Rapley
@arapl3y
Aug 04 2016 02:54
@sjames1958gm Ah ok, cool, thanks!
CamperBot
@camperbot
Aug 04 2016 02:54
arapl3y sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 2323 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
NixonRichard
@NixonRichard
Aug 04 2016 02:54
`( ...() { .... } )`
nothing s wrong
Alex Rapley
@arapl3y
Aug 04 2016 02:55
@NixonRichard I know, I just wanted clarification as to why it is like that
bitgrower
@bitgrower
Aug 04 2016 02:56
@NixonRichard -- yeah, Michael Moore's movie is pretty right on, as far as I can tell ... :(
NixonRichard
@NixonRichard
Aug 04 2016 02:58
Hey u r back @bitgrower
Oh thx for the idea my friend
bitgrower
@bitgrower
Aug 04 2016 03:00
yeah, rented Moore's movie, watched it ... he added some pieces I wasn't aware of, but just because s* is broken here, doesn't mean democracy or the rest is bad ... it means people got lulled into complacency and got stolen from ... sigh.
told you I'd watch it ... :)
NixonRichard
@NixonRichard
Aug 04 2016 03:04
Yeh i just think that documentary s something everyone shuold know
Timbowser
@Timbowser
Aug 04 2016 03:06
I'm having issues with one part of the record collection javascript exercise.
bitgrower
@bitgrower
Aug 04 2016 03:06
there's a lot people should know ... "The Big Short", "Too Big To Fail" ... Lawrence Lessig's "lesterworld" TED talk ... Jane Mayer's Dark Money ... the story of gerrymandering in North Carolina detailed in the book RatF**ked ...
@Timbowser can you post what you have ?
Timbowser
@Timbowser
Aug 04 2016 03:06
if(prop == "tracks" && collection[id][prop] == "undefined"){
collection[id][prop] = newArray;
collection[id][prop].push(value);
}
that is the only part that is getting stuck
If prop is "tracks" but the album doesn't have a "tracks" property, create an empty array before adding the new value to the album's corresponding property.
bitgrower
@bitgrower
Aug 04 2016 03:07
okay ... let's start from the beginning ... can you post ALL your code ?
Timbowser
@Timbowser
Aug 04 2016 03:07
that is the case it is trying to solve

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

// Only change code below this line
function updateRecords(id, prop, value) {
var newArray = [];

if(prop != "tracks" && value){
collection[id][prop] = value;
}

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

if(value === ""){
delete collection[id][prop];
}

if(prop == "tracks" && collection[id][prop] == "undefined"){
collection[id][prop] = newArray;
collection[id][prop].push(value);
}

return collection;
}

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

bitgrower
@bitgrower
Aug 04 2016 03:07
help formatting
CamperBot
@camperbot
Aug 04 2016 03:07

# Multi line Code

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

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

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

# Single line Code

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

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

Stephen James
@sjames1958gm
Aug 04 2016 03:07
@Timbowser "undefined" is not the same as undefined
bitgrower
@bitgrower
Aug 04 2016 03:07

for future reference ...

and @sjames1958gm is right about "undefined"

So let's start even further back then ...
help record collection ...
CamperBot
@camperbot
Aug 04 2016 03:08
no wiki entry for: `record collection`
bitgrower
@bitgrower
Aug 04 2016 03:08
what ?!?
bitgrower @bitgrower kicks @camperbot
Stephen James
@sjames1958gm
Aug 04 2016 03:09
Even the help is tired of this challenge :)
bitgrower
@bitgrower
Aug 04 2016 03:09
LOLOL
Timbowser
@Timbowser
Aug 04 2016 03:09
the help sent me here
bitgrower
@bitgrower
Aug 04 2016 03:09
okay ... so ... read me the first line of the instructions for the challenge ...
NixonRichard
@NixonRichard
Aug 04 2016 03:09
DO u want to see the full solution ? @Timbowser
i saved one in my note for cases like this
bitgrower
@bitgrower
Aug 04 2016 03:10
You're missing something HUGE ...and it's revealed in the first line of the instructions ..
@NixonRichard -- he can find dozens of solutions ...
all he has to do is go to the profile of any camper who has solved it and has their profile visible (most folks)
so ... he can go to freecodecamp.com/bitgrower -- find "record collection" ... and click on view solution and see mine ... for instance ...
Timbowser
@Timbowser
Aug 04 2016 03:11
@bitgrower are you saying the part where they don't have complete information?
bitgrower
@bitgrower
Aug 04 2016 03:12
@Timbowser follow my instructions EXACTLY ... which is what programming is a LOT about ... which is repeat back to me the FIRST sentence of the challenge instructions (something @camperbot should have given me grrrrr)
wiki record collection
CamperBot
@camperbot
Aug 04 2016 03:12

# Challenge Record Collection

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

### :checkered_flag: Problem Explanation:

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, check to see if the given element in the array has the property of "tracks". If the element has the property of "tracks", push the value onto the end of the "tracks" array. If the element does not have the property, create the property and value pair.

If value is blank, delete that prop.

Always return the entire collection object.

bitgrower
@bitgrower
Aug 04 2016 03:13
okay ... my bad ... I'm mixing this up with another favorite ... argh ...
Timbowser
@Timbowser
Aug 04 2016 03:13
You are given a JSON object representing (a small part of) your record collection.
bitgrower
@bitgrower
Aug 04 2016 03:13
thank you!!!!
Chris Cullen
@123xylem
Aug 04 2016 03:14
help Friendly Date Ranges
CamperBot
@camperbot
Aug 04 2016 03:14

# Algorithm Friendly Date Ranges

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

### :checkered_flag: Problem Explanation:

Create a program that will take two dates and convert them into a more easy to understand date such as `January 1st, 2017`. It will also check the difference between them, and handles cases with no difference, more than a day, more than a month, more than a year, and more than a month and less than a year respectively.

NixonRichard
@NixonRichard
Aug 04 2016 03:14
hmm
Timbowser
@Timbowser
Aug 04 2016 03:14
@bitgrower how does that help?
wait, is it cause I am not using the collectionCopy?
bitgrower
@bitgrower
Aug 04 2016 03:15
it would help more if I weren't mixing up challenges ... but reading & following instructions in detail anyway is a good habit to get into ...
no ...
NixonRichard
@NixonRichard
Aug 04 2016 03:16
why dont u past ur URL here for ez ? @Timbowser
i always do that to get help
NixonRichard
@NixonRichard
Aug 04 2016 03:17
just this part s enough my friend @Timbowser
bitgrower
@bitgrower
Aug 04 2016 03:17
This message was deleted
Timbowser
@Timbowser
Aug 04 2016 03:18
I am returning the collection at the end
NixonRichard
@NixonRichard
Aug 04 2016 03:18
yeh u shuold return ur entire collection
bitgrower
@bitgrower
Aug 04 2016 03:18
yeah, sorry ... :) I'm not focusing as well as I should ...
time to take a break ... I'll be back in a while ...
Timbowser
@Timbowser
Aug 04 2016 03:19
@NixonRichard how is it not returning the entire collection?
NixonRichard
@NixonRichard
Aug 04 2016 03:19
It is
u r returning the entire collection
Timbowser
@Timbowser
Aug 04 2016 03:20
ok
NixonRichard
@NixonRichard
Aug 04 2016 03:20
lol
so do u know where to start ?
and how to start ?
Timbowser
@Timbowser
Aug 04 2016 03:20
thats what I thought, think I just misread what you were saying.
Patrick Krawczykowski
@pkrawc
Aug 04 2016 03:21
what is up with all this bracket notation?
Timbowser
@Timbowser
Aug 04 2016 03:21
there is really only one of the if statements that is not working
@pkrawc what do you mean?
NixonRichard
@NixonRichard
Aug 04 2016 03:22
@Timbowser u have to use === to compare with undefined
u r using ==
check the error sign
it s telling u
Timbowser
@Timbowser
Aug 04 2016 03:23
@NixonRichard that still did not fix it. I think I am just going to start over.
Patrick Krawczykowski
@pkrawc
Aug 04 2016 03:25
@Timbowser collection[id][prop].push(value); could also be collection.id.prop.push(value); It doesn't really matter and sometimes bracket is better but I just think dot notation is much more readable.
greg
@wearenotgroot
Aug 04 2016 03:26
@pkrawc @Timbowser when dealing with variables use bracket notation!! .(dot) notation is used when you have literal named properties(the property name is literally prop and id as exmple)
Timbowser
@Timbowser
Aug 04 2016 03:26
@pkrawc I thought when using variables you must use brackets
tommy
@tommygebru
Aug 04 2016 03:27

@Timbowser ok but take into account the if structure...

if(){}
else(){}

or
if(){}
else if(){}
or
if(){}
else if(){}
else(){}
or
if(){
if(){}}
Patrick Krawczykowski
@pkrawc
Aug 04 2016 03:32
@Timbowser @wearenotgroot you're totally correct. I don't know what I was reading.
komorebi
@komorebi-san
Aug 04 2016 03:36
hello
Chris Cullen
@123xylem
Aug 04 2016 03:37
``````function makeFriendlyDates(arr) {
var arr0 =arr.pop();
arr0= arr0.split(/-/);
for(i=0;i<arr0.length;i++){
switch (arr0[1]) {
case 01:
arr0[1] = "Janurary";
break;
case 02:
arr0[1] = "February";
break;
case 03:
arr0[1] = "March";
break;

}}

return arr0;
}
makeFriendlyDates(['2016-01-01', '2016-02-04']);``````
Hello FIrends Im back!.. In this problem Ive seperated the date format and am gonna try using switch statements to convert the numbers to words.. It says "Octal literals are not allowed in strict mode." When i do this though... Is this workable or have I made a mistake somewhere??
thanks
NixonRichard
@NixonRichard
Aug 04 2016 03:39
hi Guyz
lboyer06
@lboyer06
Aug 04 2016 03:41
I'm having trouble with Stand In Line

function nextInLine(arr, item) {

myArr = [arr,item];
myArr.push(7);
myArr.shift();
// shift seems to remove the whole array besides the one from push and the 6

return myArr; // Change this line
}

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

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

Michael Noronha
@mtn
Aug 04 2016 03:43
@lboyer06 why do you have 7 as a parameter of push?
@lboyer06 also, if you initialize mrArr like that
@lboyer06 I'm pretty sure you'll create an array with just two values
@lboyer06 example: https://repl.it/CjVe/0
Michael Noronha
@mtn
Aug 04 2016 03:49
Anyone in here that has done Falsy Bouncer and wouldn't mind taking a look and my code?
Tyler Brown
@pelicanscarecrow
Aug 04 2016 03:51

// 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();

What is wrong with my code? I have to make myOutfit return to "sweater"
Michael Noronha
@mtn
Aug 04 2016 03:52
@pelicanscarecrow What is the problem asking you to do?
@pelicanscarecrow A link to the challenge would be good
Michael Noronha
@mtn
Aug 04 2016 03:53
@pelicanscarecrow ya doofus ;)
Timbowser
@Timbowser
Aug 04 2016 03:53
@NixonRichard just letting you know I solved my problem. Thanks for talking through it with me.
CamperBot
@camperbot
Aug 04 2016 03:53
timbowser sends brownie points to @nixonrichard :sparkles: :thumbsup: :sparkles:
Tyler Brown
@pelicanscarecrow
Aug 04 2016 03:54
@michaeltnoronha my var name is myOutfit
why would it be something else?
and what would it be?
Michael Noronha
@mtn
Aug 04 2016 03:54
@pelicanscarecrow the instructions were something different; I closed the page
@pelicanscarecrow here, i'll check again
Tyler Brown
@pelicanscarecrow
Aug 04 2016 03:55
Add a local variable to myOutfit to override the value of outerWear with "sweater".
oh my god
Michael Noronha
@mtn
Aug 04 2016 03:55
@pelicanscarecrow add a local variable to myOutfit ;)
Tyler Brown
@pelicanscarecrow
Aug 04 2016 03:55
nevermind I get what you were saying
I said var myOutfit instead of var outerWear.
Michael Noronha
@mtn
Aug 04 2016 03:56
@pelicanscarecrow yep!
Tyler Brown
@pelicanscarecrow
Aug 04 2016 03:56
thanks @michaeltnoronha
CamperBot
@camperbot
Aug 04 2016 03:56
pelicanscarecrow sends brownie points to @michaeltnoronha :sparkles: :thumbsup: :sparkles:
Michael Noronha
@mtn
Aug 04 2016 04:00
@NixonRichard Could you explain falsy bouncer to me?
@NixonRichard In particular, how the callback function works
NixonRichard
@NixonRichard
Aug 04 2016 04:02
well
sure
Jeffrowetull
@Jeffrowetull
Aug 04 2016 04:03
Hi, I'm doing ex194 and I don't get how to accomplish the third obj: nextInLine([5,6,7,8,9], 1) should return 5. I coded the function so it pushes the item onto the back of the array while returning the shifted front of the array. What's going wrong?
NixonRichard
@NixonRichard
Aug 04 2016 04:03
@Timbowser Nice :+1:
@michaeltnoronha u have to
remove all of these `false, null, 0, "", undefined, and NaN.` values from ur given array
Michael Noronha
@mtn
Aug 04 2016 04:04
@Jeffrowetull What is the title?
@NixonRichard Right
Chris Lacaille
@ChrisL108
Aug 04 2016 04:05
Is Boolean(bool) how you check if bool is boolean primitive?
NixonRichard
@NixonRichard
Aug 04 2016 04:06
boolean s if else
no sorry
it mean true or false
Chris Lacaille
@ChrisL108
Aug 04 2016 04:06
Oh okay
Michael Noronha
@mtn
Aug 04 2016 04:07
@NixonRichard Could you provide a bit more guidance please?
Jeffrowetull
@Jeffrowetull
Aug 04 2016 04:07
@michaeltnoronha Stand in line
Michael Noronha
@mtn
Aug 04 2016 04:08
@Jeffrowetull Can you share what you have?
Jeffrowetull
@Jeffrowetull
Aug 04 2016 04:08
@michaeltnoronha function nextInLine(arr, item) {
return testArr.shift(0); // Change this line
}
@michaeltnoronha Where it would affect var testArr = [1,2,3,4,5]; as the arr
Michael Noronha
@mtn
Aug 04 2016 04:09
@Jeffrowetull you are altering testArr, but the param is arr?
Jeffrowetull
@Jeffrowetull
Aug 04 2016 04:10
@michaeltnoronha ooo good point
Michael Noronha
@mtn
Aug 04 2016 04:10
@Jeffrowetull (thumbsup)
Jeffrowetull
@Jeffrowetull
Aug 04 2016 04:10
@michaeltnoronha thank you
CamperBot
@camperbot
Aug 04 2016 04:10
jeffrowetull sends brownie points to @michaeltnoronha :sparkles: :thumbsup: :sparkles:
Michael Noronha
@mtn
Aug 04 2016 04:10
:thumbsup: second time's the charm... ;)
Akash Chavan
@CruiseDevice
Aug 04 2016 04:17

Escape Sequences in Strings

``````
var myStr; // Change this line``````

What to do here? Please explain.

Brandon Bowers
@Bowers96
Aug 04 2016 04:22
Anybody?
Julio Herrera
@julrom
Aug 04 2016 04:22
@CruiseDevice you have to assign the string with the escaped chain, you could \ to don't break the string or simply you can use '' inside the "this is and 'example'"
NixonRichard
@NixonRichard
Aug 04 2016 04:22
hmm
``````function bouncer(arr) {
// Don't show a false ID to this bouncer.
var falsy = [false, null,0, "", undefined,  NaN];

return arr.filter(function(val) {
for ( var i = 0; i < falsy.length; i ++){
return val != i;}
});

}

bouncer([false, null, 0, NaN, undefined, ""]);``````
Akash Chavan
@CruiseDevice
Aug 04 2016 04:23
@julrom Its little confusing. but i will try.
NixonRichard
@NixonRichard
Aug 04 2016 04:23
falsy boucner challenge lol
@michaeltnoronha This s some idea
bitgrower
@bitgrower
Aug 04 2016 04:23
carefully read the first recommended link on the challenge for falsy bouncer
I spent hours on falsy bouncer...even solved it ... but it was ugly ... then I went back and read the first recommended link, and solved it, elegantly, in about 5 minutes
domdion
@domdion
Aug 04 2016 04:25
this challenge is quite fun, as it can be solved in one line of code within the function using both concepts outlined in the help
bitgrower
@bitgrower
Aug 04 2016 04:25
so what kind of government do you have, @NixonRichard
NixonRichard
@NixonRichard
Aug 04 2016 04:26
@bitgrower hmm well socialism kind of
Julio Herrera
@julrom
Aug 04 2016 04:26
@CruiseDevice Could you put the link of the exercise?
NixonRichard
@NixonRichard
Aug 04 2016 04:26
but u still able to buy what u want
Brandon Bowers
@Bowers96
Aug 04 2016 04:27

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

``````
var myStr; // Change this line``````
Surbhi Oberoi
@surbhioberoi
Aug 04 2016 04:27
can someone explain me how a binary tree works? and how to solve it?
NixonRichard
@NixonRichard
Aug 04 2016 04:28
@bitgrower
im trying to find a english word can describe it
Chris Cullen
@123xylem
Aug 04 2016 04:29
``````function makeFriendlyDates(arr) {
var arr0 =arr.shift();//create first date
arr0= arr0.split(/-/);
for(i=0;i<arr0.length;i++){
switch (arr0[1]) {
case "01":
arr0[1] = "Janurary";
break;
case "02":
arr0[1] = "February";
break;
case "03":
arr0[1] = "March";
break;
case "04":
arr0[1] = "April";
break;
case "05":
arr0[1] = "May";
break;
case "06":
arr0[1] = "June";
break;
case "07":
arr0[1] = "July";
break;
case "08":
arr0[1] ="August";
break;

case "09":
arr0[1] ="September";
break;

case "10":
arr0[1] ="October";
break;

case "11":
arr0[1] ="November";
break;

case "12":
arr0[1] ="December";
break;

}switch (arr0[2]) {
case "01":
case "21":
case "31":
arr0[2] =arr0[2]+ 'st';
break;
case "02":
case "22":
arr0[2] =arr0[2]+'nd';
break;
case "03":
case "23":
arr0[2] =arr0[2]+ 'rd';
break;
default:
arr0[2] =arr0[2]+ 'th';
break;
}
}

return arr0;
}
makeFriendlyDates(['2016-07-12', '2016-07-04']);``````
This coe is returning 12thththth for some reason.. I have a feeling its to do with the for loop running 3 times but Im not sure.. Any ideas?
Orv Bongat
@orvb
Aug 04 2016 04:30
@surbhioberoi binary trees are best explained with visual aids, so for that i'd get on youtube, plenty of good explanations
Surbhi Oberoi
@surbhioberoi
Aug 04 2016 04:30
@orvb oh okay! thanks
CamperBot
@camperbot
Aug 04 2016 04:30
surbhioberoi sends brownie points to @orvb :sparkles: :thumbsup: :sparkles:
NixonRichard
@NixonRichard
Aug 04 2016 04:30
@bitgrower It was communist before 1995 but since 1996 they called it something like socialist market economy
THe main different is there s only one party
unlike two in the US
Brandon Bowers
@Bowers96
Aug 04 2016 04:35
`js`
```js
``````
var myStr = "Here is a backslash \\.\n\rHere is a new line with two tabs.";``````

You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words.

Here is the text with the escape sequences written out.

FirstLinenewlinebackslashSecondLinebackslashcarriage-returnThirdLine

Orv Bongat
@orvb
Aug 04 2016 04:38
@Bowers96 the instructions show you the end result its expecting and right now, your myStr is way off, re-read the instructions again
Akash Chavan
@CruiseDevice
Aug 04 2016 04:39
@Bowers96 i am also facing difficulty solving it.
CamperBot
@camperbot
Aug 04 2016 04:39

## :point_right: algorithm no repeats please [wiki]

:triangular_flag_on_post: Remember to use `Read-Search-Ask` if you get stuck. Try to pair program :busts_in_silhouette: and write your own code :pencil:

### :checkered_flag: Problem Explanation:

This task requires us to return the number of total permutations of the provided string that don't have repeated consecutive letters. It is to be assumed that all characters in the provided string are each unique. For example, `aab` should return 2 because it has 6 total permutations (`aab`, `aab`, `aba`, `aba`, `baa`, `baa`), but only 2 of them (`aba` and `aba`) don't have the same letter (in this case `a`) repeating.

To achieve that, we'll have to look at each possible permutation of a string. There are several ways to do that. A common interview question is building a function that collects all permutations of a string. There are several tutorials available on the internet on how to do that.

#### Potential Methods Used As Solution

##### Recursive Method

This task can be daunting even after watching a tutorial. To write a recursive solution, you will want to send each new use of the function three inputs:

1. A new string (or character array) that is being built.
2. A position in your new string that's going to be filled next.
3. An idea of what characters (more specifically positions) from the original string have yet to be used.
Orv Bongat
@orvb
Aug 04 2016 04:40
@CruiseDevice show your code so we can see where you're at
NixonRichard
@NixonRichard
Aug 04 2016 04:40
@bitgrower If u want to get it for ez then i wuold they say r bad just like most governments lol but u r fine if u have lots of money lol :smile:
Akash Chavan
@CruiseDevice
Aug 04 2016 04:42
``````
var myStr = "This is my first \'variable initialization\'"; // Change this line``````
Brandon Bowers
@Bowers96
Aug 04 2016 04:42
@CruiseDevice
``var myStr= "FirstLine\n\\SecondLine\\\rThirdLine";``
That is the correct code man.
@CruiseDevice *
Orv Bongat
@orvb
Aug 04 2016 04:44
@Bowers96 you're supposed to help him figure it out, not hand out the answer instantly =P
AndrewBeeh
@AndrewBeeh
Aug 04 2016 04:44

function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}

if (val) { // Change this line
return "Over 10";
}

return "10 or Under";
}

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

Brandon Bowers
@Bowers96
Aug 04 2016 04:44
True, he has been struggling for awhile though. @orvb
Michael Noronha
@mtn
Aug 04 2016 04:44
@Bowers96 Which is why it's more important to lead him through
@Bowers96 Greatest opp
Coy Sanders
@coymeetsworld
Aug 04 2016 04:45
@michaeltnoronha @orvb :thumbsup:
AndrewBeeh
@AndrewBeeh
Aug 04 2016 04:45
Can I get some help with this
Michael Noronha
@mtn
Aug 04 2016 04:45
@AndrewBeeh actually nevermind, not needed
Brandon Bowers
@Bowers96
Aug 04 2016 04:45
I agree but sometimes you won't get it and the answer is very beneficial. @orvb @michaeltnoronha
Michael Noronha
@mtn
Aug 04 2016 04:46
@AndrewBeeh What should be true, for you to return each of those statements?
@Bowers96 We'll have to agree to disagree, at least in that I don't this this was one of those times ;)
Brandon Bowers
@Bowers96
Aug 04 2016 04:47
Next time he comes across a situation like that he knows the format now sometimes these question are worded very weird. @michaeltnoronha
I agree. @michaeltnoronha
To disagree. @michaeltnoronha
Michael Noronha
@mtn
Aug 04 2016 04:48
:thumbsup: :)
Brandon Bowers
@Bowers96
Aug 04 2016 04:48
:clap: :smile:
Chris Cullen
@123xylem
Aug 04 2016 04:50
``````function makeFriendlyDates(arr) {
var arr0 =arr.shift();//create first date
arr0= arr0.split(/-/);

var arr1=arr.pop();//second date
arr1=arr1.split(/-/);

for(i=0;i<arr0.length;i++){ // Loop through Dates
switch (arr0[1]) { //For each case convert them to months
// FIRST DATES DELETED FOR VIEWER SAKE

//Here starts THE SECOND DATEs Conversion------------------------------------------------------

switch (arr1[2]) {
case "01":
arr1[2] = "Janurary";
break;
case "02":
arr1[2]= "February";
break;
case "03":
arr1[2] = "March";
break;
case "04":
arr1[2] = "April";
break;
case "05":
arr1[2] = "May";
break;
case "06":
arr1[2] = "June";
break;
case "07":
arr1[2] = "July";
break;
case "08":
arr1[2] ="August";
break;

case "09":
arr1[2] ="September";
break;

case "10":
arr1[2] ="October";
break;

case "11":
arr1[2] ="November";
break;

case "12":
arr1[2] ="December";
break;

}switch (arr1[2]) {
case "01":
case "21":
case "31":
arr1[2] =parseInt(arr1[2])+ 'st';
break;
case "02":
case "22":
arr1[2] =parseInt(arr1[2])+'nd';
break;
case "03":
case "23":
arr1[2] =parseInt(arr1[2])+ 'rd';
break;
default:
arr1[2] =parseInt(arr1[2])+ 'th';
break;
}
}

return arr0 +" "+ arr1;
}
makeFriendlyDates(['2016-07-12', '2016-07-02']);``````
Why is my last number saying nanthon the second date when both dates are converted the same?
NaNth
eg 2016 07 NaNth
bitgrower
@bitgrower
Aug 04 2016 04:51
@NixonRichard neither ... but I am old & disabled ...
Narendra Singh
@nakulrathore
Aug 04 2016 04:51
help: Make Unique Objects by Passing Parameters to our Constructor
CamperBot
@camperbot
Aug 04 2016 04:51

# Challenge Make Unique Objects by Passing Parameters to our Constructor

When you have a constructor but don't want to keep creating the same object, all you have to do is add parameters to the constructor the following way:

``````var Car = function(wheels, seats, engines) {

this.wheels = wheels;

this.seats = seats;

this.engines = engines;

};``````
Narendra Singh
@nakulrathore
Aug 04 2016 04:52
anyone???
NixonRichard
@NixonRichard
Aug 04 2016 04:53
@bitgrower u retired ?
Michael Noronha
@mtn
Aug 04 2016 04:53
Michael Noronha
@mtn
Aug 04 2016 04:55
@nakulrathore What do you have? When I clicked the link I couldn't really tell what you had going on
@nakulrathore (it looked like everything was on 2 lines)
silver537
@silver537
Aug 04 2016 04:56
NixonRichard
@NixonRichard
Aug 04 2016 04:56
``````function bouncer(arr) {
// Don't show a false ID to this bouncer.

return arr.filter(function(val) {

return val;}
);

}

bouncer([7, "ate", "", false, 9]);``````
this worked hmm
Michael Noronha
@mtn
Aug 04 2016 04:56
@silver537 Could you guide me on seek and destroy please?
Narendra Singh
@nakulrathore
Aug 04 2016 04:56
@silver537 @michaeltnoronha , i didnt understand the instruction in challenge
Michael Noronha
@mtn
Aug 04 2016 04:57
@nakulrathore You might want to start off just resetting the code :p
@nakulrathore Do you understand how the car constructor works?
silver537
@silver537
Aug 04 2016 04:57
@michaeltnoronha im on my phone not on the computer. Its gonna be hard to help with any code that requires thinking and specific instructions. Pastr your code and i can try.
bitgrower
@bitgrower
Aug 04 2016 04:57
@NixonRichard no ...
silver537
@silver537
Aug 04 2016 04:58
@NixonRichard try the Boolean object. Boolean (val)
Michael Noronha
@mtn
Aug 04 2016 04:58
@silver537 Not started writing yet, was just planning. The first thing (that I know everyone encounters) is I noticed there is only 1 param, but 3 args passed
bitgrower
@bitgrower
Aug 04 2016 04:58
NixonRichard
@NixonRichard
Aug 04 2016 04:59
Sorry i missed understanded u @bitgrower :smile:
@silver537 it worked no problem with it
Michael Noronha
@mtn
Aug 04 2016 04:59
@bitgrower refer to reply to silver :p
Narendra Singh
@nakulrathore
Aug 04 2016 04:59
@michaeltnoronha yup
silver537
@silver537
Aug 04 2016 04:59
@michaeltnoronha have you checked the relevant link? For arguments object.
bitgrower
@bitgrower
Aug 04 2016 04:59
ahh ... I see you haven't started ... and that's a good observation...that's why you should read up on the arguments object ... I think there's a link to the page
Michael Noronha
@mtn
Aug 04 2016 05:00
@silver537 read but not comprehended. I'll take another lookj
bitgrower
@bitgrower
Aug 04 2016 05:00

@bitgrower refer to reply to silver :p

NixonRichard
@NixonRichard
Aug 04 2016 05:00
@bitgrower but there s one greathing in my nation : there s no terror attack ever lol
silver537
@silver537
Aug 04 2016 05:00
@bitgrower he meant to see what he told me. Cause it answers you as well.
bitgrower
@bitgrower
Aug 04 2016 05:01
ah, thanks ...
Michael Noronha
@mtn
Aug 04 2016 05:01
@nakulrathore So currently, you are assigning properties of the object based on hardcoded values
@nakulrathore You want to change them so they can be assigned based on parameters
@nakulrathore Refer to the example to see how you would add parameters, if you're unsure
Narendra Singh
@nakulrathore
Aug 04 2016 05:01
@michaeltnoronha ty man , was just playing here . i know js all
CamperBot
@camperbot
Aug 04 2016 05:01
nakulrathore sends brownie points to @michaeltnoronha :sparkles: :thumbsup: :sparkles:
Michael Noronha
@mtn
Aug 04 2016 05:02
@nakulrathore lolk
bitgrower
@bitgrower
Aug 04 2016 05:02
@NixonRichard being subject to terror attacks are the result of many things ... :)
silver537
@silver537
Aug 04 2016 05:03
@michaeltnoronha are you familiar with es6?
Michael Noronha
@mtn
Aug 04 2016 05:03
@silver537 the term rings no bells
Aug 04 2016 05:03
hello
Rohit
@dorseta
Aug 04 2016 05:03
hi
bitgrower
@bitgrower
Aug 04 2016 05:03
@michaeltnoronha which challenge is @nakulrathore working on ?
Timothy Ah Koy
@TimothyFiji
Aug 04 2016 05:04
Hey everyone 😁 I'm in need of help for the Convert Celsius to Fahrenheit.
Aug 04 2016 05:04
this is my code
Narendra Singh
@nakulrathore
Aug 04 2016 05:04
@bitgrower Make Object Properties Private
Aug 04 2016 05:04
``````
// Setup
var collection = {
"2548": {
"album": "Slippery When Wet",
"artist": "Bon Jovi",
"tracks": [
"Let It Rock",
"You Give Love a Bad Name"
]
},
"2468": {
"album": "1999",
"artist": "Prince",
"tracks": [
"1999",
"Little Red Corvette"
]
},
"1245": {
"artist": "Robert Palmer",
"tracks": [ ]
},
"5439": {
"album": "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function updateRecords(id, prop, value) {

if(prop!== "tracks" ){
collection[id][prop]=value;
}
/** else if(prop !== "tracks" ){
//collection[id][prop]=value;
}**/

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

return collection;
}

// Alter values below to test your code
updateRecords(5439, "tracks", "Take a Chance on Me");``````
Michael Noronha
@mtn
Aug 04 2016 05:04
Rohit
@dorseta
Aug 04 2016 05:04
NixonRichard
@NixonRichard
Aug 04 2016 05:04
hmm
Aug 04 2016 05:04
why it's say ```
NixonRichard
@NixonRichard
Aug 04 2016 05:04
another record collection
bitgrower
@bitgrower
Aug 04 2016 05:04
yeah ... bothers a lot of folks ...
Michael Noronha
@mtn
Aug 04 2016 05:04
the same questions always show up in here :p
Aug 04 2016 05:05
``TypeError: Cannot read property 'push' of undefined``
can you help me @dorseta
Rohit
@dorseta
Aug 04 2016 05:05
can anybody sort out my problem
I don't know
Aug 04 2016 05:06
ok no prob @dorseta
silver537
@silver537
Aug 04 2016 05:07
FORGIVE ME im distracted by my cat crunching away a baby bunny. Sounds awesome!!
Markus Kiili
@Masd925
Aug 04 2016 05:07
@radityaputranto You need to check if the tracks array is present on the record before pushing.
Justin Steele
@JustinSteele02
Aug 04 2016 05:07
Is this bad? I feel like I'm living on the edge with a `while(true)` loop. My solution to Drop It challenge.
``````function dropElements(arr, func) {
while (true) {
var test = arr.slice(0, 1).filter(func);

if (test.length > 0 || arr.length === 0) {
return arr;
} else {
arr.shift();
}
}
}

dropElements([1, 2, 3], function(n) {return n < 3; });``````
bitgrower
@bitgrower
Aug 04 2016 05:08

@michaeltnoronha -- you can use the arguments object to access all the arguments passed to your function ... any number of parameters can be passed to a function ... the one you see in seek & destroy is "named" ... the others are not, so you must use the arguments object to access them ...

...the arguments object is an array-LIKE object, so you can get it's length, you can index into it like an array, but you cannot use array methods with it ... AND, the value of the arguments object changes when a new scope is opened (that is, if you call another function

So, if you want to use the values in the arguments object in another function, you will have to copy the values into local variables and pass those ...

Michael Noronha
@mtn
Aug 04 2016 05:08
@bitgrower thanks :thumbsup:
CamperBot
@camperbot
Aug 04 2016 05:08
michaeltnoronha sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:star2: 1166 | @bitgrower |http://www.freecodecamp.com/bitgrower
silver537
@silver537
Aug 04 2016 05:09
Holy shit. The bunny doesnt have a head anymore!!!
Michael Noronha
@mtn
Aug 04 2016 05:09
Markus Kiili
@Masd925
Aug 04 2016 05:10
@bitgrower More precise would be to say that every function (execution context) has its own arguments object, instead of arguments object's value changing.
silver537
@silver537
Aug 04 2016 05:11
Now its gnawing its way towards the abdomen
Aug 04 2016 05:12
@Masd925 so , i need create propertie "tracks" before push it ?
Markus Kiili
@Masd925
Aug 04 2016 05:12
@radityaputranto Yes, if it is absent.
Michael Noronha
@mtn
Aug 04 2016 05:15

@bitgrower I'm trying to construct my cb function rn: ``` return arr.filter(function(arguments[1],arguments[2]){

});```

@bitgrower where i do something inside the function
@bitgrower but it's setup all wrong
@silver537 Any chance you can tell what I'm doing wrong?
NixonRichard
@NixonRichard
Aug 04 2016 05:18
hmm hmm
Markus Kiili
@Masd925
Aug 04 2016 05:18
@michaeltnoronha The parameters of filter callback are the element being iterated by filter and the index of the element. The logic goes inside the callback.
tommy
@tommygebru
Aug 04 2016 05:19
@Masd925 :wave:
Markus Kiili
@Masd925
Aug 04 2016 05:19
The callback should return true for those elements that you like filter to keep.
Michael Noronha
@mtn
Aug 04 2016 05:20
@Masd925 so are you saying the filter iterates itself?
@Masd925 I was thinking of this wrong; I was thinking I needed a funtion that would return true for what I watned to keep and false otherwise, and I'd just pass that through the filter
Markus Kiili
@Masd925
Aug 04 2016 05:20
Yes, iterations and creation of the result array is done automatically under the hood.
silver537
@silver537
Aug 04 2016 05:20
The filter iterates through the array
Markus Kiili
@Masd925
Aug 04 2016 05:21
The callback tells filter how to filter one arbitrary array element.
Michael Noronha
@mtn
Aug 04 2016 05:21
What would the index of the element be?
Also, because arr was the argument explicitly passed (or whatever, not sure about terminology), can I just referr to it as arr or do I need to use the argument object for everything
Markus Kiili
@Masd925
Aug 04 2016 05:22
You should use parameters like `function(elem, index){...}`
Filter then passes an element to `elem` and index to `index`.
Michael Noronha
@mtn
Aug 04 2016 05:23
got it
Manish Giri
@Manish-Giri
Aug 04 2016 05:24
Michael Noronha
@mtn
Aug 04 2016 05:24
@silver537 @Masd925 Thanks for the help so far
CamperBot
@camperbot
Aug 04 2016 05:24
michaeltnoronha sends brownie points to @silver537 and @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2226 | @masd925 |http://www.freecodecamp.com/masd925
bitgrower
@bitgrower
Aug 04 2016 05:26

@bitgrower More precise would be to say that every function (execution context) has its own arguments object, instead of arguments object's value changing.

yes ... it is more accurate ... I was trying to get around the fact that they would expect to say arguments[0] in one context and expecting it to be the same in the new context ...

Peter
@NeonKraze
Aug 04 2016 05:26

Ok, I'm confused on this one, I am not sure on how to finish this, I currently am on the Challenge counting cards, I can't for the life of me figure out how to get it to print the string " Hold" or " Bet" at the end of the value set for the variable count here is my code let me know if I'm doing it wrong. I tried using an if statment as well as a switch but for some reason it keeps adding it to the end of each number which I am not surprised about I just can't wrap my head around it
```

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 = count + 1;
break;
}
switch (card){
case 7:
case 8:
case 9:
count = count +0;
break;
}
switch (card){
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count = count -1;
break;
}

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

// Note: Only the last will display
cc(3); cc(2); cc(3); cc(3); cc(2);

silver537
@silver537
Aug 04 2016 05:26
You can, however, set up the call back to check if the other two arguments exist inside the array. Using the filter. Youll iterate the array argument, and check if argument 1 and argument 2 is indexof the element in argument array. Remember, the filter returns negative 1 if the test fails.
@michaeltnoronha
Aug 04 2016 05:26
@Masd925 oke thanks
CamperBot
@camperbot
Aug 04 2016 05:26
radityaputranto sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2227 | @masd925 |http://www.freecodecamp.com/masd925
silver537
@silver537
Aug 04 2016 05:27
@Manish-Giri dude she ate the entire bunny. And i watched the whole thing i even helped chopping up the bunny into pieces.
Manish Giri
@Manish-Giri
Aug 04 2016 05:27
@silver537 :cat2:
@silver537 get another bunny
Michael Noronha
@mtn
Aug 04 2016 05:28
``````
function destroyer(arr) {
// Remove all the values
return arr.filter(function(elem, index){
return (arr[index] !== arguments[1] && arr[index] !== arguments[2]);
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
@silver537 @Masd925 What sily thing am I doing?
oh wait
don't tell me
nevermind still wrong
Markus Kiili
@Masd925
Aug 04 2016 05:29
@michaeltnoronha The filter callback has its own arguments object.
Michael Noronha
@mtn
Aug 04 2016 05:29
@Masd925 oh shoot. should I make local vars?
Markus Kiili
@Masd925
Aug 04 2016 05:29
@michaeltnoronha You can store destroyers arguments object on a variable, yes.
Or pass it into callback as value of `this`.
You should loop arguments instead of hardcoding the number of arguments.
Aaron Nethersole
@Aaron85
Aug 04 2016 05:30
Its still asking me to "The property nickname of myCar should be a string" but I have a string for it.... dont I?

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

// Only change code below this line.

var myCar = new Car();

myCar.turboType = "twin";

Michael Noronha
@mtn
Aug 04 2016 05:30
``````
function destroyer(arr) {
// Remove all the values
arg1 = arguments[1];
arg2 = arguments[2];
return arr.filter(function(elem, index){
return (elem[index] !== arg1 && elem[index] !== arg2);
});
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
silver537
@silver537
Aug 04 2016 05:30
@Masd925 youve got some weird methods.
Markus Kiili
@Masd925
Aug 04 2016 05:31
`var args = arguments;` is better and then loop args.
eeflores
@eeflores
Aug 04 2016 05:31
maybe `myCar.nickname = "bob";`
0b4cL
@0b4cL
Aug 04 2016 05:31

Okay, I passed this exercise but don't fully understand why. Could anybody shed some light? function caseInSwitch(val) {
// Only change code below this line
switch (val) {
case 1:
return "alpha";
break;
case 2:
return "beta";
break;
case 3:
return "gamma";
break;
case 4:
return "delta";
break;
console.log('Please pick a value from "alpha" to "delta"!');
}

// Only change code above this line
}

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

Markus Kiili
@Masd925
Aug 04 2016 05:31
@silver537 What weird methods?
Michael Noronha
@mtn
Aug 04 2016 05:31
what I just posted isn't passing
0b4cL
@0b4cL
Aug 04 2016 05:31
Selecting from many options with Switch Statements
silver537
@silver537
Aug 04 2016 05:32
made me get on the comp. -.-
Michael Noronha
@mtn
Aug 04 2016 05:32
@Masd925 Anything else I'm misunderstanding?
@Masd925 currently failing the 3rd test, destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].
Markus Kiili
@Masd925
Aug 04 2016 05:33
@michaeltnoronha `elem` is the array element being iterated by filter. No need for array access.
Manish Giri
@Manish-Giri
Aug 04 2016 05:34
@0b4cL you should probably be assigning `alpha` or `beta` to `answer` in each `case`, instead of `return`
``````case 1: answer = “alpha”;
break;``````
cdcrowther
@cdcrowther
Aug 04 2016 05:35
@NeonKraze : I did an if/then formula after the count. If (count > 0) { return count + " Bet;) } else { return count + " Hold";}. I'm sure there are other ways but it worked for me.
Michael Noronha
@mtn
Aug 04 2016 05:36
@Masd925 ah I see why you recommended looping
@Masd925 passing for now, but I'll need to revisit this to really understand it fully
@Masd925 @silver537 thanks for your help/guidnace/patience
CamperBot
@camperbot
Aug 04 2016 05:36
michaeltnoronha sends brownie points to @masd925 and @silver537 :sparkles: :thumbsup: :sparkles:
:warning: michaeltnoronha already gave silver537 points
:warning: michaeltnoronha already gave masd925 points
Peter
@NeonKraze
Aug 04 2016 05:36
@cdcrowther yeah oh! if I scoot the function down so that it doesn't add ' bet' and ' Hold' then in theory it should work. but theres always that "in Theory" haha
Markus Kiili
@Masd925
Aug 04 2016 05:36
@michaeltnoronha ok. An easier way is to turn arguments object into an array and use indexOf inside the callback.
Chris Cullen
@123xylem
Aug 04 2016 05:37
This message was deleted
0b4cL
@0b4cL
Aug 04 2016 05:37
@Manish-Giri okay thanks alot. :+1:
CamperBot
@camperbot
Aug 04 2016 05:37
0b4cl sends brownie points to @manish-giri :sparkles: :thumbsup: :sparkles:
:star2: 1599 | @manish-giri |http://www.freecodecamp.com/manish-giri
Manish Giri
@Manish-Giri
Aug 04 2016 05:37
@0b4cL welcome
Jonathan Leon
@Wo1v3r
Aug 04 2016 05:38
Guys this works but I wonder how could I make it more efficent? not sure if I nailed closures yet
``````function myNaN(num){
return (typeof(num)!=='number');
}

if (myNaN(arguments[0])) return undefined;

if (arguments.length === 2 ){
if (myNaN(arguments[1])) return undefined;
return arguments[0]+arguments[1];
}

var operand1 = arguments[0]; //For closure scope

return function(operand2){
if (myNaN(operand2))return undefined;
return operand1 + operand2;
};
}

Chris Cullen
@123xylem
Aug 04 2016 05:39

Quick Question: Why is my switch going straight to default???

``````function makeFriendlyDates(arr) {
var arr0 =arr.shift();//create first date
arr0= arr0.split(/-/);

var arr1=arr.pop();//second date
arr1=arr1.split(/-/);

for(i=0;i<arr0.length;i++){ // Loop through Dates
switch (arr0[1]) { //For each case convert them to months
case "01":
arr0[1] = "Janurary";
break;
case "02":
arr0[1] = "February";
break;
case "03":
arr0[1] = "March";
break;
case "04":
arr0[1] = "April";
break;
case "05":
arr0[1] = "May";
break;
case "06":
arr0[1] = "June";
break;
case "07":
arr0[1] = "July";
break;
case "08":
arr0[1] ="August";
break;

case "09":
arr0[1] ="September";
break;

case "10":
arr0[1] ="October";
break;

case "11":
arr0[1] ="November";
break;

case "12":
arr0[1] ="December";
break;

}switch (arr0[2]) { //Then for each day date convert to days
case "01":
case "21":
case "31":
arr0[2] =parseInt(arr0[2])+ 'st';
break;
case "02":
case "22":
arr0[2] =parseInt(arr0[2])+'nd';
break;
case "03":
case "23":
arr0[2] =parseInt(arr0[2])+ 'rd';
break;
default:                                 //With this default that adds "th"
arr0[2] =parseInt(arr0[2])+ 'th';
break;
}

//Here starts THE SECOND DATEs Conversion------------------------------------------------------
//I took them out as they same as first and long to look at

}

return arr0 +" "+ arr1;
}
makeFriendlyDates(['2016-07-01', '2016-07-02']);``````

As you can see 2016 07 01 becomes 01th when theres a case that says it should be 01st? What gives !!!

Markus Kiili
@Masd925
Aug 04 2016 05:39
@Wo1v3r Better place for working code is https://gitter.im/FreeCodeCamp/CodeReview
cdcrowther
@cdcrowther
Aug 04 2016 05:40
@NeonKraze it should. I put in your code and then added the if/then statement and it worked. You just need to concatenate the count and the " bet" or " hold" strings
Jonathan Leon
@Wo1v3r
Aug 04 2016 05:41
@Masd925 Ok ty
CamperBot
@camperbot
Aug 04 2016 05:41
wo1v3r sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2228 | @masd925 |http://www.freecodecamp.com/masd925
mattcharlesh
@mattcharlesh
Aug 04 2016 05:44

function checkObj(checkProp) {

if (myObj.hasOwnProperty(checkProp) = true) {
return myObj.checkProp ;
} else {
return false ;
}
}

What is wrong with this?
Markus Kiili
@Masd925
Aug 04 2016 05:44
@mattcharlesh The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: `var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants"`. Bracket notation works with keys that can be arbitrary strings `cat["lives left"]; //returns 3`, variables `var key="clothes"; cat[key]; //returns "pants"`, or expressions `cat["lives"+" "+"left"]; //returns 3`.
So `.checkProp` is not doing what you need.
Bar Akiva
@Gitity
Aug 04 2016 05:48
Anyone online?
Aug 04 2016 05:48
@Gitity sure ;)
Bar Akiva
@Gitity
Aug 04 2016 05:48
:)
Olga C
@Octopinky
Aug 04 2016 05:48
@Gitity yes
Aug 04 2016 05:49
Bar Akiva
@Gitity
Aug 04 2016 05:49
I fiddled with dev tools and found out all JS methods, including Jquery, are contained inside the global object (window).
Why is that?
Caleb Catt
@cattman42
Aug 04 2016 05:51
'''
help
'''
CamperBot
@camperbot
Aug 04 2016 05:51

# CamperBot

### Basic Commands:

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

meet CamperBot in

Olga C
@Octopinky
Aug 04 2016 05:52
@Gitity I would not know :(
@cattman42 what do you need help with?
mattcharlesh
@mattcharlesh
Aug 04 2016 05:53
thanks @Masd925 But I still reaching to understand what you are talking about ...
CamperBot
@camperbot
Aug 04 2016 05:53
mattcharlesh sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2229 | @masd925 |http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Aug 04 2016 05:53
@Gitity They have to reside somewhere in order to be used.
Global variables are properties of the global object.
Caleb Catt
@cattman42
Aug 04 2016 05:54

var y = 1;
var total = 1;
var myArray = [];
function factorialize(num) {
while(y <= num) {
myArray.push(y);
y++;
}

for (var i = 0; i< myArray.length; i++)
{
total *= myArray[i];
}

}

factorialize(5);

```

``````var y = 1;
var total = 1;
var myArray = [];
function factorialize(num) {
while(y <= num) {
myArray.push(y);
y++;
}
for (var i = 0; i< myArray.length; i++)
{
total *= myArray[i];
}
}
factorialize(5);``````
Bar Akiva
@Gitity
Aug 04 2016 05:55
@Masd925 so in general, functions, native methods and outside libraries like Jquery are all essentially invocable properties of an object, which is the global object? Yeah?
@cattman42 i dont think you need a while loop for this one
Markus Kiili
@Masd925
Aug 04 2016 05:56
@Gitity Yes.
Bar Akiva
@Gitity
Aug 04 2016 05:56
@Masd925 thanks!
CamperBot
@camperbot
Aug 04 2016 05:56
gitity sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 2230 | @masd925 |http://www.freecodecamp.com/masd925
Bar Akiva
@Gitity
Aug 04 2016 05:57
@Masd925 is this the same with other languages as well?
Picshulo
@Picshulo
Aug 04 2016 05:57
Caleb Catt
@cattman42
Aug 04 2016 05:58
@Gitity Thank you for your help
CamperBot
@camperbot
Aug 04 2016 05:58
cattman42 sends brownie points to @gitity :sparkles: :thumbsup: :sparkles:
Caleb Catt
@cattman42
Aug 04 2016 05:58
@Picshulo That worked!!! Thank you!! any reason why?
CamperBot
@camperbot
Aug 04 2016 05:58
cattman42 sends brownie points to @picshulo :sparkles: :thumbsup: :sparkles:
Bar Akiva
@Gitity
Aug 04 2016 05:59
@cattman42 its considered bad practice to have your variables outside of the function that requires them
they are "global" and thus can interfere with other stuff
Caleb Catt
@cattman42
Aug 04 2016 05:59
@Gitity Otay, that makes sense, is that why it was blocking me from completing it?
I tried lots of stuff lol I tried type converting to allllll different types -_-
Bar Akiva
@Gitity
Aug 04 2016 06:00
it shouldnt block it. I suggest you go inside other peoples profiles and see how they solved this lesson
most likely their code will be of higher quality
its not just about solving the lesson, its about solving it effectively
Markus Kiili
@Masd925
Aug 04 2016 06:01
@Gitity I haven't seen it as explicitly defined in other languages. Some languages talk about namespaces etc.
Caleb Catt
@cattman42
Aug 04 2016 06:01
There was some talk about recursive but I've no idea what that stuff is, it looked crazy! I usually do look at other people's code but really wanted to do this challenge 100% on my own
Bar Akiva
@Gitity
Aug 04 2016 06:02
@Masd925 i recall something about namespaces from c#. You could say namespaces or global objects are different lingos for similar things yeah?
@cattman42 dont think about recursive now. No CS or theoretical stuff. Just write code and learn to solve problems
its a waste of time and you will forget even if you manage to get it
What i do is try to solve a lesson. Once it is solved I look at other solutions to see how I could do better
Markus Kiili
@Masd925
Aug 04 2016 06:03
@Gitity Yes, those names reside somewhere, but in JS it is an accessable object.
Caleb Catt
@cattman42
Aug 04 2016 06:04
That sounds like a good idea, thank you for the help again @Gitity
CamperBot
@camperbot
Aug 04 2016 06:04
cattman42 sends brownie points to @gitity :sparkles: :thumbsup: :sparkles:
:warning: cattman42 already gave gitity points
Bar Akiva
@Gitity
Aug 04 2016 06:05
No problem! Always remember to see how other people solve the problems you are trying to solve
Jonathan Leon
@Wo1v3r
Aug 04 2016 06:10
Is there a way to debug js step by step ?
Abis Mal
@abisthecodermal
Aug 04 2016 06:11
@Manish-Giri, for you
Hao Tao
@Ka1evi
Aug 04 2016 06:11
Manish Giri
@Manish-Giri
Aug 04 2016 06:12
@manucpp haha
@Wo1v3r one sec, hold on
0b4cL
@0b4cL
Aug 04 2016 06:13

Hey guy's
Why doesn't this code work in Adding a default option in switch?

function sequentialSizes(val) {
// Only change code below this line
switch(val) {
case 2:
case 2:
case 3:
result = "Low";
break;
case 4:
case 5:
case 6:
result = "Mid";
break;
case 7:
case 8:
case 9:
result = "High";
break;
}

// Only change code above this line
}

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

Manish Giri
@Manish-Giri
Aug 04 2016 06:13

@Wo1v3r go here - :point_up: August 4, 2016 11:14 AM

then scroll down n read through

Jonathan Leon
@Wo1v3r
Aug 04 2016 06:15
@Manish-Giri go where sorry :D
Robert Richey
@0x0936
Aug 04 2016 06:15
@0b4cL I don't see a default option
0b4cL
@0b4cL
Aug 04 2016 06:16
Ah I see.
Robert Richey
@0x0936
Aug 04 2016 06:16

@0b4cL you'll need to change the case options

Write a switch statement to set answer for the following conditions:
"a" - "apple"
"b" - "bird"
"c" - "cat"
default - "stuff"

@prdpsn
Aug 04 2016 06:16
can anyone help me with the exercise of "Using Objects for Lookups" in javascript?
0b4cL
@0b4cL
Aug 04 2016 06:18
@0x0936 I passed that exercise. this is Multiple Identical Options in Switch Statements. Still having trouble.
Tenzin Namgyel
@tenraj
Aug 04 2016 06:18
Somebody help me with Using Objects for Lookups challenge https://www.freecodecamp.com/challenges/using-objects-for-lookups
Robert Richey
@0x0936
Aug 04 2016 06:19
@0b4cL gotcha. you repeated `case 2`. need a case 1
@prdpsn
Aug 04 2016 06:20

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

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

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

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

what else should i write?
0b4cL
@0b4cL
Aug 04 2016 06:21
@0x0936 Thanks.
CamperBot
@camperbot
Aug 04 2016 06:21
0b4cl sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:star2: 1634 | @0x0936 |http://www.freecodecamp.com/0x0936
Picshulo
@Picshulo
Aug 04 2016 06:22
@prdpsn "Use it to lookup val and assign the associated string to the result variable." That means result should be equal to lookup[val]
0b4cL
@0b4cL
Aug 04 2016 06:22

function sequentialSizes(val) {
// Only change code below this line
switch(val) {
case 1:
case 2:
case 3:
result = "Low";
break;
case 4:
case 5:
case 6:
result = "Mid";
break;
case 7:
case 8:
case 9:
result = "High";
break;
default:
}

// Only change code above this line
}

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

Jonathan Leon
@Wo1v3r
Aug 04 2016 06:22
If anyone wants to pair on 'Spinal Tap Case' and 'Smallest Common multipiles' I've been stuck on them for a while so welcome to study together :3
Christy Muniz
@tidus37
Aug 04 2016 06:22

Hi guys! I'm running into a bit of problems with Generating a whole number with Javascript

``````
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.
Math.floor(Math.random() * 10);

return Math.random();
}``````

am I missing something?

0b4cL
@0b4cL
Aug 04 2016 06:22
Still not getting any returns. Really stumped.
Manish Giri
@Manish-Giri
Aug 04 2016 06:23
@Wo1v3r click on the blue link in my previous message
Jonathan Leon
@Wo1v3r
Aug 04 2016 06:24
@Manish-Giri Oh I used to do that when writing my own js files but was wondering if its possible through fcc's challenge system \ codepen.io
Robert Richey
@0x0936
Aug 04 2016 06:24
@0b4cL `answer` is the variable in that challenge to assign to, not `result`
Picshulo
@Picshulo
Aug 04 2016 06:24
@tidus37 I know how it should look right but i won't be able to explain it with my sucky english.. if no one helps, i'll try
Robert Richey
@0x0936
Aug 04 2016 06:25
@0b4cL also, don't need a default case for that one - just like we don't always need to write an `else` conditional to an `if` statement
@prdpsn
Aug 04 2016 06:25
got it. Thanku @Picshulo :smile:
CamperBot
@camperbot
Aug 04 2016 06:25
prdpsn sends brownie points to @picshulo :sparkles: :thumbsup: :sparkles:
Christy Muniz
@tidus37
Aug 04 2016 06:25
It's ok @Picshulo no worries
Picshulo
@Picshulo
Aug 04 2016 06:25
@prdpsn
Aug 04 2016 06:26
thankyou @Picshulo
CamperBot
@camperbot
Aug 04 2016 06:26
prdpsn sends brownie points to @picshulo :sparkles: :thumbsup: :sparkles:
:warning: prdpsn already gave picshulo points
0b4cL
@0b4cL
Aug 04 2016 06:27
@0x0936 Thanks man. Passed it now. You da best.
CamperBot
@camperbot
Aug 04 2016 06:27
0b4cl sends brownie points to @0x0936 :sparkles: :thumbsup: :sparkles:
:warning: 0b4cl already gave 0x0936 points
Robert Richey
@0x0936
Aug 04 2016 06:27
:+1:
Hao Tao
@Ka1evi
Aug 04 2016 06:29
Can anyone help me with the challenge of "Word Blanks" in javascript? :worried: ried:
ahmed abouhay
@abohay
Aug 04 2016 06:29
``````
function titleCase(str) {
var strlow = str.toLowerCase();
var arrone = strlow.split(" ");
for (var i = 0 ; i < arrone ; i++ ){
var arrtwo = arrone[i].split('');
arrtwo[0].toUpperCase();
var arrtwoj= arrtwo.join('');
}
var allj = arrone.join(" ");
return allj;
}

titleCase("I'm a little tea pot");``````
anyone could help me
Picshulo
@Picshulo
Aug 04 2016 06:32
@tidus37 Ok, let's try :D you have to return whole (sample?), not just Math.random().. that means
``return Math.floor(Math.random() * 10);``
Robert Richey
@0x0936
Aug 04 2016 06:34
@abohay describe what `arrone` is after `strlow.split(' ')`
Enrique Alejandro Arzamendi Picazzo
@AleCx4
Aug 04 2016 06:34
hi guys!
Picshulo
@Picshulo
Aug 04 2016 06:34
@Ka1evi Sure, where is your problem?
Manish Giri
@Manish-Giri
Aug 04 2016 06:34
@Wo1v3r Ah I see. No idea about codepen. I do remember seeing a "debug mode" though.
Chris Cullen
@123xylem
Aug 04 2016 06:34

QUICK QUESTION: How can I make a concise codefor removing duplicates here without popping or shifting an element?

``````answer.push(arr0[0]+" " +arr0[1]+ " " +arr0[2]+ "," + " " +arr1[0]+" "+ arr1[1]+" " +arr1[2]);
if(arr0[0]==arr1[0]){

}

Do i have to just write it out like return arr1 + arr 1 +arr2 1 + arr2 1 etc or ist there a cheat?

Enrique Alejandro Arzamendi Picazzo
@AleCx4
Aug 04 2016 06:34
quick question, anyone have any good tutorials for parsing JSON with jquery? some recommendations would be nice, I have already found some online but wanted to see if anyone knew of anything else to use as wwell
Ariel Moctezuma
@KyleMoctezuma
Aug 04 2016 06:39
having problems with a challenge( increment a number with javescript) is this right var myVar = i++; \ myVar = 87 i = 1
Jellal
@15371584703
Aug 04 2016 06:40
if(arr0[0]==arr1[0]){
}
Robert Richey
@0x0936
Aug 04 2016 06:40
@abohay I'm trying to get you to say something like 'an array of lowercase words'. Now look at your for loop - the condition is `i < arrone` there's something missing here. Any idea what it is?
Chris Cullen
@123xylem
Aug 04 2016 06:41
@15371584703 i didnt get that
I tried .indexOf here but wasnt sure exactly how to use it
silver537
@silver537
Aug 04 2016 06:44
@123xylem using the Set object
Robert Richey
@0x0936
Aug 04 2016 06:44
@123xylem an easy way to get uniques is to use a Set
``````var arr = [1, 1, 2, 2, 3, 3];
var set = new Set(arr);
var uniques = [...set]; // [1, 2, 3]``````
Chris Cullen
@123xylem
Aug 04 2016 06:48
@0x0936 never seen that before il have a look#
@0x0936 how do i search for it in a video
set doesnt come up with anything
Robert Richey
@0x0936
Aug 04 2016 06:50
I don't understand the question
silver537