11th
Jun 2016
bitgrower
@bitgrower
Jun 11 2016 00:01
@tertiaryidentifier recursion is a basic type of algorithm used in programming to solve a certain class of problems ... :) ... and something a lot of programmers don't fully understand ... there are lots of resources on the web to help you out -- I'm not even going to begin to try and explain that here :)
however, anyone who is mucking about with arrays and array.reduce -- I would have thought had been exposed to it already ! :)
John
@tertiaryidentifier
Jun 11 2016 00:04
okay, thanks for the help @bitgrower
CamperBot
@camperbot
Jun 11 2016 00:04
tertiaryidentifier sends brownie points to @bitgrower :sparkles: :thumbsup: :sparkles:
:warning: tertiaryidentifier already gave bitgrower points
John
@tertiaryidentifier
Jun 11 2016 00:05
icky feeling that this is not right
var product = 1;

function factorialize(num) {
for (i = 0; i == num; i++) {
}

}

factorialize(5);
grrrr why does it show up in grey .... something's wrong with that syntax
i am so confused :'(
halp
is anyone there .... @bitgrower
Jaren Escueta
@jarenescueta731
Jun 11 2016 00:11
@tertiaryidentifier i don't know why it's greyed out, but i can say you only need one equal sign for i=num in the for loop
@tertiaryidentifier also you're treating your var product as if it's a function
John
@tertiaryidentifier
Jun 11 2016 00:13
@jarenescueta731 lol yeah it's a hot mess ... doing a little bit of reading, gonna have something entirely new in a few seconds
ugh, why didn't freecodecamp point to assignment operators instead of arithmetic operators? would have made my life SO much easier
okay, now that I have changed this SO MUCH, my question is why this isn't working ...
var product = 1;

function factorialize(num) {
for (i = 1; i <= num; i++) {
product *= i;
}
return product;
}

factorialize(5);
because factorialize(5) actually returns 120 now
but the challenge says it doesn't ...
Taur'e Anthony
@k0decraft
Jun 11 2016 00:17
I'm to the point now where I have to ask "how to do this" on each challenge...maybe the instructions/examples aren't elementary enough for me...anyways...on the challenge Testing Objects for Properties what exactly is it asking here....and is my code in the general idea of it?

// Setup
var myObj = {
pet: 'kitten',
bed: 'sleigh',
};

function checkObj( checkProp ) {

}

// Test your code by modifying these values
checkObj( 'gift' );
John
@tertiaryidentifier
Jun 11 2016 00:19
@k0decraft , I definitely felt the same way with most of those challenges. let me take a look at my own code and compare
@k0decraft hint, you want to use an if / else scheme here
This message was deleted
This message was deleted
function checkObj( checkProp ) {

myObj.hasOwnProperty( 'gift' );   // as written, this evaluates to either true or false, and has no effect on the function or what it returns. just a statement, not a piece of code that "does something"

return 'Not Found'; // each time the function is run, it will always return 'Not Found', because this is line is not conditional on whether anything is true or not
}
sorry, very messy ... hope you can read my notes @k0decraft
Taur'e Anthony
@k0decraft
Jun 11 2016 00:23
@tertiaryidentifier Hey man, thanks for the input. Do I really need to use if/else here though? Like, should I start using things outside of the examples to get the code working? I know in coding there are several ways to get a same result.
CamperBot
@camperbot
Jun 11 2016 00:23
k0decraft sends brownie points to @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
John
@tertiaryidentifier
Jun 11 2016 00:24
@k0decraft I don't see a way to complete the challenge without if/else, and yes, most of the challenges after that require you to use skills that you previously learned and built upon
considering that the challenge says:
Modify the function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not, return "Not Found".
That's a pretty big hint that if/else is required
Tulio Natale
@tuliodnw
Jun 11 2016 00:26
people help, if i have button with sound, how can i make it that when i press the button a second time, it will cut the sound and will start it again from 0,
Taur'e Anthony
@k0decraft
Jun 11 2016 00:27
Ok, thanks @tertiaryidentifier ... I see we have to READ and catch those keywords as they are very sneaky...but I don't I have really learned anything yet, I've just gone through the challenges but nothing has stuck.
CamperBot
@camperbot
Jun 11 2016 00:27
k0decraft sends brownie points to @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave tertiaryidentifier points
John
@tertiaryidentifier
Jun 11 2016 00:28
@k0decraft it will stick eventually. i'd recommend browsing https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference to get a handle on generic javascript concepts
skipperhi
@skipperhi
Jun 11 2016 00:30
Why is the variable flase always returning true, even when arr has false values?
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var flase = flase;
for (var i = 0; i < arr.length; i++) {
flase = new Boolean(arr[i]);
}
var filteredArr = arr.filter(function(val) {
if (flase === true) {
return true;
} else {
return false;
}
});

return flase;
}
Jason Shoemaker
@kutsuya1
Jun 11 2016 00:31
This message was deleted
Taur'e Anthony
@k0decraft
Jun 11 2016 00:34
@tertiaryidentifier Thanks man, but I have a dilemma about MDN, us beginners are pointed to go there, but their explanations suck on a beginner level...like who wrote that stuff? Oh, seasoned developes did....in which it creates a difficult barrier of entry. It gets alot of hate...but W3Schools does it a little better. I want Nintendo to teach me how to code !
CamperBot
@camperbot
Jun 11 2016 00:34
k0decraft sends brownie points to @tertiaryidentifier :sparkles: :thumbsup: :sparkles:
:warning: k0decraft already gave tertiaryidentifier points
John
@tertiaryidentifier
Jun 11 2016 00:35
@k0decraft , I agree. for each challenge you can also google the name of the challenge and "free code camp". usually there's a reddit discussion or a github discussion about one user's solution and a bunch of people explaining things in the comments
FCC is all like "don't look at other people's code!!!", but I like to see an example done really well and understand it, not try to spontaneously create a perfect answer
Taur'e Anthony
@k0decraft
Jun 11 2016 00:37
@tertiaryidentifier I agree.
Brendan Kinahan
@BKinahan
Jun 11 2016 00:40
You know, there are pages in the wiki with solutions to many challenges.
skipperhi
@skipperhi
Jun 11 2016 00:40
Never mind, found a solution to my problem. Never knew that .filter(Boolean) was a thing...
@BKinahan I know, but I go there just to get the hints, not the answers
Arjun
@arjunsingh81989
Jun 11 2016 00:47
I have a question on Responsive Images. Does resolution of an image mean "display width and height" or "natural width and height"?
skipperhi
@skipperhi
Jun 11 2016 00:52
What does the arguments object do? I didn’t understand what they said…
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Alissa
@aherbert78
Jun 11 2016 00:55
I'm stuck on the record collection challenge. I can't figure out how to create a new object within the array when it doesn't already exist. So far, I have this:
David Halls
@DavidHalls
Jun 11 2016 00:55
Alissa
@aherbert78
Jun 11 2016 00:56

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

return collection;

}

roseslee
@roseslee
Jun 11 2016 00:56
Hi fellow campers,
I have a questions about the Record Collection problem.
Can someone point out to me why this code doesn't work?
function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection.id[prop] = value;
} else if (value !== "" && prop === "tracks") {
collection.id[prop].push(value);
} else if (value === "") {
delete collection.id[prop];
}
return collection;
}
Emmanuelle DeBarge
@emmanuelledebarge
Jun 11 2016 00:57
This message was deleted
function factorialize(num) {

if(num <= 1) {
return num;
}

else {
return num * factorialize(num-=1);
}

}

factorialize(0);
hey guys how do i make 0 factor into 1?
David Halls
@DavidHalls
Jun 11 2016 00:59
@aherbert78 hasOwnProperty is alerady a boolean, take off the ===false and it would return true
@emmanuelledebarge use a for loop
Alissa
@aherbert78
Jun 11 2016 01:01
@Byzgig but i only want to create the new object if hasOwnProperty returns false
Luke
@lhovee
Jun 11 2016 01:01
hey guys! I don't know why (2,"3") (2)([3]) and some URL don't return undefined ... help please


for (var i=1; i<arguments.length; i++) {
if (isNaN(arguments[i])) {return undefined;}
return base +=arguments[i];
}

function inside(ace) {
if (isNaN(ace)) {return undefined;}
return base+=ace;
}
return inside;
}

addTogether(2,3);
Emmanuelle DeBarge
@emmanuelledebarge
Jun 11 2016 01:02
@Byzgig ok
David Halls
@DavidHalls
Jun 11 2016 01:02
@aherbert78 you could put an ! in front of it, or rewrite your code so you are working on the true side
Alissa
@aherbert78
Jun 11 2016 01:04
@Byzgig yeah i was just thinking about nesting an if statement within an if
Rafael Gerônimo
@rafaelgeronimo
Jun 11 2016 01:04

Hi! Can you explain me why this solution for the Profile Lookup problem don't work?

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for(var i = 0; i < contacts.length; i++){
if(contacts[i].firstName === firstName){
if(contacts[i].hasOwnProperty(prop)){
return contacts[i][prop];
}else return "No such property";
}else{
return "No such contact";
}
}
// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");

Thanks!

David Halls
@DavidHalls
Jun 11 2016 01:05
@aherbert78 i think that is a good idea
Rafael Gerônimo
@rafaelgeronimo
Jun 11 2016 01:09
Forget! I just found the error :smile:
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:22
need help on this problem,

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

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

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

convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
David Halls
@DavidHalls
Jun 11 2016 01:23
@ryzhkale you are not assigning anything to any variable
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:23
what u mean
David Halls
@DavidHalls
Jun 11 2016 01:24
@ryzhkale what is this doing celsius * 9/5 + 32;
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:24
converting celsium to fehrinhiet
David Halls
@DavidHalls
Jun 11 2016 01:25
@ryzhkale what var is storing the result?
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:25
fahrenheit
David Halls
@DavidHalls
Jun 11 2016 01:27
@ryzhkale you need to review celsius * 9/5 + 32; it is not being assigned to anything,
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:35

function convertToF(celsius) {
var fahrenheit;
// Only change code below this line
fahrenheit = -30 9/5 +32;
fahrenheit = -10
9/5 +32;
fahrenheit = 0 * 9/5 +32;

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

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

David Halls
@DavidHalls
Jun 11 2016 01:37
@ryzhkale close, take two of those fahrenheit statements out and replace the first number after the = with celsius and i think you'll have it
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:37
i assigned it to fahrenheit but it converts only last one, hot do i make it covert to all numners that i need it convertToF(0) should return a number
convertToF(-30) should return a value of -22
convertToF(-10) should return a value of 14
convertToF(0) should return a value of 32
convertToF(20) should return a value of 68
convertToF(30) should return a value of 86
David Halls
@DavidHalls
Jun 11 2016 01:38
@ryzhkale with celsius *
Alan Saber
@Alan95
Jun 11 2016 01:38
help Iterate over Arrays with map
CamperBot
@camperbot
Jun 11 2016 01:38

# Challenge Iterate over Arrays with map

Using map is the best way to iterate through an array or object. Map uses a function to pretty much do whatever you want it to do. It will pass each value to the callback function.

//Use map to add three to each value in the array
var array = [1,2,3,4,5];

array = array.map(function(val){
return val + 3;
});
Fatma Ali
@Fatmali
Jun 11 2016 01:38
Hi guys ..I'm can someone please advice me on how I can build the tic-tac-toe game...thanks
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:40
@Byzgig fahrenheit *= 9/5 + 3?
like that?
David Halls
@DavidHalls
Jun 11 2016 01:40
@ryzhkale fahrenheit = celsius * 9/5 +32;
Alex Ryzhkov
@ryzhkale
Jun 11 2016 01:41
@Byzgig thnx, you're the man
CamperBot
@camperbot
Jun 11 2016 01:41
ryzhkale sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
Zane Page
@Zaceraly
Jun 11 2016 01:43

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

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

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

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

David Halls
@DavidHalls
Jun 11 2016 01:44
@Zaceraly whatcha got going on Zane?
Zane Page
@Zaceraly
Jun 11 2016 01:44
I would really appreciate it if anyone can tell me what I did wrong on this look up table.
sorry accidentally sent it
David Halls
@DavidHalls
Jun 11 2016 01:44
help switch @Zaceraly
CamperBot
@camperbot
Jun 11 2016 01:45
no wiki entry for: switch @zaceraly
David Halls
@DavidHalls
Jun 11 2016 01:45
@Zaceraly read up on switch statements, there is alot missing from this
Zane Page
@Zaceraly
Jun 11 2016 01:46
well the challenge says to not use a switch statement at all. which is partly i am confused
Stephen
@stephepush
Jun 11 2016 01:46
Hi, this is what I have for the mutations algorithm. Am I on the right track?
//mutations attempt
function mutation(arr) {
var splitArr = [];
for (var i = 0; i < arr.length; i++){
splitArr.push(arr[i].toLowerCase().split(""));
}
console.log(splitArr);

var jIter = 0;
//named so because in the next for loop j will be the iterant because i has already been used. j will be iterated and results will go into the variable to be used in a conditional statement
for (var j = 0; j > arr[1].length; j++){
if (splitArr[1].indexOf(splitArr[0]) >= 0){
jIter = jIter + 1;
console.log(jIter);
}

}

if (jIter >= arr) {
return true;
} else {
return false;
}
}

mutation(["Mary", "Army"]);
David Halls
@DavidHalls
Jun 11 2016 01:47
@Zaceraly have you recently used switch statements in previuos lessons
Zane Page
@Zaceraly
Jun 11 2016 01:48
yes sir. I'm on the challenge called "Using objects for Lookups"
David Halls
@DavidHalls
Jun 11 2016 01:50
@Zaceraly ok, so what you have now is never getting into the lookup table, you need to somehow call that table and compare what you send it
@stephepush remind me what this challenge is asking for? what are the results supposed to be
Diego Mayer
@Chrono79
Jun 11 2016 01:54
@stephepush arr is an array, why are you comparing it to an integer?
Zane Page
@Zaceraly
Jun 11 2016 01:54
Ok, Thanks @Byzgig.
CamperBot
@camperbot
Jun 11 2016 01:54
zaceraly sends brownie points to @byzgig :sparkles: :thumbsup: :sparkles:
Stephen
@stephepush
Jun 11 2016 01:55
@Byzgig , you have see if the strings in the two elements match, even if they have different cases or spell different words with the same letters
@Chrono79 , what line are you referring to?
Diego Mayer
@Chrono79
Jun 11 2016 01:55
@stephepush if (jIter >= arr) {
You could use only one loop and indexOf to solve this challenge
Stephen
@stephepush
Jun 11 2016 01:56
@Chrono79 , oh I meant to compare jiter's final tally to the length of the string in...
the arr[1]
Diego Mayer
@Chrono79
Jun 11 2016 01:57
what do you need to check? that all the letters in arr[1] are in arr[0]
Stephen
@stephepush
Jun 11 2016 01:58
umm, let me check the page, its been a few hours since I worked on the challenge
@Chrono79 : yes I have to check if arr[1] 's letters are in arr[0]
Diego Mayer
@Chrono79
Jun 11 2016 02:00
You don't need to convert a string to an array to check that, use strings
Stephen
@stephepush
Jun 11 2016 02:04
the data is in an array by default, do you mean that I don't need to split the string elements within the array?
Diego Mayer
@Chrono79
Jun 11 2016 02:06
yes
David Halls
@DavidHalls
Jun 11 2016 02:08
help smallest common multiple
CamperBot
@camperbot
Jun 11 2016 02:08

# Algorithm Smallest Common Multiple

### Explanation:

The smallest common multiple between two numbers is the smallest number that both numbers can divide into. This concept can be extended to more than two numbers as well.

We can first start with just finding the smallest common multiple between two numbers. Naively, you can start writing out multiple of each number until you write a multiple that exists from both numbers.

An example would be the numbers 3 and 4. The multiples of 3 are 3, 6, 9, 12, 15, 18, ... and the multiples of 4 are 4, 8, 12, 16, 20, .... The first smallest number we run into in both lists is 12 so this is the smallest common multiple between 3 and 4.

This problem can be confusing because most people look for the smallest common multiple of just the two numbers but forget the keyword range. However, this means that if you are given [1,5], then you have to check for the smallest common multiple for all the numbers [1,2,3,4,5] that is evenly divisible by all of them.

DC
@dctor
Jun 11 2016 02:08
hey why i am getting NaN for this simple function?
http://codepen.io/dctor/pen/QEyzjO?editors=0010
Diego Mayer
@Chrono79
Jun 11 2016 02:09
@dctor you can't apply Math.min to an array like that
DC
@dctor
Jun 11 2016 02:16
got it thanks @Chrono79
CamperBot
@camperbot
Jun 11 2016 02:16
dctor sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1109 | @chrono79 |http://www.freecodecamp.com/chrono79
daiwik
@daiwik
Jun 11 2016 02:30

why does

0.1 + 0.2 == 0.30000000000000004

but similar behavior doesn't happen with other numbers. For e.g.

0.2 + 0.3 = 0.5
0.01 + 0.02 = 0.03
anyone?
Diego Mayer
@Chrono79
Jun 11 2016 02:39
daiwik
@daiwik
Jun 11 2016 03:04
thanks @Chrono79
CamperBot
@camperbot
Jun 11 2016 03:04
daiwik sends brownie points to @chrono79 :sparkles: :thumbsup: :sparkles:
:star2: 1110 | @chrono79 |http://www.freecodecamp.com/chrono79
Blake Harris
@bharris62
Jun 11 2016 03:13
any volunteers to help me out with some regex?
Joseph
@revisualize
Jun 11 2016 03:55
@Chrono79 Question: Is "Where Art Thou" a filter?
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:02
Hi guys, i'm doing Check for Palindromes and i dont know how to remove punctuation and symbols out of array by filter. Can anyone help?
Joseph
@revisualize
Jun 11 2016 04:10
@NguyenThuongHuy You don't do an array filter
@NguyenThuongHuy Well, I guess you could. But, damn would that be difficult.
@NguyenThuongHuy What's your current code look like?
Jason
@jasonHzq
Jun 11 2016 04:12
@bharris62 what's ur problem
Joseph
@revisualize
Jun 11 2016 04:13
Did this chat really die for over 40 minutes?
lcassettai
@lcassettai
Jun 11 2016 04:20
it was because Argentina was playing ♥ @revisualize
:P
Joseph
@revisualize
Jun 11 2016 04:20
Soccer?
I don't watch.
lcassettai
@lcassettai
Jun 11 2016 04:28
yep american cup
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:35
@revisualize sorry i did not see your reply, i dont have the code yet, i just want to know how to remove those non-alphanumeric characters.
Ethan
@EthandotNever
Jun 11 2016 04:36
Has anyone completed the "Word Blanks" challenge?
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:37
@EthandotNever yeah
Ethan
@EthandotNever
Jun 11 2016 04:38
I've been stumped on it for awhile now... @NguyenThuongHuy
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:38
@revisualize can you give me a hint?
@EthandotNever can you show me your code
Joseph
@revisualize
Jun 11 2016 04:38
@NguyenThuongHuy String replace?
GGvibes
@GGvibes
Jun 11 2016 04:41
I completed that one too @EthandotNever can you copy your code here or say what the issue with it is?
Ethan
@EthandotNever
Jun 11 2016 04:41
I don't think I understand what I'm supposed to do but here it is....

var result = "";
// Your code below this line
string1 = "The" + myAdjective + myNoun + myVerb + myAdverb + " in the park.";

// Your code above this line

return result;
}

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

Its' horrible, I know...
GGvibes
@GGvibes
Jun 11 2016 04:42
ohh that one. Yeah I remember it,,
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:42
@EthandotNever you missing the space
GGvibes
@GGvibes
Jun 11 2016 04:43
The first "The" needs a space after it inside the quotes
and everything else needs a space like this: " "
rfrancisG
@rfrancisG
Jun 11 2016 04:44
Hi coders I'm a beginner I can't seem to crack the word blanks stage in the chapter of prpblems before algarythims.
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:45
@EthandotNever with your code the result look like Thebigdogranquickly
Ethan
@EthandotNever
Jun 11 2016 04:46
Okay, I'll give it a try
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:46
@EthandotNever try to add some spaces between the the words.
Joseph
@revisualize
Jun 11 2016 04:46
@EthandotNever You need to have spaces between your words.
GGvibes
@GGvibes
Jun 11 2016 04:47
@EthandotNever between each variable it would look like this "The " + mynoun + " " + myadjective + " " etc..
also was the [ string1 = ] a part of your code?
@EthandotNever
Ethan
@EthandotNever
Jun 11 2016 04:50

Like this?

var result = "";
// Your code below this line
String1 = "The " + "" + myAdjective + "" + myNoun + "" + myVerb + "" + myAdverb + "in he park.";

// Your code above this line

return result;
}

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

Taylor
@13xray13
Jun 11 2016 04:50
assignment with a returned value, help anyone?
GGvibes
@GGvibes
Jun 11 2016 04:50
It should start with [ var result = ] Then every quote needs a space in between them
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:51
@EthandotNever close, more like " "
GGvibes
@GGvibes
Jun 11 2016 04:51
except don
Taylor
@13xray13
Jun 11 2016 04:51
var processed = 2;
function processArg(num) {
return (num + 1);
}
My code ^^
GGvibes
@GGvibes
Jun 11 2016 04:51
excpet dont put the brackets like I did
Taylor
@13xray13
Jun 11 2016 04:51
Instructions
Call the processArg function with an argument of 7 and assign its return value to the variable processed.
Ethan
@EthandotNever
Jun 11 2016 04:51
Okay, I'll try that again
GGvibes
@GGvibes
Jun 11 2016 04:52
I'm stuck on "accessing objects properties with variables"
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[16];       // Change this Line
var player = testObj[playerNumber];  // Change this Line
what am I missing here?
William Fish
@williamlfish
Jun 11 2016 04:54
Hey there, looking for some help, first off how may I ask are you guys adding the code images?
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:54
@GGvibes you dont need to define playerNumber = testObj[16]
William Fish
@williamlfish
Jun 11 2016 04:55
@GGvibes you dont need to call the obj twice.
GGvibes
@GGvibes
Jun 11 2016 04:56
i know it's not right I was trying different things I am just not getting how to call 16 it wants that
William Fish
@williamlfish
Jun 11 2016 04:56
just type 16 :-)
Ethan
@EthandotNever
Jun 11 2016 04:56
Omg, it finally worked!!
GGvibes
@GGvibes
Jun 11 2016 04:57
@williamlfish to add code you use three of these :  before and after the code. They're up by the 1 key
Ethan
@EthandotNever
Jun 11 2016 04:57
@GGvibes @NguyenThuongHuy @revisualize
Thx, you guys!!!
CamperBot
@camperbot
Jun 11 2016 04:57
ethandotnever sends brownie points to @ggvibes and @nguyenthuonghuy and @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 1249 | @revisualize |http://www.freecodecamp.com/revisualize
GGvibes
@GGvibes
Jun 11 2016 04:58
@EthandotNever No problem!
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 04:58
@EthandotNever Good work!
GGvibes
@GGvibes
Jun 11 2016 04:59
@williamlfish LOL goddamnit I knew it was something stupid like that....
playerNumber = 16 --
This message was deleted
William Fish
@williamlfish
Jun 11 2016 05:00
Thanks @GGvibes
CamperBot
@camperbot
Jun 11 2016 05:00
williamlfish sends brownie points to @ggvibes :sparkles: :thumbsup: :sparkles:
William Fish
@williamlfish
Jun 11 2016 05:00

// 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 records = collection[id];

if(value !== '' && prop !== "tracks"){
records[prop] = value;
}else if(value !== '' && prop === "tracks"){
records[prop].push(value);
}else if(value === ""){
delete records[prop];
}
console.log(records);

return collection;
}

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

GGvibes
@GGvibes
Jun 11 2016 05:00
thank you @williamlfish !
CamperBot
@camperbot
Jun 11 2016 05:00
ggvibes sends brownie points to @williamlfish :sparkles: :thumbsup: :sparkles:
William Fish
@williamlfish
Jun 11 2016 05:01
so i cannot the the abba to create a "tracks" array in the obj!?!?!
Connor Hastey-Palindat
@cpalindat
Jun 11 2016 05:02
help diff two arrays
CamperBot
@camperbot
Jun 11 2016 05:02

# Algorithm Diff Two Arrays

: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:

Check two arrays and return a new array that contains only the items that are not in either of the original arrays.

Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:05
@williamlfish The push only use for the existing array, and the tracks array you try to create is not exist.
William Fish
@williamlfish
Jun 11 2016 05:06
@NguyenThuongHuy totally, but i cannot figure out how to create existing array?
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:07
@williamlfish how can you create an array inside the object?
William Fish
@williamlfish
Jun 11 2016 05:10
I do not know? haha that is what I am asking. Do you know? I am trying diff things but cannot figure out?
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:12
@williamlfish it's quite simple than you think, i also made the same mistake you did.
tommy
@tommygebru
Jun 11 2016 05:12
soooo... Im doing weather project... does anyone know how to bind the openweather with these icons :heart: :heart: :heart:
https://erikflowers.github.io/weather-icons/api-list.html
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:14
@williamlfish just focus how to make this records[prop] become an array
David Gagne
@david-gagne
Jun 11 2016 05:27
Can anyone help me with the Using Objects for Lookups challenge?
This message was deleted
Here's my code
// Setup
function phoneticLookup(val) {
var result = "";

// Only change code below this line

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

result = lookup.alpha;
result = lookup.bravo;
result = lookup.charlie;
result = lookup.delta;
result = lookup.echo;
result = lookup.foxtrot;
result = lookup[""];

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

// Change this value to test
phoneticLookup("alpha");
The problem I keep running into is the last result is the only value shown when I run the program.
tommy
@tommygebru
Jun 11 2016 05:29
@david-gagne good try :wink2: but all those names can be replaced with one word.....
David Gagne
@david-gagne
Jun 11 2016 05:30
@tommygebru I'm completely lost by your comment.
William Fish
@williamlfish
Jun 11 2016 05:31
@david-gagne use switch()
tommy
@tommygebru
Jun 11 2016 05:31
This message was deleted
David Gagne
@david-gagne
Jun 11 2016 05:32
@williamlfish Using switch isn't allowed on this challenge.
tommy
@tommygebru
Jun 11 2016 05:33
sorry I see what i did there I mixed result with return :smile:
@david-gagne
phoneticLookup("alpha");
David Gagne
@david-gagne
Jun 11 2016 05:33
@tommygebru Happened to me a lot, too.
tommy
@tommygebru
Jun 11 2016 05:33
do you know what this means ^
@david-gagne
phoneticLookup("alpha");
David Gagne
@david-gagne
Jun 11 2016 05:34
@tommygebru That's the function call.
tommy
@tommygebru
Jun 11 2016 05:34
right its the parameter and in the beginning we see that
val
represents the parameter
David Gagne
@david-gagne
Jun 11 2016 05:34
phoneticLookup(val)
tommy
@tommygebru
Jun 11 2016 05:35
with
phoneticLookup(val)
right!
David Gagne
@david-gagne
Jun 11 2016 05:35
Mhmm, I'm listening. lol.
tommy
@tommygebru
Jun 11 2016 05:35
so when we call a function we know that "really" we are always using val for this function at least
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:36
@david-gagne The object properties should be in "" and you only need 1 line of result = lookup in bracket notation
David Gagne
@david-gagne
Jun 11 2016 05:37
@tommygebru I was under the impression that val is attributed to the object's keys...
tommy
@tommygebru
Jun 11 2016 05:38

so now you have to think back to the previous challenge on how we accessed objects

myObj()={
a:1,
b:2,
c:3
}

but using a

William Fish
@williamlfish
Jun 11 2016 05:39
up, @tommygebru is right, sorry I got confused.
tommy
@tommygebru
Jun 11 2016 05:39

@tommygebru I was under the impression that val is attributed to the object's keys...

val is representing a string,
which will represent & access the properties....
so it can give you back the associated string

César
@ICesarI
Jun 11 2016 05:39
@david-gagne, look at this documentation Objects
David Gagne
@david-gagne
Jun 11 2016 05:39
@NguyenThuongHuy When you say the object properties should be in "", do you mean like
var lookup = {
"bravo":"Boston",
"charlie":"Chicago
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:39
@david-gagne yes
David Gagne
@david-gagne
Jun 11 2016 05:41
This message was deleted

@tommygebru So should I structure my object like:

var lookup() = {
...
...
}

?

Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 05:43
@david-gagne try to look back the Accessing Objects Properties with Bracket Notation for your result = lookup
David Gagne
@david-gagne
Jun 11 2016 05:44
Alright let me give these suggestions a shot. JS is a challenge.
César
@ICesarI
Jun 11 2016 05:46
mmm
This message was deleted
lribando
@lribando
Jun 11 2016 05:49
i'm stuck on the switch statement:

function caseInSwitch(val) {
// Only change code below this line
switch(val) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:

// Only change code above this line
}
}

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

nothing is happening when i run
David Gagne
@david-gagne
Jun 11 2016 05:51

@tommygebru @ICesarI I'm still confused on the syntax suggested. In the MDN docs the syntax seems radically different from that suggested in the example on FCC.

Here's the example from FCC:

var alpha = {
1:"Z",
2:"Y",
3:"X",
4:"W",
...
24:"C",
25:"B",
26:"A"
};
alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"

Here's my code again:

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

result = lookup.alpha;
result = lookup.bravo;
result = lookup.charlie;
result = lookup.delta;
result = lookup.echo;
result = lookup.foxtrot;
result = lookup[""];

Here's MDN's code:

var myCar = new Object();
myCar.make = "Ford";
myCar.model = "Mustang";
myCar.year = 1969;
César
@ICesarI
Jun 11 2016 05:52
@david-gagne, on your code you are saving a reference to a string on result.
result = lookup.alpha; saves the reference of "Adams" (The location of "Adams" in the memory). Then, you are saving another reference on result again, and so on. That's why you are get in the last refernce, that is lookup lookup[""];.
So what is that reference? Using the square bracket notation the interpreter looks for an empy string "" on the object lookup, but obviously that property doesn't exist so you get an undefined.
Ritvik Raj
@ritvikraj14
Jun 11 2016 05:53
Tommy Mertell
@sinithwar
Jun 11 2016 05:53
Hello there, I am working on the Diff Two Arrays and my code isn't working the way I want it to, and I looked up the FCC code guide for it and the code is identical only there's works on repl bu mine fails on FCC. Could some please tell me why?
   for(var i = 0; i < arr1.length; i++){
if(arr2.indexOf(arr1[i] === -1)){
newArr.push(arr1[i]);
}
}
for(var h = 0; h < arr2.length; h++){
if(arr1.indexOf(arr2[h] === -1)){
newArr.push(arr2[h]);
}
}
return newArr;
}
David Gagne
@david-gagne
Jun 11 2016 05:53
@ICesarI One of milestones on the challenge is to produce an undefined return. But I'm unsure how to make each result populate without causing the program to exit upon return.
Ritvik Raj
@ritvikraj14
Jun 11 2016 05:53

My code......... function chunkArrayInGroups(arr, size) {
// Break it up.

var l=arr.length;
var k=Math.ceil(l/size);
var arrnew=[k-1][size-1];
for(var i=0;i<k;i++){
for(var j=0;j<size;j++){
arrnew[i][j]=arr[i*2+j];

}    

}

return arrnew;

}

chunkArrayInGroups(["a", "b", "c", "d"], 2);

MIGUEL AMARO
@amaromi
Jun 11 2016 05:53
@lribando check out your case statements, that’s where the magic is happening. you are saying look at “alpha” in the first case you are asking is it 1…. so this is where you’ll put what you want to evaluate to true.
if you know if’s if “alpha” = 1 then answer = “alpha"
Markus Kiili
@Masd925
Jun 11 2016 05:54
@david-gagne You can create objects by object literals {} or object constructor New Object(). Properties you can add inside the literal or later with dot or bracket notation.
Ritvik Raj
@ritvikraj14
Jun 11 2016 05:55
@amaromi @david-gagne Can you help me?
David Gagne
@david-gagne
Jun 11 2016 05:56
@Masd925 So the object constructor is a predefined term in JS, right?
MIGUEL AMARO
@amaromi
Jun 11 2016 05:56
@ritvikraj14 Today’s my first day, let me see if I can.
César
@ICesarI
Jun 11 2016 05:57
@david-gagne, your function recieves one parameter and that parameter should be one property of your intern object. Using square bracket notation you can use that argument in order to look for the property, id est myObject[variable]
Tommy Mertell
@sinithwar
Jun 11 2016 05:57
@ritvikraj14 That actually looks far more complex than it should. I will try to help you while I wait for help.
Markus Kiili
@Masd925
Jun 11 2016 05:58
@david-gagne You can create a plain object with built-in constructor Object or you can use other built-in or user generated constructors to create different kinds of objects. Any function can be used to create objects with new keyword, but functions designed to create objects are written with capital first letter.
David Gagne
@david-gagne
Jun 11 2016 05:59
@Masd925 Got it, thanks!
CamperBot
@camperbot
Jun 11 2016 05:59
david-gagne sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1813 | @masd925 |http://www.freecodecamp.com/masd925
Ritvik Raj
@ritvikraj14
Jun 11 2016 05:59
David Gagne
@david-gagne
Jun 11 2016 05:59
@ritvikraj14 I wish I could help you. I know the pain. lol.
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:00
okay no problem @david-gagne
I am expecting help from @sinithwar .
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:01
I'm doing Check for Palindromes but i dont know how to remove the non-alphanumeric characters, can anyone give me a suggestion?
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:01
yeah i can help in that @NguyenThuongHuy
JavaScriptErika
@JavaScriptErika
Jun 11 2016 06:02

I'm working on Record Collection: https://www.freecodecamp.com/challenges/record-collection

All but one test passes... any pointers in the right direction would be helpful.

function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} else if (value === "") {
delete collection[id][prop];
}
return collection;
}
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:02
@ritvikraj14 what should i use?
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:03
var removeChar=str.replace(/[^A-Z0-9]/gi,"").toLowerCase();
the use this ....var checkP=removeChar.split("").reverse().join("");
@NguyenThuongHuy
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:05
i see im thinking about replace too but i dont understand [^A-Z0-9]
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:05
@shusil123
Jun 11 2016 06:05
@ritvikraj14 , you can use array.slice in your problem. Inside a for loop with i<arr.length and incrementing i += size you can push the values of arr.slice(i, i+size) to a new array and return it..
Tommy Mertell
@sinithwar
Jun 11 2016 06:06
@ritvikraj14 I'
@ritvikraj14 lol I'm getting to it and yes, you made it far more complex than it needed to be
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:06
hey guys how do i format code to display it here?
@shusil123
Jun 11 2016 06:07
help format
CamperBot
@camperbot
Jun 11 2016 06: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 thecode.

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

Tommy Mertell
@sinithwar
Jun 11 2016 06:07
@ritvikraj14 create an empty array, run a while loop that checks the index to the size and slice then push

@ritvikraj14 so, something like this

var temp = [],
i = 0;

while (i < arr.length) {
temp.push(arr.slice(i, i += size));
}
return temp;


Jonathan Mitchell
@Vanhealen
Jun 11 2016 06:08
I have a question about callbacks.
1)does handlePhoto go run off somewhere else
2)and then we grab the result when are are ready. - When do we get the result, after the first parameter has finished running?
downloadPhoto('http://coolcats.com/cat.gif', handlePhoto)

function handlePhoto (error, photo) {
}

console.log('Download started’)
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:08
okay I will now try by my own @sinithwar . thanks
CamperBot
@camperbot
Jun 11 2016 06:08
ritvikraj14 sends brownie points to @sinithwar :sparkles: :thumbsup: :sparkles:
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:09
This message was deleted
Tommy Mertell
@sinithwar
Jun 11 2016 06:09
So lol, anyone want to help me with my issue?
Jonathan Mitchell
@Vanhealen
Jun 11 2016 06:09
low key confused when callbacks actually run and execute
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:10
@NguyenThuongHuy [^A-Z0-9] will replace all other character except A-Z 0-9 with ""
JavaScriptErika
@JavaScriptErika
Jun 11 2016 06:10
@sinithwar I'm stuck on the same challenge... all but one test pasts for me D:
Jun 11 2016 06:10
@sinithwar add code that checks if the prop exist
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:10
For lowercase we include i after /[^A-Z0-9]/ g
Tommy Mertell
@sinithwar
Jun 11 2016 06:11
JavaScriptErika
@JavaScriptErika
Jun 11 2016 06:11
function updateRecords(id, prop, value) {
if (prop !== "tracks" && value !== "") {
collection[id][prop] = value;
} else if (prop == "tracks" && value !== "") {
collection[id].tracks.push(value);
} else if (value === "") {
delete collection[id][prop];
}
return collection;
}
Tommy Mertell
@sinithwar
Jun 11 2016 06:11
@Shraddha99 This is the code I have
var newArr = [];
// Same, same; but different.
for(var i = 0; i < arr1.length; i++){
if(arr2.indexOf(arr1[i] === -1)){
newArr.push(arr1[i]);
}
}
for(var h = 0; h < arr2.length; h++){
if(arr1.indexOf(arr2[h] === -1)){
newArr.push(arr2[h]);
}
}
return newArr;
MIGUEL AMARO
@amaromi
Jun 11 2016 06:11
@ritvikraj14 I can’t help :(
Tommy Mertell
@sinithwar
Jun 11 2016 06:11
It is identical to the one on the CodeCamp solutions page
Jun 11 2016 06:11

@sinithwar function updateRecords(id, prop, value)
{
if( value !== "")
{
if(prop!=="tracks")
{
collection[id][prop]=value;
}
else if( prop ==="tracks")
{
if(collection[id].hasOwnProperty(prop))
{
collection[id][prop].push(value);
}
else
{
collection[id].tracks = [];
collection[id][prop].push(value);
}
}
}
else
delete collection[id][prop];

return collection;
}

this will work
n u will understand too
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:12
@amaromi Actually my doubt is clear.
Tommy Mertell
@sinithwar
Jun 11 2016 06:12
I don't understand I like of that, I'm on the Diff Two Arrays
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:13
@ritvikraj14 Thanks
CamperBot
@camperbot
Jun 11 2016 06:13
nguyenthuonghuy sends brownie points to @ritvikraj14 :sparkles: :thumbsup: :sparkles:
Tommy Mertell
@sinithwar
Jun 11 2016 06:13
Oi that's the one dealing with api's, I done that
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:14


// 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 (value !== "" && prop !== "tracks"){
collection[id][prop] = value;
}else if (prop == "tracks" && value !== ""){
collection[id][prop].push(value);
}
else if(value === ""){
delete collection[id][prop];
}

return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
hey guys, where could i be going wrong?
Jun 11 2016 06:15
@sinithwar oops sry
Tommy Mertell
@sinithwar
Jun 11 2016 06:15
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:15
challenge "record collection"
Jun 11 2016 06:16
@cacious7 U haven't made the chk if the prop exist see the code I posted just a little ago
Ritvik Raj
@ritvikraj14
Jun 11 2016 06:16
@cacious7

// 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" && value!=="" ){
collection[id][prop]=value;
}
else if(prop=="tracks" && value!==""){
if(!collection[id].hasOwnProperty("tracks"))
collection[id].tracks=[];
collection[id].tracks.push(value);
}
else if(value===""){
delete collection[id][prop];
}
return collection;
}

@cacious7 Check your code wherever it is wrong.
Tommy Mertell
@sinithwar
Jun 11 2016 06:18
(0.0)/
No one then eh?
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:19
@ @ritvikraj14 thanks an
CamperBot
@camperbot
Jun 11 2016 06:19
cacious7 sends brownie points to @ritvikraj14 :sparkles: :thumbsup: :sparkles:
Tommy Mertell
@sinithwar
Jun 11 2016 06:24

Can someone tell me the difference between these two solutions? It's driving me mental this is.
My solution

function diffArray(arr1, arr2) {
var newArr = [];
// Same, same; but different.
for(var i = 0; i < arr1.length; i++){
if(arr2.indexOf(arr1[i] === -1)){
newArr.push(arr1[i]);
}
}
for(var h = 0; h < arr2.length; h++){
if(arr1.indexOf(arr2[h] === -1)){
newArr.push(arr2[h]);
}
}
return newArr;
}

CodeCamp's Official Solution

  var newArr = [];
// Looping through arr1 to find elements that do not exist in arr2
for (var i = 0; i < arr1.length; i++) {
if (arr2.indexOf(arr1[i]) === -1){
// Pushing the unique to arr1 elements to the newArr
newArr.push(arr1[i]);
}
}
// Looping through arr2 to find elements that do not exist in arr1
for (var j = 0; j < arr2.length; j++) {
if (arr1.indexOf(arr2[j]) === -1){
// Pushing the unique to arr2 elements to the newArr
newArr.push(arr2[j]);
}
}

return newArr;
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:26
@ritvikraj14 So reverse() can work with string beside array?
Tommy Mertell
@sinithwar
Jun 11 2016 06:27
@NguyenThuongHuy a string is just an array of ASCII characters
Markus Kiili
@Masd925
Jun 11 2016 06:28
@NguyenThuongHuy .reverse() is an array method.
Cacious Siamunyanga
@cacious7
Jun 11 2016 06:28
@ritvikraj14 thatnks an, really cleared it up
Tommy Mertell
@sinithwar
Jun 11 2016 06:28

You can do

var str = "Hi";
console.log(str[0]);

and you would get H

Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:29
@Masd925 yeah but i just found it work with string too
function palindrome(str) {

var reduceStr = str.replace(/[^A-Z0-9]/gi,"").toLowerCase();
var reverse = reduceStr.split("").reverse().join("");
if (reduceStr === reverse){
return true;
}
else {return false;}

}

palindrome("eye");
Markus Kiili
@Masd925
Jun 11 2016 06:30
@NguyenThuongHuy No, but you can make an array from string content. reduceStr.split("") is an array.
Tommy Mertell
@sinithwar
Jun 11 2016 06:30
@NguyenThuongHuy when you split, it turns it into an array
Hello
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:34
@Masd925 @sinithwar Thanks i just ckeck back the Split Strings with split and in the example they define var array =[]; so i thought it's not an array
CamperBot
@camperbot
Jun 11 2016 06:34
nguyenthuonghuy sends brownie points to @masd925 and @sinithwar :sparkles: :thumbsup: :sparkles:
:star2: 1814 | @masd925 |http://www.freecodecamp.com/masd925
Huy Nguyen Thuong
@NguyenThuongHuy
Jun 11 2016 06:35
var string = "Split me into an array";
var array = []; <------- this one

// Only change code below this line.

array = string.split(" ");
Markus Kiili
@Masd925
Jun 11 2016 06:36
@NguyenThuongHuy The last line assigns a new value to array variable. The original value assigned here var array = []; is overwritten.
Jason Carpenter
@Jason9199
Jun 11 2016 06:38
Would it be possible for someone to take a look at my "Where do I belong" code and help me understand why most of my tests are passing but some are failing?
Markus Kiili
@Masd925
Jun 11 2016 06:39
@Jason9199 Sure.
Jason Carpenter
@Jason9199
Jun 11 2016 06:39
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var index;
function compareNumbers(a, b) {
return a - b;
}
var sorted = arr.sort(compareNumbers);
for (i=0; i<sorted.length; i++) {
if (sorted[i]==num) {
index = (i-1);
return index;
} else if (sorted[i]>num) {
index = i;
return index;
} else {
index = (i+1);
}
}
return index;
}
oops, not formatted well
Markus Kiili
@Masd925
Jun 11 2016 06:40
@Jason9199 The solution is easier if you first push num into arr. After sorting, the result is the first index of num.
Jason Carpenter
@Jason9199
Jun 11 2016 06:41
@Masd925 I hadn't considered trying that. Hmm...
Markus Kiili
@Masd925
Jun 11 2016 06:41
@Jason9199 It is also possible to solve it without sorting at all.
Tommy Mertell
@sinithwar
Jun 11 2016 06:43
O...omg, the difference is so minute and small no wonder I missed it
Jason Carpenter
@Jason9199
Jun 11 2016 06:44
@Masd925 Anything stand out as to why this might work for some and fail for others? I put a bunch of console.logging into it and it was finding the right answer according to the console.logs for all problem sets. I don't know why it wouldn't pass all the tests.
Even if there is a better way to do it.
Tommy Mertell
@sinithwar
Jun 11 2016 06:44
if(arr1.indexOf(arr2[j] === -1))
// and not
if(arr1.indexOf(arr2[j]) === -1)
so my culprit was => )
Markus Kiili
@Masd925
Jun 11 2016 06:46
@sinithwar Don't assume that "FCC official solutions" are necessarily good. Mostly they are.
Tommy Mertell
@sinithwar
Jun 11 2016 06:47
@Masd925 No, I had come up with a solution that made sense and when I went looking for a solution that would work, I check mine against there's and it looked identical except they use an j where I used a h
their's
theirs god it's 3AM
Markus Kiili
@Masd925
Jun 11 2016 06:48
@sinithwar Yes, that solution is decent. Same code repeating twice, and much simpler code could be made. For example:
function diff(arr1, arr2) {
return arr1.concat(arr2).filter(function(val, index, array){
return array.indexOf(val)===array.lastIndexOf(val);
});
}
Tommy Mertell
@sinithwar
Jun 11 2016 06:49
Yes, they have a similar solution underneath the solution I used
Markus Kiili
@Masd925
Jun 11 2016 06:50
@sinithwar ok
Tommy Mertell
@sinithwar
Jun 11 2016 06:50
I can think like that in Ruby, I can't do it in Js just yet
Thanks CamperBot
Jason Carpenter
@Jason9199
Jun 11 2016 06:52
Actually @Masd925 for my problem the number being pushed into the array won't always be the first index after the array is sorted.
Markus Kiili
@Masd925
Jun 11 2016 06:53
@Jason9199 After you push num and sort arr, the result is the first index of num, always.
Jason Carpenter
@Jason9199
Jun 11 2016 06:54
@Masd925 I guess I don't understand what you're saying. This is what it's saying to return. "Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted."
Markus Kiili
@Masd925
Jun 11 2016 06:55
@Jason9199 What I said gives the same result as the task description.
@Jason9199 Even easier way to get the same result is to avoid sorting altogether and just count arr elements <num.
@Jason9199 All these ways use some logic or math to get to the same result.
Jason Carpenter
@Jason9199
Jun 11 2016 06:57
@Masd925 Well as I said, I don't understand what you're saying. The first index of num? num is a single number being pushed into the array...
Markus Kiili
@Masd925
Jun 11 2016 06:57
@Jason9199 After pushing (and sorting) there can be several values equal to num. I am talking about first occurence of num.
Jason Carpenter
@Jason9199
Jun 11 2016 07:02
@Masd925 If you're trying to say that there may be more than one entry in the array with the same value as num, then yes that's right. For example one of the tests is "getIndexToIns([10, 20, 30, 40, 50], 30) should return 2."
@Masd925 That much I know, but obviously I'm having issue getting the code to pass all the tests. The code I posted earlier passes more than half the tests, including the ones with num matching more than one index in the array. I just don't know why it won't pass all of them. And again, when I console.log from within the code it finds the right answers for all the tests, just some of them say they fail. Obviously they don't say why...
Markus Kiili
@Masd925
Jun 11 2016 07:06
@Jason9199 The first index returned should be i, not i-1. Then it works. Change index = (i-1);
Jason Carpenter
@Jason9199
Jun 11 2016 07:09
@Masd925 I changed the order and the same tests still fail.
Markus Kiili
@Masd925
Jun 11 2016 07:09
@Jason9199 Just remove the -1 there
Jason Carpenter
@Jason9199
Jun 11 2016 07:09
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var index;
function compareNumbers(a, b) {
return a - b;
}
var sorted = arr.sort(compareNumbers);
for (i=0; i<sorted.length; i++) {
if (sorted[i]>num) {
index = i;
return index;
} else if (sorted[i]==num) {
index = (i-1);
return index;
} else {
index = (i+1);
}
}
return index;
}
Markus Kiili
@Masd925
Jun 11 2016 07:10
@Jason9199 You changed something else too. The old code works if you just remove the -1.
Arjun
@arjunsingh81989
Jun 11 2016 07:10
Is HTTP only used to communicate between applications over the internet? or Can HTTP be used as a protocol for communication between two applications installed on ones computer?
NixonRichard
@NixonRichard
Jun 11 2016 07:10
hi
finally i got the full stack certification
Jason Carpenter
@Jason9199
Jun 11 2016 07:11
@Masd925 Alright I got it to work, your hint helped me.
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
var index;
function compareNumbers(a, b) {
return a - b;
}
var sorted = arr.sort(compareNumbers);
for (i=0; i<sorted.length; i++) {
if (sorted[i]>=num) {
index = i;
return index;
} else {
index = (i+1);
}
}
return index;
}
Thanks @Masd925
CamperBot
@camperbot
Jun 11 2016 07:12
:star2: 1815 | @masd925 |http://www.freecodecamp.com/masd925
jason9199 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jun 11 2016 07:14
@Jason9199 The other ways I was talking about are:
function getIndexToIns(arr, num) {
arr.push(num);
arr.sort(function (a, b) {return a - b;});
return arr.indexOf(num);
}

function getIndexToIns(arr, num) {
return arr.reduce(function(prev, curr){
return curr<num ? prev+1 : prev;
},0);
}
Jason Carpenter
@Jason9199
Jun 11 2016 07:15
@Masd925 Ok thanks for explaining those. The first one I had no clue what you were talking about, but I wasn't thinking about using .indexOf().
CamperBot
@camperbot
Jun 11 2016 07:15
jason9199 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: jason9199 already gave masd925 points
Markus Kiili
@Masd925
Jun 11 2016 07:17
@Jason9199 The last one means that you can figure out your spot in a (by length) queue by counting the kids shorter than you. Quite logical.
Vivienne Sales
@Natto278
Jun 11 2016 07:21

I am not getting this Nesting for Loops challenge. I understand how to do the calculations, but when I write my code, it keeps returning 1. What doing wrong? Here's my code: function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (var i = 0; i > arr.length; i++) {
for (var j = 0; j > arr[j].length; j++) {
console.log(arr[i][j]);
}
}

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

// Modify values below to test your code
multiplyAll([[1],[2],[3]]);

Markus Kiili
@Masd925
Jun 11 2016 07:21
@Natto278 Multiply product by the element. Don't log it.
Vivienne Sales
@Natto278
Jun 11 2016 07:22
@Masd925 so I need to get rid of the console.log line?
Markus Kiili
@Masd925
Jun 11 2016 07:24
@Natto278 Yes, logging doesn't change product. Multiply instead product by the element.
Vivienne Sales
@Natto278
Jun 11 2016 07:25
@Masd925 And the element is the variable?
Markus Kiili
@Masd925
Jun 11 2016 07:29
@Natto278 arr[i][j] is one element being looped.
NixonRichard
@NixonRichard
Jun 11 2016 07:29
im too awesome
Cacious Siamunyanga
@cacious7
Jun 11 2016 07:30

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i = 0; i < arr.length; i++){
for(var j = 0; i < arr[i].length; i++){
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
where a i going wrong?
Markus Kiili
@Masd925
Jun 11 2016 07:31
@NixonRichard Boolean("@NixonRichard is too awesome"); // true
Arpan
@sahooarpan
Jun 11 2016 07:31

function titleCase(str) {
var arrayOfstrings=str.split(" ");
for(i=0;i<arrayOfstrings.length;i++)
{
var placeholder=arrayOfstrings[i];
var Uppcase=placeholder.charAt(0).toUpperCase();
placeholder=placeholder.slice(1,placeholder.length).toLowerCase();
arrayOfstrings[i]=Uppcase.concat.(placeholder);
}
str=arrayOfstrings.join(' ');
return str;
}

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

where z error
NixonRichard
@NixonRichard
Jun 11 2016 07:32
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function randomWholeNum() {

// Only change code below this line.
var random09 = Math.floor(Math.random()*9);

return Math.random();

}
Cacious Siamunyanga
@cacious7
Jun 11 2016 07:32
getting "TypeError Cannot read property 'length' of undefined
NixonRichard
@NixonRichard
Jun 11 2016 07:32
hi
what s wrong with my code ?
Markus Kiili
@Masd925
Jun 11 2016 07:32
@cacious7 here for(var j = 0; i < arr[i].length; i++){
Arpan
@sahooarpan
Jun 11 2016 07:33
wch challenge @NixonRichard
??
Vivienne Sales
@Natto278
Jun 11 2016 07:33
@Masd925 Okay.
NixonRichard
@NixonRichard
Jun 11 2016 07:34
this one
Arpan
@sahooarpan
Jun 11 2016 07:35

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

function randomWholeNum() {

// Only change code below this line.

return Math.floor(Math.random()*10);
}

this is code @NixonRichard
Cacious Siamunyanga
@cacious7
Jun 11 2016 07:35
@Masd925 whats the error, and what do u suggest i do?
Chestnut-Rice
@Chestnut-Rice
Jun 11 2016 07:36

Hi, I've got a question for the record collection challenge

function updateRecords(id, prop, value) {
if (value !== "" && prop !== "tracks") {
collection[id][prop] = value;
}
else if (prop === "tracks" && value !== ""){
collection[id][prop].push(value);
}
else if (value === "") {
delete collection[id][prop];
}

return collection;
}

Why does collection[id][prop].push(value); not work with the second objective? I understand it's probably due to there not being a "tracks" property, but how to fix it?

Arpan
@sahooarpan
Jun 11 2016 07:38

@sahooarpan
function titleCase(str) {
var arrayOfstrings=str.split(" ");
for(i=0;i<arrayOfstrings.length;i++)
{
var placeholder=arrayOfstrings[i];
var Uppcase=placeholder.charAt(0).toUpperCase();
placeholder=placeholder.slice(1,placeholder.length).toLowerCase();
arrayOfstrings[i]=Uppcase.concat.(placeholder);
}
str=arrayOfstrings.join(' ');
return str;
}

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

Cacious Siamunyanga
@cacious7
Jun 11 2016 07:39
@Chestnut-Rice on the second if - you first have make sure the "tracks" is a property (by using .hasOwnPropeerty), if not create that property as an array. then push the value into tracks
Chestnut-Rice
@Chestnut-Rice
Jun 11 2016 07:39
thanks @cacious7 !
CamperBot
@camperbot
Jun 11 2016 07:39
chestnut-rice sends brownie points to @cacious7 :sparkles: :thumbsup: :sparkles:
Cacious Siamunyanga
@cacious7
Jun 11 2016 07:41
@Chestnut-Rice you welcome
Chestnut-Rice
@Chestnut-Rice
Jun 11 2016 07:41
I did it :D
Arpan
@sahooarpan
Jun 11 2016 07:42
@Chestnut-Rice can u send me record collection challenge code??
Cacious Siamunyanga
@cacious7
Jun 11 2016 07:43
Hey guys, where am i going wrong. am getting TypeError Cannot read property 'length' of undefined

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for(var i = 0; i < arr.length; i++){
for(var j = 0; i < arr[i].length; i++){
product *= arr[i][j];
}
}
// Only change code above this line
return product;
}

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
@shusil123
Jun 11 2016 07:45
@cacious7 , it's j<arr[i].length; in your second for loop, and j++
Kuldeep
@kuldeep-izap
Jun 11 2016 07:48
hi can anyone please tell me solution of Escaping Literal Quotes in Strings
@shusil123
Jun 11 2016 07:48
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
product *= arr[i][j];
}
}
@cacious7
@kuldeep-izap , post what do you have, here .....
Norvin Burrus
@ndburrus
Jun 11 2016 07:49
@kuldeep-izap can you post your code?
Kuldeep
@kuldeep-izap
Jun 11 2016 07:50
oks

var myStr = "I am a \"double quoted\" string inside \"double quotes\"";

// Change this line

Anthony
@eyarie
Jun 11 2016 07:51
hi all
can anyone help me wiith the solution for word blanks
Norvin Burrus
@ndburrus
Jun 11 2016 07:53
@kuldeep-izap ...carefully check the punctuation... :)
@eyarie can you post your code?
Anthony
@eyarie
Jun 11 2016 07:56

var result = "This " + myAdjective +"is"+ myNoun + "has " + myVerb + "are" + myAdverb;
// Your code below this line

// Your code above this line
return result;
}

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

NixonRichard
@NixonRichard
Jun 11 2016 07:56
Math.floor(Math.random() * (max - min + 1)) + min
hi
Kuldeep
@kuldeep-izap
Jun 11 2016 07:56
@ndburrus Thanks
CamperBot
@camperbot
Jun 11 2016 07:56
kuldeep-izap sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
NixonRichard
@NixonRichard
Jun 11 2016 07:56
what this code s doing ?
Norvin Burrus
@ndburrus
Jun 11 2016 07:57
@eyarie ok, create your sentence (madlib), then we can start building the string...
@kuldeep-izap great work! :sparkles:
NixonRichard
@NixonRichard
Jun 11 2016 07:59
what this code s doing ?
Math.floor(Math.random() * (max - min + 1)) + min
Anthony
@eyarie
Jun 11 2016 08:00
thanks
just did @ndburrus
NixonRichard
@NixonRichard
Jun 11 2016 08:01
what s it doing ?
Norvin Burrus
@ndburrus
Jun 11 2016 08:01
@NixonRichard the code generates random whole numbers... within a range
@eyarie can you post your sentence?
NixonRichard
@NixonRichard
Jun 11 2016 08:02
@ndburrus do u watch onepieace ?
Norvin Burrus
@ndburrus
Jun 11 2016 08:02
@NixonRichard no, i don't know what that is..
NixonRichard
@NixonRichard
Jun 11 2016 08:03
u just wasted ur life ...
that s an aniiiimmmeee !!! u can take ur life back by starting watching it though
Anthony
@eyarie
Jun 11 2016 08:08

var result ="";
// Your code below this line
result += "my "+ myAdjective +" "+ myNoun +" "+ myVerb +" very" + myAdverb + ".";

// Your code above this line
return result;
}

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

still did work
Rabin Shrestha
@jyapujuju
Jun 11 2016 08:10

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

//Try it out here
var myCar = new Car(3, 1, 2);
var hCar = new Car(4, 4, 2);
var mCar = new Car(4, 4, 2);
what should i do?
Anthony
@eyarie
Jun 11 2016 08:14
thanks @ndburrus i have figured it out
CamperBot
@camperbot
Jun 11 2016 08:14
eyarie sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Anthony
@eyarie
Jun 11 2016 08:14
i forgot to space out the characters
bakermrr
@bakermrr
Jun 11 2016 08:15
@jyapujuju you should create a this.x = num list
Andrew Forbes
@aforbe2
Jun 11 2016 08:26
Is anyone up? I could use some help with one of the challanges
Norberto
@nortocode
Jun 11 2016 08:28
@jyapujuju define some parameters for the function and assign them
Norvin Burrus
@ndburrus
Jun 11 2016 08:28
@eyarie nice job!! :+1:
@aforbe2 what (challenge name) are you working on?
@jyapujuju which challenge is this?
@jyapujuju ...review/check these items: var Car = function() { & //Change this constructor :) the instructions offer that we can make variable constructors by add[ing] parameters to our constructor.
Norvin Burrus
@ndburrus
Jun 11 2016 08:36
are there any other questions (challenge name, please...) i might be able to assist with? ok, happy coding... :)
TechAgent
@cyberwizkid
Jun 11 2016 08:50
@ndburrus hello
Harshit Anand
@nerocool996
Jun 11 2016 08:50
str.replace(/[A-Z]/g,"$1".toLowerCase()); Why isn't this working? The '$1' should be replace with the result shouldn't it?
TechAgent
@cyberwizkid
Jun 11 2016 08:50
@ndburrus were can i go to get help with php?
Norvin Burrus
@ndburrus
Jun 11 2016 08:51
@cyberwizkid hi... i'm not sure - i would think perhaps in the backend chat room... " :+1:
Cacious Siamunyanga
@cacious7
Jun 11 2016 08:52
guys, this challenge is irritating me, plizz help

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i = 0; i < 5; i++){
if (firstName !== contacts[i]["firstName"]){
console.log( "No such contact");
}
for (var c = 0; c < contacts.length; c++){
for (var j = 0; j < contacts[c].length; j++){
if(prop !== contacts[c][j]);
console.log("No such property");
}
}

}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
plizz help
Norvin Burrus
@ndburrus
Jun 11 2016 08:54
@cacious7 why is 5 being used as opposed to the string length, just curious... or (var i = 0; i < 5; i++){ next, if (firstName !== contacts[i]["firstName"]){ updat: firstName is an actual property name, so dot notation can be used. the string notation, however, is not needed.
Cacious Siamunyanga
@cacious7
Jun 11 2016 08:56
@ndburrus its actually supposed to be var i = 1 . because there are only four firstNames
Norvin Burrus
@ndburrus
Jun 11 2016 08:58
@cacious7 maybe i'm not understanding... i was referring to i < 5; in the double for loop, the code is looking for a non-match for prop. remember, that the prop check should already have the firstName check satisfied.
Cacious Siamunyanga
@cacious7
Jun 11 2016 09:00
there are only 4 contacts, so there are only four firstNames. so i should only loop through four contacts contacts[i]
@ndburrus with firstaName being contacts[i]["firstName"]
Norvin Burrus
@ndburrus
Jun 11 2016 09:02
@cacious7 that is true, but how does that relate to i = 1?
Jun 11 2016 09:03
function palindrome(str) {
// Good luck!
var newStr;
newStr=str.toLowerCase();
str=newStr.replace(/' '/gi,'');
newStr=str.replace(/','/gi,'');
str=newStr(/'.'/gi,'');
if(str===str.reverse())
{
return true;
}
return false;
}
palindrome("eye");
it just cannot be passed
@shusil123
Jun 11 2016 09:04
@cacious7 , you're making it complex . Just use if (contacts[i].firstName!=="") and nested if (contacts[i].firstName === firstName) return contacts[i][prop]. Outside the nested if return "No such property". Outside total ifs return "No such contact"...
JavaScriptErika
@JavaScriptErika
Jun 11 2016 09:08
Can someone help me out with my code? It's with the Record Collection challenge
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Jun 11 2016 09:10
@7humbs Sure
Norvin Burrus
@ndburrus
Jun 11 2016 09:11
@cacious7 let's ensure we understand the firstName iteration/loop. i think there is confusion on this point. to check if the input firstName is within one of the four records, we need to iterate through them. there should be 4 iterations becuase there are four records. now, we use the variable given (firstName) and compare it to each of the firstName property names (which point to values) for each record. ok, to code that, we identify the contacts record contacts{i], and add .firstName (we use dot notation because firstName is an actual property name). make sense? :sparkles:
nameToReachPeople
@nameToReachPeople
Jun 11 2016 09:11
Hi, i want here to set greyscale with jquery, to elements after particular timeout, with setTimeout but it doesn't works. Can u take look at code, it is short? How to set greyscale to element in jquery?
http://codepen.io/ustvarno/pen/dXGawe
JavaScriptErika
@JavaScriptErika
Jun 11 2016 09:12
I appreciate it @thomlom
https://www.freecodecamp.com/challenges/record-collection
Only one test won't pass, here's my code:

// 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" && value !== "") {
collection[id][prop] = value;
} else if (prop == "tracks" && value !== "") {
collection[id][prop].push(value);
} else if (value === "") {
delete collection[id][prop];
}
return collection;
}

// Alter values below to test your code
updateRecords(5439, "artist", "ABBA");
nameToReachPeople
@nameToReachPeople
Jun 11 2016 09:12
i found.... :)
lily wang
@XiaoYingWang
Jun 11 2016 09:16
How to do this?
Norvin Burrus
@ndburrus
Jun 11 2016 09:17
@LilyCathy basically, the items in the output (right) column need to be translated into the code (left column)... :+1:
@shusil123
Jun 11 2016 09:17
@LeonardoPlaska , you can wrap up the regular expression in one line ,
var newStr = "";
newStr = str.toLowerCase();
newStr = newStr.replace(/[\W+_]/g, "");
if(newStr===newStr.split('').reverse().join(''))
{
return true;
}

return false;
}
Jun 11 2016 09:18
but what does "/[\W+_]/" means?
Nick Ang
@nickangtc
Jun 11 2016 09:18
I need help figuring out why my jQuery "GET" isn't working when I try to get data through OpenWeather API...
  //|--- Get weather data and display on page
$.get("api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&APPID=95eaa17a6d237ecea9f9956ac1b77766", function(data) { tempC = data.weather.main.temp / 10; // OpenWeather API returns Celsius * 10 rain = data.rain["3h"]; clouds = data.clouds.all; console.log(tempC); console.log(rain); console.log(clouds); }); // end of "get" weather --| Shusil Banjade @shusil123 Jun 11 2016 09:19 Like I did, non-alphanumeric characters with underscore. Relace them with ""... @LeonardoPlaska Leonardo Plaska @LeonardoPlaska Jun 11 2016 09:19 @shusil123 but what does "/[\W+_]/" means? Yildirim @yildirimmurat Jun 11 2016 09:19 @7humbs you should consider the case where the property doesnt exist Nick Ang @nickangtc Jun 11 2016 09:19 When I enter the full URL of the API + my API key, I can view the data object Shusil Banjade @shusil123 Jun 11 2016 09:20 That means non-alphanumeric characters . @LeonardoPlaska Leonardo Plaska @LeonardoPlaska Jun 11 2016 09:20 oh thanks @shusil123 CamperBot @camperbot Jun 11 2016 09:20 leonardoplaska sends brownie points to @shusil123 :sparkles: :thumbsup: :sparkles: :cookie: 391 | @shusil123 |http://www.freecodecamp.com/shusil123 Leonardo Plaska @LeonardoPlaska Jun 11 2016 09:20 got it Shusil Banjade @shusil123 Jun 11 2016 09:20 @LeonardoPlaska Anytime JavaScriptErika @JavaScriptErika Jun 11 2016 09:21 @yildirimmurat going to give that a try - thank you CamperBot @camperbot Jun 11 2016 09:21 7humbs sends brownie points to @yildirimmurat :sparkles: :thumbsup: :sparkles: :cookie: 241 | @yildirimmurat |http://www.freecodecamp.com/yildirimmurat Shusil Banjade @shusil123 Jun 11 2016 09:22 Capital W means non-words characters (not a-z) plus underscore since underscore is not included in \W. @LeonardoPlaska Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:23 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" && value !== "") { collection[id][prop] = value; } else if (prop == "tracks" && value !== "") { if (!collection[id].tracks){ collection[id].tracks = []; } collection[id][prop].push(value); } else if (value === "") { delete collection[id][prop]; } return collection; } // Alter values below to test your code updateRecords(5439, "tracks", "Take a Chance on Me"); @7humbs NixonRichard @NixonRichard Jun 11 2016 09:23 hi Nick Ang @nickangtc Jun 11 2016 09:23 Anyone tried looking at the code I pasted? I've been stumped by this for 2 days... tried all sorts of things like getJSON vs get, using all the parameters of get... still can't get it to work (ie. console log not showing ANY of the data) NixonRichard @NixonRichard Jun 11 2016 09:23 can u send me a cookie plz Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:23 It's because the array tracks doesn't exist for 5439, you need to check first if it's already here or not NixonRichard @NixonRichard Jun 11 2016 09:23 i want to test my new acc brownie points Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:25 @nickangtc What's your problem exactly? Nick Ang @nickangtc Jun 11 2016 09:27 @thomlom it's not being able to store certain data from OpenWeather (like temperature, clouds, etc) into variables I declared Andrew Forbes @aforbe2 Jun 11 2016 09:27 @ndburrus it's Accessing Nested Objects in JSON Norvin Burrus @ndburrus Jun 11 2016 09:28 @aforbe2 can you post what you've got so far? Andrew Forbes @aforbe2 Jun 11 2016 09:28 @ndburrus Here is the solution I came up with, I don't understand why it isn't correct Nick Ang @nickangtc Jun 11 2016 09:28 Actually, I'm not even sure that the code I wrote did retrieve the data object from OpenWeather at all Andrew Forbes @aforbe2 Jun 11 2016 09:28 // Setup var myStorage = { "car": { "inside": { "glove box": "maps", "passenger seat": "crumbs" }, "outside": { "trunk": "jack" } } }; // Only change code below this line myStorage.car.inside["glove box"]; var gloveBoxContents = "myStorage"; // Change this line Norvin Burrus @ndburrus Jun 11 2016 09:30 @aforbe2 ok, let's start here: var gloveBoxContents =only one (1) line of code is needed... review the last couple of example code lines. essentially, we can reference (or point to) the desired value, using dot notation until we need to reach inside a property and get a value (this is where we'll use bracket notation).... Andrew Forbes @aforbe2 Jun 11 2016 09:30 On line 16 where I use the dot notation and bracket notation I get a red X that says "Expected an assignment or function call and instead saw an expression Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:30 Can you give the full code of your project ? Or your codepen's link if you use it ? Nick Ang @nickangtc Jun 11 2016 09:31 Yes! One moment @thomlom the buttons are redundant, left over from previously when I was trying to figure some things out Henrique Salguero @kikosalguero Jun 11 2016 09:33 Hello guys, how can i filter and array to put null elements off? Andrew Forbes @aforbe2 Jun 11 2016 09:33 @ndburrus Oh I got it! I store the call in the gloveBoxContents variable instead of putting them on two separate lines! Thank you so much! CamperBot @camperbot Jun 11 2016 09:33 aforbe2 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles: :cookie: 494 | @ndburrus |http://www.freecodecamp.com/ndburrus Norvin Burrus @ndburrus Jun 11 2016 09:34 @aforbe2 excellent work!!! :sparkles: you found it before i could finish typing.... :) very well done... :sparkles: Andrew Forbes @aforbe2 Jun 11 2016 09:35 @ndburrus Yeah, your hint about only needing one line of code is what I needed. Thank you again! CamperBot @camperbot Jun 11 2016 09:35 aforbe2 sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles: Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:35 @nickangtc I'm checking your code :) CamperBot @camperbot Jun 11 2016 09:35 :warning: aforbe2 already gave ndburrus points Nick Ang @nickangtc Jun 11 2016 09:35 Hahah that's great.. thanks a lot @thomlom CamperBot @camperbot Jun 11 2016 09:35 :cookie: 375 | @thomlom |http://www.freecodecamp.com/thomlom nickangtc sends brownie points to @thomlom :sparkles: :thumbsup: :sparkles: Norvin Burrus @ndburrus Jun 11 2016 09:35 @aforbe2 ..anytime... :+1: Henrique Salguero @kikosalguero Jun 11 2016 09:35 Im in the Falsy Bouncer challenge, that is my code:  Im in the Falsy Bouncer challenge, that is my code: function bouncer(arr) { function filterFalse(el) { return el != false; } function filterFalse2(el2) { return el2 !== null; } arr = arr.filter(filterFalse); return arr; } bouncer([1, null, NaN, 2, undefined]); JavaScriptErika @JavaScriptErika Jun 11 2016 09:36 Thank you @thomlom CamperBot @camperbot Jun 11 2016 09:36 7humbs sends brownie points to @thomlom :sparkles: :thumbsup: :sparkles: :cookie: 376 | @thomlom |http://www.freecodecamp.com/thomlom Shraddha Parab @Shraddha99 Jun 11 2016 09:36 can anyone help me out with this code CamperBot @camperbot Jun 11 2016 09:36 no wiki entry for: me out with this code Shraddha Parab @Shraddha99 Jun 11 2016 09:37 function lookUpProfile(firstName, prop){ for(i=0; i<= contacts[i].length; i++) { if(contacts[i].firstName == firstName) { if(contacts.firstName[i].prop == prop) { return contacts[i].prop; } } else if (contacts[i].firstName !== firstName) { return "No such contact"; } else if(contacts[i].prop != prop) { return "No such Property"; } } } Henrique Salguero @kikosalguero Jun 11 2016 09:38 Im in the Falsy Bouncer challenge, that is my code: function bouncer(arr) { function filterFalse(el) { return el != false; } function filterFalse2(el2) { return el2 !== null; } arr = arr.filter(filterFalse); arr = arr.filter(filterFalse2); return arr; } bouncer([1, null, NaN, 2, undefined]); What im doing wrong? NixonRichard @NixonRichard Jun 11 2016 09:47 var Car = function() { this.wheels = 4; this.engines = 1; this.seats = 1; }; // Only change code below this line. var myCar = new Car(); { this.wheels = 4; }; hi what s wrong with my code ? Priyankar Kumar @priyankark Jun 11 2016 09:50 { this.wheels = 4; }; does nothing at the end Nick Ang @nickangtc Jun 11 2016 09:51 @thomlom spot anything? NixonRichard @NixonRichard Jun 11 2016 09:52 The property nickname of myCar should be a string Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 09:53 @nickangtc There is something wrong with your URL obviously. What is weird is that if I type manually the URL in the browser, I get an object, but it's not working with codepen! So I'm trying to figure it out :p NixonRichard @NixonRichard Jun 11 2016 09:53 xhamster help plz CamperBot @camperbot Jun 11 2016 09:55 no wiki entry for: plz NixonRichard @NixonRichard Jun 11 2016 09:55 here s the link to my lesson help make instances of objects with a constructor function CamperBot @camperbot Jun 11 2016 09:56 ## :point_right: challenge make instances of objects with a constructor function [wiki] # Challenge Make Instance of Objects with a Constructor Function A function that creates objects is called a constructor_, my favorite way of creating objects when you have to create more than one of the same object. You can also edit the second object to add more properties if needed. This is called creating _instances of an object. Each new instance of this object inherits all the properties and methods of your original object. var Car = function() { this.wheels = 4; }; // New instance of Car object. var myCar = new Car(); //Add the property "engines" to myCar, and make it a number. myCar.engines = 1; Nick Ang @nickangtc Jun 11 2016 09:56 @thomlom oh the url? Ahh.. yeah it's so strange isn't it? I did the same thing with the URL and I can get the object Did I use the right methods to access the object properties? I double checked and it looks right.. Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 10:05 @nickangtc The fact is that your callback function is not called Chris @VexBlade Jun 11 2016 10:06 Hi, I was wondering if this would be the best way to do this, it passes but I am not sure if its be best way. function convertToF(celsius) { var fahrenheit; // Only change code below this line var a = celsius * 9/5 + 32; fahrenheit = a; // Only change code above this line return fahrenheit; } // Change the inputs below to test your code convertToF(-30); Priyankar Kumar @priyankark Jun 11 2016 10:06 why not just var fahrenheit = celsius * 9/5 + 32 or just return celsius * 9/5 + 32; Chris @VexBlade Jun 11 2016 10:07 ah, see I knew it could be done easier. Danny Nguyen @Chrysippean Jun 11 2016 10:08 How do you guys put screenshots in chat? Chris @VexBlade Jun 11 2016 10:08 @priyankark Thanks CamperBot @camperbot Jun 11 2016 10:08 vexblade sends brownie points to @priyankark :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for priyankark Priyankar Kumar @priyankark Jun 11 2016 10:09 help format CamperBot @camperbot Jun 11 2016 10:09 ## :point_right: code formatting [wiki] # Multi line Code js ⇦ Type 3 backticks and then press [shift + enter ⏎] (type js or html or css) <paste your code here>, then press [shift + enter ⏎]  ⇦ Type 3 backticks, then press [enter ⏎] # Single line Code This an inline <paste code here> code formatting with a single backtick() at _start_ and _end_ around thecode. See also: ☛ How to type Backticks | ☯ Compose Mode | ❄ Gitter Formatting Basics Priyankar Kumar @priyankark Jun 11 2016 10:09 This message was deleted CamperBot @camperbot Jun 11 2016 10:09 :bulb: to format code use backticks!  more info Priyankar Kumar @priyankark Jun 11 2016 10:09 This message was deleted Danny Nguyen @Chrysippean Jun 11 2016 10:10 '''<p>Test<p> ''' CamperBot @camperbot Jun 11 2016 10:10 :bulb: to format code use backticks!  more info Danny Nguyen @Chrysippean Jun 11 2016 10:10 <p>Test2</p> Priyankar Kumar @priyankark Jun 11 2016 10:11 <p> Done </p> Danny Nguyen @Chrysippean Jun 11 2016 10:11 I see, thanks @priyankark CamperBot @camperbot Jun 11 2016 10:11 sensasian sends brownie points to @priyankark :sparkles: :thumbsup: :sparkles: :warning: could not find receiver for priyankark Shusil Banjade @shusil123 Jun 11 2016 10:11 @Sensasian , backsticks , above tab button in my keyboarsd. Not ''', single quotes CamperBot @camperbot Jun 11 2016 10:11 :bulb: to format code use backticks!  more info Danny Nguyen @Chrysippean Jun 11 2016 10:12 Yeah I figured that out haha, it's late :c Priyankar Kumar @priyankark Jun 11 2016 10:12 any idea people why the bot cant find a receiver for me Nick Ang @nickangtc Jun 11 2016 10:19 @thomlom how did you figure that out? Danny Nguyen @Chrysippean Jun 11 2016 10:19 I'm on the Javascript "Record Collection" lesson & my code is close, but the problem is that it's not adding a "track" property to id 5439. Anyone know what I'm missing? function updateRecords(id, prop, value) { if (value !== "" && prop === "tracks") { collection[id].tracks.push(value); } else if (value !== "") { collection[id][prop] = value; } else if (value === "") { delete collection[id][prop]; } return collection; } Here's the collection // 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)); "After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element." Creative Shin @CreativeShin Jun 11 2016 10:23 can someone explain me for-in loop in objects ? skipperhi @skipperhi Jun 11 2016 10:25 @Creative-Shin what do you mean by that? Creative Shin @CreativeShin Jun 11 2016 10:26 for (var key in anyobj){} This message was deleted This message was deleted Brendan Kinahan @BKinahan Jun 11 2016 10:27 @priyankark it means your github account isn't linked to your FCC profile, you can add it from your FCC settings Ghost @ghost~56ef2a8b85d51f252ab9dec9 Jun 11 2016 10:28 @nickangtc $(document).ready(function() {

// All global variables
var latitude = 0;
var longitude = 0;
var tempC = 0; // temp in Celsius (default OpenWeather unit)
var tempF = tempC * 9 / 5 + 32; // temp in Fahrenheit
var clouds = 0;
var rain = 0;
var clickCount = 0;

// Function to get location
function geolocateMe() {
// Check if browser supports geolocation
if ("geolocation" in navigator) {
console.log("geolocation supported");
} else {
console.log("geolocation not supported on this browser");
}
// Message to return when geolocation not supported
if (!navigator.geolocation) {
$("#locationMessage").text("Geolocation not supported on your browser"); } // Messge to return when geolocation can't be obtained // including when user blocks geolocation permission function error() {$("#locationMessage").text("Can't get your location");
}
// What to do when geolocation is successfully obtained
function success(position) {
latitude = Math.floor(position.coords.latitude);
longitude = Math.floor(position.coords.longitude);
$("#locationMessage").text("Your position is " + latitude + " lat & " + longitude + " long."); getWeather(latitude, longitude) } // Get Location navigator.geolocation.getCurrentPosition(success, error); } //--- Get geolocation now geolocateMe(); //|--- Get weather data and display on page function getWeather(latitude, longitude){ console.log(latitude, longitude) var url = "http://api.openweathermap.org/data/2.5/weather?lat=50&lon=2?callback=?&APPID=95eaa17a6d237ecea9f9956ac1b77766"$.getJSON(url, function(data) {
console.log("success")
tempC = data.weather.main.temp / 10; // OpenWeather API returns Celsius * 10
rain = data.rain["3h"];
clouds = data.clouds.all;
console.log(tempC);
console.log(rain);
console.log(clouds);
}); // end of "get" weather --|
console.log("blabla")
}

// Display temperature, in Celsius by default
$("#temperatureDisplay").prepend(tempC); // Determine weather image to display in background if (rain > 0) {$(".body").append("<body background='https://images.unsplash.com/photo-1428592953211-077101b2021b?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=9d68a7748a61d3609c2f1417ab7fd7e0'></body>");
} else {
if (clouds < 50) {
$("#weatherImg").append("<body background='https://images.unsplash.com/photo-1428592953211-077101b2021b?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=9d68a7748a61d3609c2f1417ab7fd7e0'></body>"); } else if (clouds >= 50) {$("#weatherImg").append("<body background='https://images.unsplash.com/photo-1428592953211-077101b2021b?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=9d68a7748a61d3609c2f1417ab7fd7e0'></body>");
}
}

$("#temperatureDisplay").on("click", function() { if (clickCount % 2 === 0) {$("#temperatureDisplay").text(tempF + " F");
clickCount++;
} else {
\$("#temperatureDisplay").text(tempC + " C");
clickCount++;
}
}

)
})
Brendan Kinahan
@BKinahan
Jun 11 2016 10:28
Ghost
@ghost~56ef2a8b85d51f252ab9dec9
Jun 11 2016 10:29
@thomlom You can see that you get in your console the latitude, the longitude, blabla but not success! So that means that your callback function is not firing, and I have to admit I don't know at all how to resolve this. The JSON code is valid, so the callback function should fire... :/
skipperhi
@skipperhi
Jun 11 2016 10:29
@Sensasian You need to check for “hasOwnProperty” for tracks, then create a tracks, since id 5439 doesn’t have a tracks
Creative Shin
@CreativeShin
Jun 11 2016 10:30
@BKinahan I actually just visited that...anyway I know what I am doing wrong now...
@BKinahan @skipperhi thanks
CamperBot
@camperbot
Jun 11 2016 10:30
creative-shin sends brownie points to @bkinahan and @skipperhi :sparkles: :thumbsup: :sparkles:
:star2: 1622 | @bkinahan |http://www.freecodecamp.com/bkinahan
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:32
hi friends i'm stuck on counting cards problem. i'm using switch satement . i'm not understanding how should i return.
@shusil123
Jun 11 2016 10:33
@oxide94Git , paste your code here in format
Stephen James
@sjames1958gm
Jun 11 2016 10:33
@nickangtc If you are using a recent chrome (vers 50+) then getLocation will only work for https:// sites. And api.openweather.org only for http:// so you may need to use a different location mechanism - the api for ip-api.com will give you location based on IP address.
Brendan Kinahan
@BKinahan
Jun 11 2016 10:33
@oxide94Git what you return should depend on the current value of count after the current (and previous) card drawn are taken into account.
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:33

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 += 1;
break;
case 7:
case 8:
case 9:
count = count ;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
}
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');

Stephen James
@sjames1958gm
Jun 11 2016 10:33
@oxide94Git
help format
CamperBot
@camperbot
Jun 11 2016 10:33

# 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 thecode.

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

ALMY91
@ALMY91
Jun 11 2016 10:34
hi guys
Stephen James
@sjames1958gm
Jun 11 2016 10:34
@oxide94Git The instructions indicate that you need to compare count to zero and decide what to return. Maybe if else after switch.
ALMY91
@ALMY91
Jun 11 2016 10:34
i dont understand what does this function do?
var a=[2,3,4];
var big= a.reduce(function(accumulator,value){return Math.pow(value,accumulator);});

console.log(big);
specifically Math.pow
Brendan Kinahan
@BKinahan
Jun 11 2016 10:34
@oxide94Git Hold/Bet should also have a space before them in your returned string.
Stephen James
@sjames1958gm
Jun 11 2016 10:35
@ALMY91 Math.pow(x, y); raises x to the power y
skipperhi
@skipperhi
Jun 11 2016 10:35
@oxide94Git You need an if/else to text for whether count is negative or not
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:35
@ALMY91 hi how did you paste that. i had to copy paste on the chat box thats why.
Stephen James
@sjames1958gm
Jun 11 2016 10:35
This message was deleted
Brendan Kinahan
@BKinahan
Jun 11 2016 10:36
@ALMY91 Step by step, it does 3^2 (9), then 4^9 (262144)
@sjames1958gm note the reversal of the variables :)
Stephen James
@sjames1958gm
Jun 11 2016 10:36
Yeah, deleted my wrongness :)
Stephen James
@sjames1958gm
Jun 11 2016 10:37
@oxide94Git Three backticks (next to one key), then shift-enter, then paste, then shift-enter then three backticks then enter
backticks are next to the one key (on my keyboard)
Brendan Kinahan
@BKinahan
Jun 11 2016 10:37

@oxide94Git like this:

js


Aleksa Rakic
@aleksarakic
Jun 11 2016 10:40
I'm working on 'Drop it' algorithm.. I cant find a way to remove array elements in for loop without messing up array length. Looping backwards doesn't work with this algorithm. Any ideas?
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:41
@shusil123 @BKinahan @sjames1958gm thank you :smile: ..
CamperBot
@camperbot
Jun 11 2016 10:41
oxide94git sends brownie points to @shusil123 and @bkinahan and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1522 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
:star2: 1623 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 11 2016 10:42
@aleksarakic could be simpler to just find the first one that returns true, note its location, and then drop everything before it in the array
Nick Ang
@nickangtc
Jun 11 2016 10:43
@thomlom thanks a lot for looking through my code and adding to it
CamperBot
@camperbot
Jun 11 2016 10:43
nickangtc sends brownie points to @thomlom :sparkles: :thumbsup: :sparkles:
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:44
@skipperhi you too thank you :+1:
CamperBot
@camperbot
Jun 11 2016 10:44
oxide94git sends brownie points to @skipperhi :sparkles: :thumbsup: :sparkles:
Aleksa Rakic
@aleksarakic
Jun 11 2016 10:44
@BKinahan thanks, good approach :)
CamperBot
@camperbot
Jun 11 2016 10:44
aleksarakic sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1624 | @bkinahan |http://www.freecodecamp.com/bkinahan
Nick Ang
@nickangtc
Jun 11 2016 10:44
@sjames1958gm I'm not sure I know what you mean... how can I change the location mechanism? And what's ip-api.com? Open Weather states not to use IP address, and use only openweather.org
Stephen James
@sjames1958gm
Jun 11 2016 10:45
@nickangtc You can request, using getJSON to ip-api.com to get your location. it will return json with lat long for you to use
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:46

js
sorry just trying
Nick Ang
@nickangtc
Jun 11 2016 10:46
Ahh I think I know what you mean. But Chrome loads my location just fine - it's the openweather data that I'm not receiving
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:47

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 += 1;
break;
case 7:
case 8:
case 9:
count = count ;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
}
// Only change code above this line
}

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
sorry ill try some where else
Stephen James
@sjames1958gm
Jun 11 2016 10:48
@oxide94Git Three at the end - you can edit your post move your mouse to the right side of the post and see three dots that is a menu if you left click
Brendan Kinahan
@BKinahan
Jun 11 2016 10:48
@oxide94Git you forgot one backtick at the end there. you can edit your message to fix it :D
Stephen James
@sjames1958gm
Jun 11 2016 10:48
@nickangtc If you are using codepen then you are connected to them over https://
Priyankar Kumar
@priyankark
Jun 11 2016 10:48
@BKinahan Thanks
CamperBot
@camperbot
Jun 11 2016 10:48
priyankark sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1625 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 11 2016 10:48
@oxide94Git and again, your answer shouldn't depend only on the current card being drawn, but on the overall value of count so far.
Nick Ang
@nickangtc
Jun 11 2016 10:49
@sjames1958gm thanks I'll try that later
CamperBot
@camperbot
Jun 11 2016 10:49
nickangtc sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1523 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Nick Ang
@nickangtc
Jun 11 2016 10:49
Have to cook dinner now ~
Oxide Debbarma
@oxide94Git
Jun 11 2016 10:50
@sjames1958gm actually i did'nt change anything yet i'm trying posting code
Stephen James
@sjames1958gm
Jun 11 2016 10:50
@oxide94Git I meant you could edit your post
Norvin Burrus
@ndburrus
Jun 11 2016 10:51
This message was deleted
CamperBot
@camperbot
Jun 11 2016 10:51

# 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 thecode.

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

Oxide Debbarma
@oxide94Git
Jun 11 2016 10:53
yes got it :+1: @sjames1958gm
:smile:
Sintclair
@saint21
Jun 11 2016 10:57
Hello guys, I have a question:
Is there any way to write a switch statement such that:
you can write: switch (var) {
case var = 1 or 2 or 3
do this;?
Stephen James
@sjames1958gm
Jun 11 2016 10:57
@oxide94Git :+1:
Sintclair
@saint21
Jun 11 2016 10:58
(instead of writing case var =1: case var =2: case var =3 ?
Stephen James
@sjames1958gm
Jun 11 2016 10:59
@saint21 Not that specifically, you can do case 1: case 2: case 3: on one line.
you don't do case var = 1:
Sintclair
@saint21
Jun 11 2016 11:00
Ok but you would have to repeat case and cannot put in an OR function?
operator
@sjames1958gm thank you :)
CamperBot
@camperbot
Jun 11 2016 11:01
saint21 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1524 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Stephen James
@sjames1958gm
Jun 11 2016 11:02
@saint21 no because switch (val) is going to do a compare val === to your case value, an || would turn it into a boolean and not what you intend.
Sintclair
@saint21
Jun 11 2016 11:04
I see, and when for example If I count values of cards, and the values 1 or 2 or 3 or 4 or 5 or 6 each have the same result (for example: count ++;)
I cannot pass those different cases as 1 condition
greg
@wearenotgroot
Jun 11 2016 11:05
@saint21 there is a previous lesson on that
Stephen James
@sjames1958gm
Jun 11 2016 11:05
Sintclair
@saint21
Jun 11 2016 11:06
@wearenotgroot @sjames1958gm I am aware of that : ) Just asking whether it was possible to do faster than in that challenge. Thank you for your repsonses
CamperBot
@camperbot
Jun 11 2016 11:06
saint21 sends brownie points to @wearenotgroot and @sjames1958gm :sparkles: :thumbsup: :sparkles:
:warning: saint21 already gave sjames1958gm points
:star2: 1129 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Ajkula91
@Ajkula91
Jun 11 2016 11:07
I guess i am retarded
Word Blanks, what is the solution?
greg
@wearenotgroot
Jun 11 2016 11:08
@saint21 focus on the basic first, shorthand and optimization comes later
Sintclair
@saint21
Jun 11 2016 11:08
That seems like good advise :)
greg
@wearenotgroot
Jun 11 2016 11:08
@Ajkula91 what have you tried so far?
@Ajkula91 think of it as creating a sentence with those give parameters
Ajkula91
@Ajkula91
Jun 11 2016 11:10
greg
@wearenotgroot
Jun 11 2016 11:11
@Ajkula91 myNoun, myAdjective and so on are parameters
@Ajkula91 so they shouldnt be inisde a ""
@Ajkula91 exmp
result = myAdjective + " some other sting " + ...; //concatenate string and variables with  +
Alina Melnykova
@miroshnichka
Jun 11 2016 11:12

hey guys! I have a problem with:Record Collection
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 !== "") and prop is not "tracks" then update or set the value for the prop.
If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.
If value is blank, delete that prop.

Always return the entire collection object.

My code:

// 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 col = collection[id];

if(value !== "" &&prop !== "tracks"){
col[prop] = value;
}
else if(value !== ""&&prop == "tracks"){
col[prop].push(value);

}
else {
delete col[prop];
}
return collection;

}
// Alter values below to test your code
updateRecords(5439, "artist", "ABBA"); 
The problem is : After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.

Markus Kiili
@Masd925
Jun 11 2016 11:13
@miroshnichka Create the tracks array if it is absent.
greg
@wearenotgroot
Jun 11 2016 11:14
@miroshnichka nvm
Alina Melnykova
@miroshnichka
Jun 11 2016 11:15
@Masd925 thank you! it works)
CamperBot
@camperbot
Jun 11 2016 11:15
miroshnichka sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1816 | @masd925 |http://www.freecodecamp.com/masd925
greg
@wearenotgroot
Jun 11 2016 11:15
@miroshnichka use .hasOwnProperty to test if track array exist or not, just like what @Masd925 said
Ajkula91
@Ajkula91
Jun 11 2016 11:18
@wearenotgroot thx, depressed
CamperBot
@camperbot
Jun 11 2016 11:18
ajkula91 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star2: 1130 | @wearenotgroot |http://www.freecodecamp.com/wearenotgroot
Jesse Jafa
@awareness481
Jun 11 2016 11:22
So, if I want to check if my string contains any A to Z characters is this a way to do it?
var reg = /[^A-Za-z]/;
if (reg.test(str) === true)
Islam Abasov
@IslamA
Jun 11 2016 11:26
find Caesars Cipher
CamperBot
@camperbot
Jun 11 2016 11:26

find caesars cipher

:zero: algorithm caesars cipher

Stephen James
@sjames1958gm
Jun 11 2016 11:27
@tstusr441 That is the opposite the ^ negates the rest
Jesse Jafa
@awareness481
Jun 11 2016 11:30
Thanks @sjames1958gm
CamperBot
@camperbot
Jun 11 2016 11:30
:star2: 1525 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
tstusr441 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
Markus Kiili
@Masd925
Jun 11 2016 11:37
@tstusr441 If you are doing Caesar's cipher, you could use .replace and regexp to target characters A-Z and change them according to the task.
Jesse Jafa
@awareness481
Jun 11 2016 11:39
Thanks @Masd925 . I'm actually doing the "Validate US Telephone Numbers" algorithm and just using /[A-Za-z]/(without the ^) seems to be working
CamperBot
@camperbot
Jun 11 2016 11:39
tstusr441 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1817 | @masd925 |http://www.freecodecamp.com/masd925
Stephane
@overmelo
Jun 11 2016 11:42
@sjames1958gm hello, do you have free time? i want to complete a project that is bothering me
Stephen James
@sjames1958gm
Jun 11 2016 11:43
Just a little bit of time, have to get my daughter up for volleyball tourney.
Stephane
@overmelo
Jun 11 2016 11:44
oh alright maybe later then, cos it will take long
Stephen James
@sjames1958gm
Jun 11 2016 11:44
Sry
kwal0203
@kwal0203
Jun 11 2016 11:50
Hey the backend chat doesn't seem to have much traffic. Anybody in here able to help with Node?
tavinjordaan
@tavinjordaan
Jun 11 2016 11:50

function nextInLine(arr, item) {

return item; // Change this line
}

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

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

kwal0203
@kwal0203
Jun 11 2016 11:50
I'mg doing start a node js server challenge
tavinjordaan
@tavinjordaan
Jun 11 2016 11:50
It's called "Stand in Line"
Artem Slepets
@slepets-a
Jun 11 2016 11:51
Can someone help me with escape-sentece?
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
var myStr = "\ \t \t \r \n ";
What I did wrong? :-)
Markus Kiili
@Masd925
Jun 11 2016 11:53
@tavinjordaan Find out the two array methods that do the tasks, and use them on arr and item.
Norvin Burrus
@ndburrus
Jun 11 2016 11:55
@tavinjordaan you may find this useful: "Javascript Array Methods: Unshift(), Shift(), Push(), And Pop()" {ref: http://www.bennadel.com/blog/1796-javascript-array-methods-unshift-shift-push-and-pop.htm } :)
@49h4DhPERFECT carefully review/check the punctuation... :+1: hint: all punctuation...
Brendan Kinahan
@BKinahan
Jun 11 2016 11:56
@49h4DhPERFECT you have an extra space at the end ;)
Artem Slepets
@slepets-a
Jun 11 2016 11:56
@BKinahan It didnt pass the test even without extra space)
What d.. Its worked :D
Brendan Kinahan
@BKinahan
Jun 11 2016 11:57
@49h4DhPERFECT did you escape the backslash? it's hard to tell that in the chat unless you format it as code.
Artem Slepets
@slepets-a
Jun 11 2016 11:57
Yeah, I did. Thanks. It work
"\ test"
Brendan Kinahan
@BKinahan
Jun 11 2016 11:58
@ndburrus the capitalization of method names in that article really bugs me.
Artem Slepets
@slepets-a
Jun 11 2016 11:58
@BKinahan How I can format text as a code here?
Brendan Kinahan
@BKinahan
Jun 11 2016 11:58
bot format
CamperBot
@camperbot
Jun 11 2016 11:58

# 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 thecode.

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

Brendan Kinahan
@BKinahan
Jun 11 2016 11:58
:point_up: June 11, 2016 11:58 AM @49h4DhPERFECT
Artem Slepets
@slepets-a
Jun 11 2016 11:59
:+1:
Brendan Kinahan
@BKinahan
Jun 11 2016 11:59
js
like this

Artem Slepets
@slepets-a
Jun 11 2016 11:59
'''css
• {
CamperBot
@camperbot
Jun 11 2016 11:59
:bulb: to format code use backticks!  more info
Artem Slepets
@slepets-a
Jun 11 2016 12:01
* {
margin: 0;
padding: 0;
Oh, I get it now)
Alina Melnykova
@miroshnichka
Jun 11 2016 12:01

guys. got stuck with obj again=(
What am i doing wrong?

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

function lookUpProfile(firstName, prop){
// Only change code below this line
for (var i=0; i<contacts.length;i++){
if (firstName == contacts[i].firstName){
if(contacts[i].hasOwnProperty( prop )){
return contacts[i][prop];
}

  else {
return "No such contact";
}

}
}
return "No such property";

// Only change code above this line
}
// Change these values to test your function
lookUpProfile("Akira", "likes");

Norvin Burrus
@ndburrus
Jun 11 2016 12:01
@BKinahan where (capitalization in method names)? oh, you mean in the section titles? yes, i guess that can be annoying... :+1:
Markus Kiili
@Masd925
Jun 11 2016 12:03
Norvin Burrus
@ndburrus
Jun 11 2016 12:04
@miroshnichka if the first 2 if statements are true, is the else logic (the 1st else) accurate to return no such contact?
Alina Melnykova
@miroshnichka
Jun 11 2016 12:06
@Masd925 @ndburrus thank you. i switched them and now it works) such a stupid mistake
CamperBot
@camperbot
Jun 11 2016 12:06
miroshnichka sends brownie points to @masd925 and @ndburrus :sparkles: :thumbsup: :sparkles:
:warning: miroshnichka already gave masd925 points
Norvin Burrus
@ndburrus
Jun 11 2016 12:07
@miroshnichka you're welcome :) you're on fire :fire:
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:13
hey guys does this work for you? https://codepen.io/rektix/pen/rLNNXL
Norvin Burrus
@ndburrus
Jun 11 2016 12:14
@rektix hmm... no response when the buttons are pressed....
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:14
it worked perfectly before
now it doesnt even show me city name and those things
only title and buttons
Arvin
@arvkh
Jun 11 2016 12:15
does someone here know how scrollyspy works????
Norvin Burrus
@ndburrus
Jun 11 2016 12:15
@rektix was the working version (code) saved?
Arvin
@arvkh
Jun 11 2016 12:15
does someone here know how scrollspy works????
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:15
yeah
i havent canged anything
Jim Dennis
@JimDennis
Jun 11 2016 12:16

So here's my first attempt at a new "CodePen" (and my first attempt at animated line drawing with SVG):

http://codepen.io/JimD/full/YWwMwX/

Arvin
@arvkh
Jun 11 2016 12:17
Does anybody here know how scrollspy works?
Jun 11 2016 12:17
@rektix - it works (on the Chrome / windows ) browser if you do not load via https:// but only http://.
Arvin
@arvkh
Jun 11 2016 12:17
Does anybody here understand how scrollspy works?
Greg Duncan
@GregatGit
Jun 11 2016 12:17
@arvkh http://www.w3schools.com/bootstrap/bootstrap_scrollspy.asp have a look at the template here
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:18
yeah i noticed that codepen changed to https
Jun 11 2016 12:18
@arvkh - no, I have never used it -looks like @GregatGit has a link
Arvin
@arvkh
Jun 11 2016 12:18
I did, but I don't understand how I can use it in my code.
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:18
@khaduch so what should i do to make it work again
Arvin
@arvkh
Jun 11 2016 12:18
@GregatGit
jakehm
@jakehm
Jun 11 2016 12:18
when there is an apostraphe it shows up as weird character
Norvin Burrus
@ndburrus
Jun 11 2016 12:19
@arvkh you may find this useful: "Bootstrap Scrollspy Plugin (Advanced)" {ref: http://www.w3schools.com/bootstrap/bootstrap_scrollspy.asp }, "ScrollSpy scrollspy.js" {ref: http://getbootstrap.com/javascript/ } "Scrollspy" {ref: http://v4-alpha.getbootstrap.com/components/scrollspy/ } "Scrollspy" {ref: https://davidwalsh.name/js/scrollspy }
Jun 11 2016 12:19
@rektix - just post the link at http:// instead. I think that CodePen works okay when you do that - when you post the link, if it's https:// just take the "s" out.
jakehm
@jakehm
Jun 11 2016 12:19
Arvin
@arvkh
Jun 11 2016 12:19
Thank you, but the problem I have is that it doesn't work in my code
It doesn't explain how it works
Jun 11 2016 12:19
Greg Duncan
@GregatGit
Jun 11 2016 12:19
@arvkh can you put your pen up
Arvin
@arvkh
Jun 11 2016 12:20
Sure
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:21
CamperBot
@camperbot
Jun 11 2016 12:21
rektix sends brownie points to @khaduch :sparkles: :thumbsup: :sparkles:
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:22
btw is there any way that i can make it http by default
@shusil123
Jun 11 2016 12:22
@JimDennis , Cool stuff. Inspiration, huh!!!
Arvin
@arvkh
Jun 11 2016 12:22
@GregatGit I'll DM you if that's ok?
Jim Dennis
@JimDennis
Jun 11 2016 12:22
Greg Duncan
@GregatGit
Jun 11 2016 12:23
@arvkh sure
Jim Dennis
@JimDennis
Jun 11 2016 12:24
The "[Show Solution]" logic is currently all wrong; and redundant. I was firs playing with fading the solution in with opacity before I found the (linked) tutorial on how to animate line drawing with the dasharray hack.
Also my "dash array" settings are quite right. Need to tune those.
Arvin
@arvkh
Jun 11 2016 12:24
@GregatGit Great. Did you get my message? :) For some reason you have to click on chat privately, otherwise the messages don't show up.
Jun 11 2016 12:26
@rektix - I don't know for sure - it seems that CodePen "normally" wants to use https:// - which is better for security. But sometimes you need to access things via http:// - for example, the openweather site, and the non-secure requests won't work from a site accessed with https - that's what was causing the problem. Perhaps, if you can change your request to the ip-api site to https://, then you can access everything via https? - but that does not seem to work.
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:27
hmmm ill try
Jun 11 2016 12:27
@rektix - it doesn't look like they have https access implemented there
Mihajlo Krsmanović
@rektix
Jun 11 2016 12:28
yeah just tried it
Konstantin
@kostanakis
Jun 11 2016 12:31

function destroyer(arr) {

function filter(value) {
return value != arguments[1] || value != arguments[2] || value != arguments[3];
}
// Remove all the values
arr = arr.filter(filter);
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Awful code, right?
Is there any way to pass several arguments at once?
Brendan Kinahan
@BKinahan
Jun 11 2016 12:33
@kostanakis it's not the worst code
Kévin Joffard
@kejoff
Jun 11 2016 12:33
Hi everybody, I'm stucked on the switch statement. I've no error message, so I don't know really what to do
Konstantin
@kostanakis
Jun 11 2016 12:34
Brendan Kinahan
@BKinahan
Jun 11 2016 12:34
@kostanakis the logic is a bit off though, because 2 is equal to 2 but not equal to 3, it won't be destroyed
Kévin Joffard
@kejoff
Jun 11 2016 12:34
function caseInSwitch(val) {
// Only change code below this line
switch (val){
case 1:
console.log("alpha");
break;
case 2:
console.log("beta");
break;
case 3:
console.log("gamma");
break;
case 4:
console.log("delta");
break;
}

// Only change code above this line
}

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

Brendan Kinahan
@BKinahan
Jun 11 2016 12:35
@kostanakis if you can make a proper array using the elements of the arguments object, you can use array methods like indexOf() to see if it contains certain values...
jakehm
@jakehm
Jun 11 2016 12:36
anyone know why this is happening "Bill Tregle&#8217;s Dad"
Brendan Kinahan
@BKinahan
Jun 11 2016 12:36
@kejoff you want to assign the strings to the variable answer, not just log them to the console.
jakehm
@jakehm
Jun 11 2016 12:36
Konstantin
@kostanakis
Jun 11 2016 12:37
@kejoff You shouldn't use console.log, just change the value of answer and return it
Kévin Joffard
@kejoff
Jun 11 2016 12:37
but when I use answer.push it doesn't work as well :/
Brendan Kinahan
@BKinahan
Jun 11 2016 12:37
@kejoff assignment is done with the = operator
Konstantin
@kostanakis
Jun 11 2016 12:38
@BKinahan thanks for clue.
CamperBot
@camperbot
Jun 11 2016 12:38
kostanakis sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star2: 1626 | @bkinahan |http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Jun 11 2016 12:38
@kejoff push() is for arrays.
@shusil123
Jun 11 2016 12:39
@jharrowmortelliti , clean and functional quote machine....cool stuff
jakehm
@jakehm
Jun 11 2016 12:39
@shusil123 ya but the problem is some characters aren't encoding correctly
Kat
@Topzie
Jun 11 2016 12:40
Anyone else experiencing 404 error to https://www.freecodecamp.com/js/jquery.min.map ?
jakehm
@jakehm
Jun 11 2016 12:40
Kévin Joffard
@kejoff
Jun 11 2016 12:40
Silly me!!! I make it more complicated than it is... Thanks @kostanakis and @BKinahan :)
CamperBot
@camperbot
Jun 11 2016 12:40
:star2: 1627 | @bkinahan |http://www.freecodecamp.com/bkinahan
kejoff sends brownie points to @kostanakis and @bkinahan :sparkles: :thumbsup: :sparkles:
@shusil123
Jun 11 2016 12:41
@jharrowmortelliti , oh! Though, the look is cleaner
Kat
@Topzie
Jun 11 2016 12:42
help Cannot GET /js/jquery.min.map
CamperBot
@camperbot
Jun 11 2016 12:42
no wiki entry for: cannot get jsjqueryminmap
Norvin Burrus
@ndburrus
Jun 11 2016 12:42
@Topzie Cannot GET /js/jquery.min.map this may be useful: "jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)" {ref: http://stackoverflow.com/questions/18365315/jquerys-jquery-1-10-2-min-map-is-triggering-a-404-not-found } you're welcome :)
Kat
@Topzie
Jun 11 2016 12:44
@ndburrus thanks
CamperBot
@camperbot
Jun 11 2016 12:44
topzie sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Tbuglc
@tbuglc
Jun 11 2016 12:44
hey guys, I'm getting stuck in counting cards test, your help please
Norvin Burrus
@ndburrus
Jun 11 2016 12:45
@kejoff you may find this useful: "Javascript Array Methods: Unshift(), Shift(), Push(), And Pop()" {ref: http://www.bennadel.com/blog/1796-javascript-array-methods-unshift-shift-push-and-pop.htm } :)
Jesse Jafa
@awareness481
Jun 11 2016 12:48
Why doesn't this work? It's supposed to check if the character preceeding the "-" character is a number. If it's not it should return false.
  var temp = str.indexOf("-") - 1;
if(isNaN(str.charAt(temp))) {
return false;
}

/*
telephoneCheck("-1 (757) 622-7382") should return false
My code returns true
*/
Tbuglc
@tbuglc
Jun 11 2016 12:48
@ndburrus : the problem is i don't understand it all. writting code is not a problem
Norvin Burrus
@ndburrus
Jun 11 2016 12:48
@tbuglc which challenge are you referencing (or working on)? ok, great - can you post what you've got, so far?
Tbuglc
@tbuglc
Jun 11 2016 12:49
@ndburrus : counting cards in javascript
Greg Duncan
@GregatGit
Jun 11 2016 12:50
@tstusr441 wouldn't that be +1
Jesse Jafa
@awareness481
Jun 11 2016 12:51
As far as I understand it should be - 1. I'm trying to check the character that comes before the "-". I could be wrong though
Greg Duncan
@GregatGit
Jun 11 2016 12:53
@tstusr441 "-1 (757) 622-7382" the index for that would be 0 then you -1 giving you the resutl of '-1'
Anton Tokar
@AntonTokar
Jun 11 2016 12:54

'''

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (i=0; i < arr.length; i++){
for (j=0; j<arr[i].lenght; j++){
product= product*arr[i][j];

}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);

'''

CamperBot
@camperbot
Jun 11 2016 12:54
:bulb: to format code use backticks!  more info
Greg Duncan
@GregatGit
Jun 11 2016 12:54
there is no character before the - @tstusr441
Anton Tokar
@AntonTokar
Jun 11 2016 12:54

function multiplyAll(arr) {
var product = 1;
// Only change code below this line
for (i=0; i < arr.length; i++){
for (j=0; j<arr[i].lenght; j++){
product=  product*arr[i][j];

}

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

// Modify values below to test your code
multiplyAll([[1,2],[3,4],[5,6,7]]);
Jesse Jafa
@awareness481
Jun 11 2016 12:55
Oh, yea you're right. I'm dumb @GregatGit
Anton Tokar
@AntonTokar
Jun 11 2016 12:55
help
CamperBot
@camperbot
Jun 11 2016 12:55

# 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

Jesse Jafa
@awareness481
Jun 11 2016 12:55
Thanks @GregatGit
CamperBot
@camperbot
Jun 11 2016 12:55
tstusr441 sends brownie points to @gregatgit :sparkles: :thumbsup: :sparkles:
Anton Tokar
@AntonTokar
Jun 11 2016 12:56
challenge Nesting For Loops
Markus Kiili
@Masd925
Jun 11 2016 12:57
@AntonTokar lenght -> length
@shusil123
Jun 11 2016 12:57

function permAlone(str) {

var fresult = [];
if (str.length<2) {
return [str];
}
else {
var allcomb = [];
for (var i=0; i<str.length; i++) {
var letter = str.charAt(i);
var shorterword = str.substr(0, i)+str.substr(i+1);
var swarr = permAlone(shorterword);
for(var j=0; j<swarr.length; j++) {
allcomb.push(letter+swarr[j]);
}
}
var narr= [];
for(var k in allcomb) {
narr.push(allcomb[k].replace(/[^\w]|(.)(?=\1)/gi, '')); /*replacing consecutive repeated                                                                        characters with nothing.*/
}

narr = narr.filter(function(val) {
return val.length == str.length;
});

return narr.length;

}

}

permAlone('abaab');

Has anyone solved this problem ? No repeats pleasae (Advanced algorithm scripting). I get the array with the non-repeating permutations, but the length of that array returns 0. But the returning of the array works fine, it has all elements in it. That's super weird.

Help ...

@Masd925
Tbuglc
@tbuglc
Jun 11 2016 12:58
@ndburrus : what i don't really understand is this
Cards Sequence 2, 3, 4, 5, 6 should return "5 Bet"
Cards Sequence 7, 8, 9 should return "0 Hold"
Cards Sequence 10, J, Q, K, A should return "-5 Hold"
Cards Sequence 3, 7, Q, 8, A should return "-1 Hold"
Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Cards Sequence 2, 2, 10 should return "1 Bet"
Cards Sequence 3, 2, A, 10, K should return "-1 Hold"
Anton Tokar
@AntonTokar
Jun 11 2016 12:58
@Masd925 thank you very much
CamperBot
@camperbot
Jun 11 2016 12:58
antontokar sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1819 | @masd925 |http://www.freecodecamp.com/masd925
Tbuglc
@tbuglc
Jun 11 2016 12:58
@ndburrus : what's the logic behind?
Norvin Burrus
@ndburrus
Jun 11 2016 13:00
@tbuglc ok, all this indicates is that the card count is adjusted based on the card value received. ultimately, the values for all the cards received will be tallied (and adjusted per the chart). the final count determines what the playing action (bet/hold) action will be... make sense? :)
Richard Turza
@richtone
Jun 11 2016 13:02
hi! can anyone tell my why my code doesn't work? http://codepen.io/richardturza/pen/oLbObv
Greg Duncan
@GregatGit
Jun 11 2016 13:02
@shusil123 just to make it a litte easier to read you don't need the else
Konstantin
@kostanakis
Jun 11 2016 13:02
function destroyer(arr) {
var args = Array.prototype.slice.call(arguments,1);

function filter(value) {
if(!args.indexOf(value)) {
return value;
}
}

// Remove all the values
arr = arr.filter(filter);
return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
@shusil123
Jun 11 2016 13:03
@GregatGit , I know that. But the original problem ??
Konstantin
@kostanakis
Jun 11 2016 13:03
It becomes more clear for me, but I'm still stuck.
Markus Kiili
@Masd925
Jun 11 2016 13:04
@shusil123 Your function is recursive. If you change the return value to .length, it ceases to work. The change doesn't just change the last return value.
Konstantin
@kostanakis
Jun 11 2016 13:05
This code doesn't work properly, and it seems that I know why - args is an array, not a string, so indexOf isn't suitable... So, guys, please, give me another clue)
@shusil123
Jun 11 2016 13:05
Oh, how to solve that?? @Masd925 . Do i have to change the entire function structure?
Markus Kiili
@Masd925
Jun 11 2016 13:07
@shusil123 Making a recursive inner function might be the way. Then call it and return results length.
Norvin Burrus
@ndburrus
Jun 11 2016 13:09
@tbuglc how are we doing?
Markus Kiili
@Masd925
Jun 11 2016 13:09
@kostanakis if(!args.indexOf(value)) tests whether args.indexOf(value) is 0. Doesn't make sense to me why. Checking that it is -1 would.
Konstantin
@kostanakis
Jun 11 2016 13:11
if(args.indexOf(value) != -1) should work...give me a minute to test it)
js
 if(args.indexOf(value) == -1)
it works)
@Masd925 Thanks!)
CamperBot
@camperbot
Jun 11 2016 13:12
kostanakis sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star2: 1820 | @masd925 |http://www.freecodecamp.com/masd925
Tbuglc
@tbuglc
Jun 11 2016 13:13
@ndburrus : that the way I too understand but the problem is why when pass in 2,3,4,5,6 ==> "5 Bet" and at the same time down there it say for 3,7,8, A ==> "-1 Hold"
Markus Kiili
@Masd925
Jun 11 2016 13:13
@kostanakis Return true/false from the callback, not value.
@kostanakis You return the wrong thing at the end. Return the filtered array that filter returns.
Konstantin
@kostanakis
Jun 11 2016 13:15
Don't know, what you're speaking about, my code is accepted)
Norvin Burrus
@ndburrus
Jun 11 2016 13:16
@tbuglc ...that is beacuse the individual card values determine seperate card count adjustments (+1, 0/no change, & -1)... when all five card adjustment values are added, the final result indicates the play action (bet or hold)... :sparkles: ...clear as mud?
Cassidy Blay
@CBlay
Jun 11 2016 13:18
H
Konstantin
@kostanakis
Jun 11 2016 13:18
@Masd925 And why should I return bool? arr.filter accepts values to pass into new array.
Markus Kiili
@Masd925
Jun 11 2016 13:19
@kostanakis You should return true for those elements value you like to keep. Filter method does the iterating automatically. It passes each element in its turn to the callback as value of value, and keeps those that return true.
aksoybekir
@aksoybekir
Jun 11 2016 13:20
Hello I m new to community
Can I get a help about JS ?
Mar10-9us
@Mar10-9us
Jun 11 2016 13:20
Could someone explain to me why code in the upper comment cant use window.carName? I thought the variable was supposed to be global? My brain hurts.
http://www.w3schools.com/js/tryit.asp?filename=tryjs_scope_window
Norvin Burrus
@ndburrus
Jun 11 2016 13:20
@aksoybekir hello! welcome to fcc... :) i think you'll really like it... :sparkles: what are you working on?
Konstantin
@kostanakis
Jun 11 2016 13:21
js
function isBigEnough(value) {
return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
// filtered is [12, 130, 44]
Anton Tokar
@AntonTokar
Jun 11 2016 13:21

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

function lookUpProfile(firstName, prop) {
// Only change code below this line
if (firstName in contacts && prop in contacts) {
return prop;
}
else if (firstName in lookUpProfile) {
return ("No such property");
}
else if (prop in lookUpProfile){
return ("No such contacts");
}
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");
Konstantin
@kostanakis
Jun 11 2016 13:22
this is an example from mozilla docs)
Anton Tokar
@AntonTokar
Jun 11 2016 13:22
why it doesn't work ? challenge Profile Lookup
Norvin Burrus
@ndburrus
Jun 11 2016 13:24
@Mar10-9us you may find the following useful: "Demystifying JavaScript Variable Scope and Hoisting" {ref: https://www.sitepoint.com/demystifying-javascript-variable-scope-hoisting/ }, "JavaScript Variable Scope and Hoisting Explained" {ref: http://javascriptissexy.com/javascript-variable-scope-and-hoisting-explained/ } :sparkles:
Markus Kiili
@Masd925
Jun 11 2016 13:25
@kostanakis value >= 10 is boolean.
Norvin Burrus
@ndburrus
Jun 11 2016 13:25
@AntonTokar check/review the if statement syntax/format: "JavaScript - if...else Statement" {ref: http://www.tutorialspoint.com/javascript/javascript_ifelse.htm }
Mar10-9us
@Mar10-9us
Jun 11 2016 13:25
@ndburrus Thats a lot of text! haha. thanks.
CamperBot
@camperbot
Jun 11 2016 13:25
mar10-9us sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Konstantin
@kostanakis
Jun 11 2016 13:26
@Masd925 Okay, thanks that pointed this for me, I should remember this)
CamperBot
@camperbot
Jun 11 2016 13:26
kostanakis sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:warning: kostanakis already gave masd925 points
Konstantin
@kostanakis
Jun 11 2016 13:28
@Masd925 But it works either bool or value is returned)
Zachary Bennett
@zbennett10
Jun 11 2016 13:28
var count = 0;

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

if (card == 2 || card == 3 || card == 4 || card == 5 || card ==6) {
count ++;
}

if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == "A") {
count --;
}

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

if (count>=0) {
return couont + ("Bet");
}
return "Change Me";
// Only change code above this line
}
Konstantin
@kostanakis
Jun 11 2016 13:28
In certain challenge, of course
Zachary Bennett
@zbennett10
Jun 11 2016 13:29
Says count isnt defined. dont really understand why. Thanks for the help
Norvin Burrus
@ndburrus
Jun 11 2016 13:29
@Mar10-9us ...basically, the placement/location of variables within the code determines if they are global or local. when they are placed in functions - they are local (& available within) in the function. when variables are placed outside functions - they are available everywhere... :+1:
@zbennett10 carefully examine this code piece: count ++; what are you trying to do? :)
Zachary Bennett
@zbennett10
Jun 11 2016 13:31
@ndburrus im trying to add 1 to the global variable count. But the code is saying count isnt defined
Bil
@thebiltheory
Jun 11 2016 13:32
Hi, Does anyone now how you define the “offline” “online” State on the twitch project?
pleaaaaase
Norvin Burrus
@ndburrus
Jun 11 2016 13:33
@zbennett10 when you say add 1 to the global variable count, do you mean you want to assign the count variable the value of itself, plus one? :)
Zachary Bennett
@zbennett10
Jun 11 2016 13:33
yes
Cassidy Blay
@CBlay
Jun 11 2016 13:33
function nextInLine (arr,
llamatarianism
@llamatarianism
Jun 11 2016 13:33
@thebiltheory pretty sure there's something in the twitch API that tells you whether they're streaming or not.
Norvin Burrus
@ndburrus
Jun 11 2016 13:33
@zbennett10 super! so, how do we assign values?
llamatarianism
@llamatarianism
Jun 11 2016 13:34
@thebiltheory https://github.com/justintv/Twitch-API <- important
Tbuglc
@tbuglc
Jun 11 2016 13:34
@ndburrus :I've got it pass! Thanks
CamperBot
@camperbot
Jun 11 2016 13:34
tbuglc sends brownie points to @ndburrus :sparkles: :thumbsup: :sparkles:
Norvin Burrus
@ndburrus
Jun 11 2016 13:35
@tbuglc nice work! :sparkles:
Cassidy Blay
@CBlay
Jun 11 2016 13:35
function nextInLine (arr, item) { //your code here. return item; // change code on this line
how do I complete this challenge?
Zachary Bennett
@zbennett10
Jun 11 2016 13:35
you use a variable
@ndburrus
Stephen James
@sjames1958gm
Jun 11 2016 13:35
@zbennett10 check for misspellings
Zachary Bennett
@zbennett10
Jun 11 2016 13:36
CamperBot
@camperbot
Jun 11 2016 13:36
zbennett10 sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 1526 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Tbuglc
@tbuglc