18th
Mar 2016
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 00:09
so I think I left somethign out or something
because this works and doesnt work
``````function largestOfFour(arr) {
var max = [];
var arrmax = 0;

for (var i=0; i<arr.length; i++){
for (var j=0; j<arr[i].length; j++){
if (arr[i][j] > arrmax){
arrmax = arr[i][j];}
max.push(arrmax);}
}
return max;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
so its giving me everything returned
but repeating the max
so the return is happening every time instead of just after the fors
wait i think i got it
so its working
but not giving credit
Pete
@petegarvin1
Mar 18 2016 00:10
@Jordanmeyer89 i think i just sorted the arrays then pushed the last values into a new array for that challenge...
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 00:11
got it
woo
thank you
I had to reset the arrmax at each i loop
Pete
@petegarvin1
Mar 18 2016 00:11
:D
@Jordanmeyer89 actually i just checked my code, i did it exactly how you did!
Marc
@wumpafruits
Mar 18 2016 00:21
@Jordanmeyer89 @Spacecamel100 I'm on the same exercise....looking through my FCC notes I can't find anything, so I'm about to start google searching...
not for the solution but hopefully something better than .sort()
Pete
@petegarvin1
Mar 18 2016 00:22
@wumpafruits sort would actually have been a better way to do it than what i did
@wumpafruits ill be switching to that if i ever go back and re-do
Marc
@wumpafruits
Mar 18 2016 00:27
@Spacecamel100 i shall continue to try with sort for awhile then!
@Spacecamel100 thanks
CamperBot
@camperbot
Mar 18 2016 00:27
wumpafruits sends brownie points to @spacecamel100 :sparkles: :thumbsup: :sparkles:
:star: 379 | @spacecamel100 | http://www.freecodecamp.com/spacecamel100
kalmont3
@kalmont3
Mar 18 2016 00:39
I am really trying to learn about this by myself from scratch so I decided to try the exercise with the weather link but for some reason it doesnt work... can someone please guide me? \$(document).ready(function() {
\$("#getchange").on("click", function(){ \$.getJSON("api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}", function(json) {
\$(".temp").html(JSON.stringify(json));
});
});

});
Andrew Charlebois
@andrewchar
Mar 18 2016 00:46
@kalmont3 not 100% but dont you need to do something with lat={lat}&lon={lon}
@kalmont3 your not giving it any coordinates
kalmont3
@kalmont3
Mar 18 2016 00:46
alright
Moisés Man
@moigithub
Mar 18 2016 00:50
@wumpafruits u could try using map + Math.max + apply
Andrew Charlebois
@andrewchar
Mar 18 2016 00:52
This message was deleted
This message was deleted
Jeff
@meankraken
Mar 18 2016 00:54

Hey guys, I'm on the challenge "Steamroller" where I have to flatten a nested array... my solution is as follows

``````var ans = [];
function steamroller(arr) {
// I'm a steamroller, baby

arr.forEach(function(item) {
if (Array.isArray(item)) {
steamroller(item);
}
else {
ans.push(item);
}
});

return ans;
}

steamroller([1, {}, [3, [[4]]]]);``````

It shows in the log that it returns the right answer, but I'm still getting all X's when I run tests... any ideas?

Greg D
@mosaic-greg
Mar 18 2016 00:58
@meankraken tried visualising it at http://www.pythontutor.com/javascript.html# ?
James Good
@TajYemaj
Mar 18 2016 00:59
Hello, I'm curious as to how I could go about adding specific elements within an array.
Andrew Charlebois
@andrewchar
Mar 18 2016 01:00
@TajYemaj did you do the basic javascript track?
James Good
@TajYemaj
Mar 18 2016 01:00
Pin-pointing say the data in [0] and [1] spots.
Yes.
Andrew Charlebois
@andrewchar
Mar 18 2016 01:01
there is one called Manipulate Arrays With push()
and others, shift, unshift, pop
James Good
@TajYemaj
Mar 18 2016 01:01
push only adds a new piece of data to the array though.
Say I have an array
with these bits of data stored within it already.
bryarcole
@bryarcole
Mar 18 2016 01:02
``````var contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["Javascript", "Gaming", "Foxes"]
}
];

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

for(var i = 0; i < contacts.length;  i++){
if(contacts[i].firstName == firstName && contacts[i].hasOwnProperty('prop')){
value = contacts[i][prop];
}

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

else if(!(contacts[i].hasOwnProperty('prop'))){
value = "No such property";
}
return value;
}

// Only change code above this line
}

// Change these values to test your function
lookUp("Sherlock", "likes");``````
James Good
@TajYemaj
Mar 18 2016 01:02
array{2, 5, 7];
Collin
@collinferry
Mar 18 2016 01:02
Anyone have a general idea of how to determine every 3-digit combination possible from an input array of more than three digits? I can't wrap my head around it.
James Good
@TajYemaj
Mar 18 2016 01:03
How could I add 2 and 5, and exclude 7, then take the result of 2 plus 5 and add that to 7.
bryarcole
@bryarcole
Mar 18 2016 01:03
It gets to the second else if statement and just assigns value without reassiging it
Marc
@wumpafruits
Mar 18 2016 01:03
I need to add a couple of #'s to one array as well
@moigithub no way to continue using .pop without using math.max?
i dont remember using math.max in our FCC lessons but lemme recheck my note
Andrew Charlebois
@andrewchar
Mar 18 2016 01:04
@TajYemaj you can target elements with indexing
Marc
@wumpafruits
Mar 18 2016 01:04
``````function largestOfFour(arr) {
// You can do this!
for (var i = 0; i < arr.length; i++) {
console.log(arr[i].sort(function(a,b){
return a-b;}).pop());
}
}
//[1, 3, 4, 5],[13, 18, 26, 27],[32, 35, 37, 39],[1, 857, 1000, 1001]
//.pop() the largest value off and store in an array
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
current code is this.
James Good
@TajYemaj
Mar 18 2016 01:05
I know my explanation probably sucks, but I'm doing this fibonacci challenge, and I have a slight idea of how to go about solving it. However, I wouldn't know how to specifically target the latter most pieces of data in an array to add them together, and then push their sum into the array.
Jeff
@meankraken
Mar 18 2016 01:06
@TajYemaj if you want to target the latter pieces, you can just do arr[length-1] and arr[length-2], something to that extent.
James Good
@TajYemaj
Mar 18 2016 01:06
There would be a for loop necessary to increment up to the sum of the two pieces of data from the array, and that step is before it's pushed into the array.
Andrew Charlebois
@andrewchar
Mar 18 2016 01:06
@TajYemaj `var arr = [2, 5, 7]` `var arr2 = arr[0] + arr[2]` gives you9 in arr2 then `arr2 = arr2 +arr[1]`
James Good
@TajYemaj
Mar 18 2016 01:06
ahh
really
Andrew Charlebois
@andrewchar
Mar 18 2016 01:06
something like that
probly could do a better way
James Good
@TajYemaj
Mar 18 2016 01:06
using -1 or -2 starts from the end of the array?
nevermind
you did say that
It's new to me though.
Andrew Charlebois
@andrewchar
Mar 18 2016 01:07
`.length-1` is the end yes
James Good
@TajYemaj
Mar 18 2016 01:07
noted.
Thank you.
thank you @meankraken and @andrewchar
CamperBot
@camperbot
Mar 18 2016 01:07
tajyemaj sends brownie points to @meankraken and @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 368 | @andrewchar | http://www.freecodecamp.com/andrewchar
:star: 308 | @meankraken | http://www.freecodecamp.com/meankraken
Julián
@Ulian
Mar 18 2016 01:09
I have a problem. I make a non-stop for bucle, now i can fixit :S
I close the tab, open a new one and it has the old code, and is still freeze :S
Harvey S
@harveysanders
Mar 18 2016 01:12
try that
Andrew Charlebois
@andrewchar
Mar 18 2016 01:12
@pitazo run=disabled put that in your url
Julián
@Ulian
Mar 18 2016 01:12
@harveysanders Thanks you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
CamperBot
@camperbot
Mar 18 2016 01:12
pitazo sends brownie points to @harveysanders :sparkles: :thumbsup: :sparkles:
:star: 381 | @harveysanders | http://www.freecodecamp.com/harveysanders
Julián
@Ulian
Mar 18 2016 01:13
@andrewchar Tanks!
CamperBot
@camperbot
Mar 18 2016 01:13
pitazo sends brownie points to @andrewchar :sparkles: :thumbsup: :sparkles:
:star: 369 | @andrewchar | http://www.freecodecamp.com/andrewchar
Julián
@Ulian
Mar 18 2016 01:13
@pitazo Thanks*
CamperBot
@camperbot
Mar 18 2016 01:13
sorry pitazo, you can't send brownie points to yourself! :sparkles: :sparkles:
Harvey S
@harveysanders
Mar 18 2016 01:13
@pitazo no problem
Julián
@Ulian
Mar 18 2016 01:13
@harveysanders For a moment I think I broke FCC :fire:
Harvey S
@harveysanders
Mar 18 2016 01:13
@pitazo haha yeah it happens
toddgithub
@toddgithub
Mar 18 2016 01:13
Not getting to 20
``````// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;

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

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

// Only change code below this line
var total = 0;
for (var i = 0; i < myArr.length; i++) {
total = myArr[i];
}``````
Andrew Charlebois
@andrewchar
Mar 18 2016 01:14
im sure most of us have put ourself in an infinite loop
Harvey S
@harveysanders
Mar 18 2016 01:14
@pitazo you use to have to restart the whole computer
@andrewchar yep!
Andrew Charlebois
@andrewchar
Mar 18 2016 01:14
@harveysanders real? haha
Harvey S
@harveysanders
Mar 18 2016 01:14
@pitazo i mean like 10 years ago
or less
Julián
@Ulian
Mar 18 2016 01:15
@harveysanders wow
kalmont3
@kalmont3
Mar 18 2016 01:15
Now I have this but I know I need to organize it... I dont know where to start

var x = document.getElementById("gotchange");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}

function showPosition(position) {
return position.coords.latitude;
}

function showPosition(position) {
return position.coords.longitude;
}

\$("#getchange").on("click", function(){ \$.getJSON("http://api.openweathermap.org/data/2.5/weather?lat="+position.coords.latitude+"&lon="+position.coords.longitude, function(json) {
\$("#gotchange").html(JSON.stringify(json));
});
});

});

Julián
@Ulian
Mar 18 2016 01:15
@harveysanders 10 years ago I was 10 years without computer ahah
Harvey S
@harveysanders
Mar 18 2016 01:15
@pitazo hah i hear you
bryarcole
@bryarcole
Mar 18 2016 01:18

@toddgithub

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

try that
@toddgithub you have to use the `+=` operator in order to add the contents of the `myArr[i]` to the `total` variable.
toddgithub
@toddgithub
Mar 18 2016 01:25
ah, thanks @bryarcole
CamperBot
@camperbot
Mar 18 2016 01:25
toddgithub sends brownie points to @bryarcole :sparkles: :thumbsup: :sparkles:
:star: 234 | @bryarcole | http://www.freecodecamp.com/bryarcole
Marc
@wumpafruits
Mar 18 2016 01:26
``````function titleCase(str) {
var newStr = str.toLowerCase().split(" ");
var capitalize = 0;
for (var i = capitalize; i < newStr.length; i++) {
console.log(newStr[i].charAt(0).toUpperCase());
}
return newStr;
}

titleCase("I'm a little tea pot");``````
I seem to have a problem with storing variables because on this one & on Finding the Largest Number in Arrays I'm close but no cigar....any help??
bryarcole
@bryarcole
Mar 18 2016 01:29
@wumpafruits what are you specifically trying to do here?
Marc
@wumpafruits
Mar 18 2016 01:31
i need to rejoin tooo
capitalize the first letter in each word
bryarcole
@bryarcole
Mar 18 2016 01:33
I see you trying to capitlize the first element of each new array you create
hmmm...
Julián
@Ulian
Mar 18 2016 01:34

I need help with "Where do I belong", my code works fine except when num is the greatest number

```function where(arr, num) {
arr.sort(function(a, b) {
return a-b;
});

var index = 0;

for(var i = 0; i < arr.length; i++) {
if(num <= arr[i]) {
arr.splice(i, 0, num);
index = i;
return index;
}
}
return index;
}```

Using ```where([2, 5, 10], 15);````doesn't work.

How I paste code? :S
´´´ásdasd´´´
``````function where(arr, num) {
arr.sort(function(a, b) {
return a-b;
});
var index = 0;
for(var i = 0; i < arr.length; i++) {
if(num <= arr[i]) {
arr.splice(i, 0, num);
index = i;
return index;
}
}
return index;
}``````
greg
@wearenotgroot
Mar 18 2016 01:38
@pitazo why not add(push method) num then sort then use indexOf :+1:
Julián
@Ulian
Mar 18 2016 01:39
Fixed.Before var index.
``````  if(num > arr[arr.length-1]) {
arr.splice(arr.length-1, 0, num);
return arr.length-1;
}``````
@wearenotgroot Thank you anyway!!
CamperBot
@camperbot
Mar 18 2016 01:39
pitazo sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 969 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
greg
@wearenotgroot
Mar 18 2016 01:40
@pitazo :)
Julián
@Ulian
Mar 18 2016 01:40
@wearenotgroot I can use push and sort because I have to return the index where I put the new number ;D
cant*
greg
@wearenotgroot
Mar 18 2016 01:41
@pitazo actually you only need to search for the index of the first instance of the number
Julián
@Ulian
Mar 18 2016 01:42
@wearenotgroot Oh :s
greg
@wearenotgroot
Mar 18 2016 01:42
@pitazo so if you have multiple value similar to num you only need to get the first one because when you sort it similar number/values will clump together
@pitazo well no wasted effort though :smile:
Julián
@Ulian
Mar 18 2016 01:43
@wearenotgroot xD
Thanks you!
greg
@wearenotgroot
Mar 18 2016 01:43
np
JackeL
@jackel27
Mar 18 2016 01:57
Streaming CSS Layouts, bootstrap, etc if interested visit https://www.twitch.tv/freecodecamp
ManBearPigg
@ManBearPigg
Mar 18 2016 02:01
``````\$scope.addTodo = function(){
\$scope.todos.push({'title':\$scope.newTodo}).charAt(0).toUpperCase() + string.slice(1);
\$scope.newTodo = ''
}``````
How can I capitalize the first letter of todos?
Andrew Charlebois
@andrewchar
Mar 18 2016 02:02
what exercise is this
the-code-less-traveled
@the-code-less-traveled
Mar 18 2016 02:02
hint Factorialize a Number
CamperBot
@camperbot
Mar 18 2016 02:02
Set a bonfire to talk about with `bonfire name`
the-code-less-traveled
@the-code-less-traveled
Mar 18 2016 02:03
bonfire name Factorialize a Number
CamperBot
@camperbot
Mar 18 2016 02:03
Sorry, can't find a bonfire called name factorialize a number. [ Check the map? ]
Andrew Charlebois
@andrewchar
Mar 18 2016 02:03
help Factorialize a Number
CamperBot
@camperbot
Mar 18 2016 02:03

# Problem Explanation:

Return the factorial of the provided integer. If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.

Factorials are often represented with the shorthand notation n!

For example: `5! = 1 * 2 * 3 * 4 * 5 = 120`

Julián
@Ulian
Mar 18 2016 02:10
Basic Algorithm Scripting FINISHED :D:D:D:D:D
Stefan Gisi
@stgisi
Mar 18 2016 02:11
@pitazo Congrats!
the-code-less-traveled
@the-code-less-traveled
Mar 18 2016 02:12
great job @pitazo !
Matt Leonard
@matty22
Mar 18 2016 02:12
Anyone have a good resource on learning how to use minimax?
Stefan Gisi
@stgisi
Mar 18 2016 02:13
@matty22 Have you seen this one? http://mostafa-samir.github.io/Tic-Tac-Toe-AI/
Julián
@Ulian
Mar 18 2016 02:14
@stgisi @the-code-less-traveled thank you!
CamperBot
@camperbot
Mar 18 2016 02:14
pitazo sends brownie points to @stgisi and @the-code-less-traveled :sparkles: :thumbsup: :sparkles:
Stefan Gisi
@stgisi
Mar 18 2016 02:14
Like I said, I haven't started yet, but I'm gonna go ahead and take a look at it... since I'll be there in like 2 more projects...
CamperBot
@camperbot
Mar 18 2016 02:14
:star: 270 | @the-code-less-traveled | http://www.freecodecamp.com/the-code-less-traveled
:star: 307 | @stgisi | http://www.freecodecamp.com/stgisi
Andrew Charlebois
@andrewchar
Mar 18 2016 02:15
help Sorted Union
CamperBot
@camperbot
Mar 18 2016 02:15

# Problem Explanation:

• The program has to return a new array of unique values from two original arrays in the order they show up. So there is not sorting required, and no duplicates.
Matt Leonard
@matty22
Mar 18 2016 02:15
@stgisi Yeah, it seems so complicated. Can it really be that much code to make my computer play tic-tac-toe?!
Also don't know how to use `this` at all
Stefan Gisi
@stgisi
Mar 18 2016 02:16
Hmmm... prolly not, I'll keep looking around though. You've gotten me interested
@matt22 Did you do the "Make a Person" algorithm?
@matty22*
I feel like that helped me understand this a little bit better than before. Finished it earlier today.
`this`*
Matt Leonard
@matty22
Mar 18 2016 02:17
I didn't do the advanced algorithms. Moved on to advanced projects so I could wrap up this front end cert by my goal date.
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 02:18
i loved algorithm
I love lamp
Stefan Gisi
@stgisi
Mar 18 2016 02:18
@matt22 I see. Check that one out though if you have time, it's not too difficult!
Again... x.x @matty22*
Kyle Morton
@kmorton1988
Mar 18 2016 02:19
``````function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);
var removed = [];
function remove(num) {
if (num !== args[1] || num !== args[2]) {
return num;
}
}
for (i = 0; i < args[0].length; i++) {
removed.push(args[0].filter(remove(args[0][i])));

}

return args;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
Can someone help me understand why "1" is trying to run as a function?
Matt Leonard
@matty22
Mar 18 2016 02:19
Ok, thanks @stgisi
Stefan Gisi
@stgisi
Mar 18 2016 02:22
@kmorton1988 I believe the problem lies in:
``````  for (i = 0; i < args[0].length; i++) {
removed.push(args.filter(remove(args[0][i])));
}``````
@kmorton1988 more specifically, the inner part of your for loop
Kyle Morton
@kmorton1988
Mar 18 2016 02:23
right
I know that's where it's coming from, I think my problem is I don't fully understand how arr.filter works.
I don't think I"m making the callback funciton correctly
is it supposed to return "True" and "false"?
or...
cause it's properly returning a 1 like I wanted it to, but then it looks like it's trying to run the "1" as a funciton.
when it obviously isn't
Stefan Gisi
@stgisi
Mar 18 2016 02:25
@kmorton1988 Hold on, let me look at how I completed this one
Kyle Morton
@kmorton1988
Mar 18 2016 02:25
thx
Stefan Gisi
@stgisi
Mar 18 2016 02:25
and compare
no prob
Kyle Morton
@kmorton1988
Mar 18 2016 02:25
tell me if I'm close, or waaaay far off.
I don't want the answer, I just wanna understand what I"m doing wrong
Stefan Gisi
@stgisi
Mar 18 2016 02:25
hahaha, gotcha
rhythmicjump
@rhythmicjump
Mar 18 2016 02:25
So, can anyone help me? I know i'm in the super early stages of the js, but I just can't get it to work. I'm working on the record collection challenge. It says it cannot create property "artist" on number "5439", except that's exactly what it is supposed to do, or am I misunderstanding?
Kyle Morton
@kmorton1988
Mar 18 2016 02:26
I think it's supposed to assign a value TO The property called "artist". not assign the property called artis.
rhythmicjump
@rhythmicjump
Mar 18 2016 02:26
But the property doesn't exist in that particular array.
Kyle Morton
@kmorton1988
Mar 18 2016 02:27
is it `"artist": ""`
Stefan Gisi
@stgisi
Mar 18 2016 02:27
Ok... I just used `splice` in my loop...
rhythmicjump
@rhythmicjump
Mar 18 2016 02:27
Nope it's 5439:{ album: "ABBA Gold"}
Kyle Morton
@kmorton1988
Mar 18 2016 02:27
splice.
Andrew Charlebois
@andrewchar
Mar 18 2016 02:28
@kmorton1988 filter creates a new array with its elements that pass the test
Kyle Morton
@kmorton1988
Mar 18 2016 02:28
@andrewchar yeah, but what is the callback supposed to return?
true?
Andrew Charlebois
@andrewchar
Mar 18 2016 02:28
true or false
Kyle Morton
@kmorton1988
Mar 18 2016 02:28
that's my problem then
psh
now I'm getting "True is not a function" lol.
be back in a bit, gonna shower and change into something more comfy, then I'll be back in like, 10 minutes
Josh Bivens
@joshbivens
Mar 18 2016 02:32
Anyone done "Sum All Numbers in a Range"?
Shian Poon
@shian3n
Mar 18 2016 02:34
``````  var monkeyArr=[];
for(var i=0;i<arr.length/size;i++)
{
for(var j=0;j<size;j++)
{
monkeyArr[i][j].push(arr[j]);
}
}``````

TypeError: Cannot reaed property '0' of undefined

What causes this error?

Josh Bivens
@joshbivens
Mar 18 2016 02:36
@shian3n Does it say what line is messing up?
Shian Poon
@shian3n
Mar 18 2016 02:37
@joshbivens No, it didn't. But i guess the error comes in the Array declaration line.
It seems that multidimensional array can't be created this way
Josh Bivens
@joshbivens
Mar 18 2016 02:38
@shian3n Which challenge is it?
Shian Poon
@shian3n
Mar 18 2016 02:39
@joshbivens Chunky Monkey :)
Josh Bivens
@joshbivens
Mar 18 2016 02:39
@shian3n Let me look...
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 02:39
I just got to chunky monkey
rhythmicjump
@rhythmicjump
Mar 18 2016 02:40
This message was deleted
Andrew Charlebois
@andrewchar
Mar 18 2016 02:41
@shian3n why are you using two loops
Kyle Morton
@kmorton1988
Mar 18 2016 02:41
ok I'm back in action.
Andrew Charlebois
@andrewchar
Mar 18 2016 02:41
@shian3n what is size?
Shian Poon
@shian3n
Mar 18 2016 02:42
@andrewchar To assign character inside input Array into multidimensional array based on the number
Andrew Charlebois
@andrewchar
Mar 18 2016 02:42
@shian3n posting your full code will help
Josh Bivens
@joshbivens
Mar 18 2016 02:42
@shian3n Ah. You don't need two loops.
It's all about the `slice`
Shian Poon
@shian3n
Mar 18 2016 02:42
``````function chunk(arr, size) {
// Break it up.
var monkeyArr= new Array();
for(var i=0;i<arr.length/size;i++)
{
monkeyArr[i]= new Array();
for(var j=0;j<size;j++)
{
monkeyArr[i][j]=arr[i+j];
}
}
return monkeyArr;
}

chunk(["a", "b", "c", "d"], 2);``````
Andrew Charlebois
@andrewchar
Mar 18 2016 02:43
@shian3n your not actually looping size
@shian3n its not in an array either
Shian Poon
@shian3n
Mar 18 2016 02:44
@andrewchar @joshbivens Thank you, imma try again :)
CamperBot
@camperbot
Mar 18 2016 02:44
shian3n sends brownie points to @andrewchar and @joshbivens :sparkles: :thumbsup: :sparkles:
Andrew Charlebois
@andrewchar
Mar 18 2016 02:44
@shian3n not sure exactly what the new array() thing does, makes new instances or something right? but you dont need to do that
CamperBot
@camperbot
Mar 18 2016 02:44
:star: 321 | @joshbivens | http://www.freecodecamp.com/joshbivens
:star: 370 | @andrewchar | http://www.freecodecamp.com/andrewchar
Josh Bivens
@joshbivens
Mar 18 2016 02:44
@shian3n `size` is the length of the subarrays you're pushing to your array.
Shian Poon
@shian3n
Mar 18 2016 02:45
@joshbivens So I should slice based on size, and then push it into a multidimensional array right
Andrew Charlebois
@andrewchar
Mar 18 2016 02:45
@shian3n `i<arr.length/size` i think your trying to divide here?
Josh Bivens
@joshbivens
Mar 18 2016 02:46
@shian3n Well, you'll create a multidimensional array by pushing arrays onto an array.
Look at what the tests expect @shian3n
Shian Poon
@shian3n
Mar 18 2016 02:47
@joshbivens @andrewchar Lemme reset and code again hahaha
Josh Bivens
@joshbivens
Mar 18 2016 02:52
@shian3n Good luck! ;)
@shian3n Remember, `slice`!
rhythmicjump
@rhythmicjump
Mar 18 2016 02:55
Oh, kmorton, I am starting to figure it out. I wasn't formatting it correctly or using an object lookup. I'm 3/4 done now.
I went back and saw what my mistake.
also known as kmorton1988
Kyle Morton
@kmorton1988
Mar 18 2016 02:56
awesome!
use the @ to mention people lol.
rhythmicjump
@rhythmicjump
Mar 18 2016 02:56
that's what I was missing.
And done with it! :D
Kyle Morton
@kmorton1988
Mar 18 2016 02:56
YES! does it work?
rhythmicjump
@rhythmicjump
Mar 18 2016 02:57
Yup!
Kyle Morton
@kmorton1988
Mar 18 2016 02:57
congrats :) That was a tough one for me.
rhythmicjump
@rhythmicjump
Mar 18 2016 02:57
I was doing lookups like this 'collection[id[prop]] = value;' for some reason
Shian Poon
@shian3n
Mar 18 2016 02:58

@joshbivens

``````function chunk(arr, size) {
// Break it up.
var monkeyArr =[];
var i=0;
while(i<arr.length){
monkeyArr.push(arr.slice(i,i+=size));
}

return monkeyArr;
}

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

Thanks I did it ! :)

CamperBot
@camperbot
Mar 18 2016 02:58
shian3n sends brownie points to @joshbivens :sparkles: :thumbsup: :sparkles:
:warning: shian3n already gave joshbivens points
Josh Bivens
@joshbivens
Mar 18 2016 02:59
@shian3n Nice!
rhythmicjump
@rhythmicjump
Mar 18 2016 02:59
Geez, so I apparently can't do the code stuff... omg, I just figured that out too... figured out it is `collection[id[prop]] = value;` instead of `collection[id][prop] = value;`
omg, I'm just going to stop talking now.
switch that ^
Kyle Morton
@kmorton1988
Mar 18 2016 02:59
hahahahahahahahaha.
wow. so simplistc.
finally beat seek and destroy
and I'm kicking myself for the stupidly complex methods I was using earlier to attempt it.
Andrew Charlebois
@andrewchar
Mar 18 2016 03:00
no more loops?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:00
It's weird how easy some of the stuff can be if you don't psych yourself out.
Kyle Morton
@kmorton1988
Mar 18 2016 03:01
@andrewchar nope lol.
loop wasn't needed.
Andrew Charlebois
@andrewchar
Mar 18 2016 03:01
good stuff
Kyle Morton
@kmorton1988
Mar 18 2016 03:01
after I understood that filter automatically goes through an array, it helped me figure that part out
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:01
Did anyone have issues with exercise "Use Conditional Logic with If Statements"
Andrew Charlebois
@andrewchar
Mar 18 2016 03:02
Kyle Morton
@kmorton1988
Mar 18 2016 03:02
@andrewchar do you know if there's a way to solve seek and destroy without a hard-coded third args variable?
prestonk25
@prestonk25
Mar 18 2016 03:03
``````// Setup
var number = "Montana";
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = testObj[number];       // Change this Line
var player = testObj[16];   // Change this Line``````

playerNumber should be a number

I can not get ^^^ to work. Any help please?

Andrew Charlebois
@andrewchar
Mar 18 2016 03:03
@kmorton1988 not sure
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:04
how do i add a snippet? or a screen shot like that?
Kyle Morton
@kmorton1988
Mar 18 2016 03:04
@donghoonkim1226 ```js, hit enter, paste code, then hit ctrl enter
rhythmicjump
@rhythmicjump
Mar 18 2016 03:04
@prestonk25 put a number for playerNumber
Andrew Charlebois
@andrewchar
Mar 18 2016 03:04
help format
CamperBot
@camperbot
Mar 18 2016 03:04

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

rhythmicjump
@rhythmicjump
Mar 18 2016 03:04
You somewhat have it backward @prestonk25
Kyle Morton
@kmorton1988
Mar 18 2016 03:04
then use playerNumber as the testObj index
help seek and destroy
CamperBot
@camperbot
Mar 18 2016 03:05

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

prestonk25
@prestonk25
Mar 18 2016 03:05
@rhythmicjump I have to use bracket notation to access testObj though, so that doesnt work
rhythmicjump
@rhythmicjump
Mar 18 2016 03:05
correct.
Your playerNumber variable is just a variable
Andrew Charlebois
@andrewchar
Mar 18 2016 03:06
@kmorton1988 is my solution.
``````function destroyer(arr) {
var args = Array.prototype.slice.call(arguments);

function xyz(value) {
return args.indexOf(value) == -1;
}

return arr.filter(xyz);

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
rhythmicjump
@rhythmicjump
Mar 18 2016 03:06
then do bracket with the second @prestonk25
Andrew Charlebois
@andrewchar
Mar 18 2016 03:06
@kmorton1988 not sure what hard coded arg means
Stefan Gisi
@stgisi
Mar 18 2016 03:06
@kmorton1988 Got it!
Kyle Morton
@kmorton1988
Mar 18 2016 03:07
@stgisi awesome!
Josh Bivens
@joshbivens
Mar 18 2016 03:07
`arguments` you mean @andrewchar ?
Stefan Gisi
@stgisi
Mar 18 2016 03:07
@kmorton1988 This is my first time really using filter, so took me a while
``````function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);

var removed = "";
console.log(args[1]);
function remove(arr) {
return arr.filter(function(x) {
return x != args[1] && x!= args[2];
});
}
return remove(args[0]);

}``````
Kyle Morton
@kmorton1988
Mar 18 2016 03:07
yeah, filter is confusing.
rhythmicjump
@rhythmicjump
Mar 18 2016 03:07
@prestonk25 , PM me if you need some more help, but you got this, man.
Stefan Gisi
@stgisi
Mar 18 2016 03:07
@kmorton1988 You might wanna clean that up though
Kyle Morton
@kmorton1988
Mar 18 2016 03:07
?
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:07
``````// Setup
function myFunction() {

// Only change code below this line.
if (true) {
return "That was true";
} else {
return "That was false";
}

// Only change code above this line.

}

// Change this value to test
myFunction(false);``````
Stefan Gisi
@stgisi
Mar 18 2016 03:07
i mean, i left some console.logs in there and stuff
prestonk25
@prestonk25
Mar 18 2016 03:08
``````// Setup
var number = "Montana";
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};

// Only change code below this line;

var playerNumber = [12];       // Change this Line
var player = testObj[16];   // Change this Line``````

playerNumber should be a number
The variable player should be a string
The value of player should be "Montana"
You should use bracket notation to access testObj

@rhythmicjump those are all the requirements.

Josh Bivens
@joshbivens
Mar 18 2016 03:08
@donghoonkim1226 What's this?
Kyle Morton
@kmorton1988
Mar 18 2016 03:08
here's mine @stgisi @andrewchar
``````function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments);
function remove(num) {
return num !== args[1] && num !== args[2] && num !== args[3];

}

return args[0].filter(remove);
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:08
based on my code structure, when passing false it should return "That was false"
rhythmicjump
@rhythmicjump
Mar 18 2016 03:08
Oh, @prestonk25 , you're so close, now change the player variable
Kyle Morton
@kmorton1988
Mar 18 2016 03:08
wouldn't work with a larger number of arguments to compare against.
Josh Bivens
@joshbivens
Mar 18 2016 03:08
@stgisi You don't really need that function inside your function
rhythmicjump
@rhythmicjump
Mar 18 2016 03:09
@prestonk25 use bracket notation on the second variable
Stefan Gisi
@stgisi
Mar 18 2016 03:09
@joshbivens I see!
prestonk25
@prestonk25
Mar 18 2016 03:09
@rhythmicjump To what? I can get that one to work but not the playerNumber one
Stefan Gisi
@stgisi
Mar 18 2016 03:09
@joshbivens Wasting space...
Andrew Charlebois
@andrewchar
Mar 18 2016 03:09
@kmorton1988 think i see what you mean with hard coded args. i guess my solution it doesnt matter how many there are>?
Kyle Morton
@kmorton1988
Mar 18 2016 03:09
yeah, that's probably the preferred method of coding it.
it's just.
rhythmicjump
@rhythmicjump
Mar 18 2016 03:09
@prestonk25 what playerNumber are you looking for?
Josh Bivens
@joshbivens
Mar 18 2016 03:09
@stgisi ;)
greg
@wearenotgroot
Mar 18 2016 03:09
@prestonk25 playerNumber should equal to 16
Kyle Morton
@kmorton1988
Mar 18 2016 03:09
I didn't understand what I was looking at when I first saw your solution (after finding mine)
greg
@wearenotgroot
Mar 18 2016 03:09
@prestonk25 as the instruction stated
prestonk25
@prestonk25
Mar 18 2016 03:10
it says "playerNumber should be a number" and that "You should use bracket notation to access testObj"
rhythmicjump
@rhythmicjump
Mar 18 2016 03:10
exactly.
Stefan Gisi
@stgisi
Mar 18 2016 03:10
@kmorton1988 I originally just used splice, not filter, I just wanted to see if I could try to complete it with your code!
rhythmicjump
@rhythmicjump
Mar 18 2016 03:10
so ```
var playerNumber = 16;
Kyle Morton
@kmorton1988
Mar 18 2016 03:10
haha, thanks @stgisi
CamperBot
@camperbot
Mar 18 2016 03:10
kmorton1988 sends brownie points to @stgisi :sparkles: :thumbsup: :sparkles:
greg
@wearenotgroot
Mar 18 2016 03:10
@prestonk25 then use playerNumber as a key to get a value, in this instance 'Montana'
CamperBot
@camperbot
Mar 18 2016 03:10
:star: 308 | @stgisi | http://www.freecodecamp.com/stgisi
prestonk25
@prestonk25
Mar 18 2016 03:10
@wearenotgroot setting it = [16] does not wor
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:10

Can anyone explain why myFunction(false) is not returning "That was false"?

`````````
// Setup
function myFunction() {

// Only change code below this line.
if (true) {
return "That was true";
} else {
return "That was false";
}

// Only change code above this line.

}

// Change this value to test
myFunction(false);``````

```

Stefan Gisi
@stgisi
Mar 18 2016 03:10
``````function destroyer(arr) {
var args = arguments.length - 1;
while (args > 0) {
while (arguments[0].indexOf(arguments[args]) !== -1) {
arr.splice(arguments[0].indexOf(arguments[args]),1);
}
args--;
}
return arr;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);``````
greg
@wearenotgroot
Mar 18 2016 03:10
@prestonk25 var playerNumber = 16;
Andrew Charlebois
@andrewchar
Mar 18 2016 03:11
@kmorton1988 ahh. yeah i just read on mdn and noticed indexOf returns numbers if something is there or not so if it wasnt it gives -1
prestonk25
@prestonk25
Mar 18 2016 03:11
@wearenotgroot but that doesnt satisfy the condition of only using bracket notation
Kyle Morton
@kmorton1988
Mar 18 2016 03:11
@donghoonkim1226 your function, how its written ALWAYS returns true cause you've hard-coded it to use "true"
greg
@wearenotgroot
Mar 18 2016 03:11
@prestonk25 then use as a key in `testObject[playerNumber];`
Stefan Gisi
@stgisi
Mar 18 2016 03:11
@kmorton1988 Thank you too! my fist time working with someone else like this
CamperBot
@camperbot
Mar 18 2016 03:11
stgisi sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
rhythmicjump
@rhythmicjump
Mar 18 2016 03:11
@prestonk25 var player = testObj[?];
Kyle Morton
@kmorton1988
Mar 18 2016 03:11
@donghoonkim1226 you should make your funciton take a variable and then pass that variable to the if-statement
CamperBot
@camperbot
Mar 18 2016 03:11
:star: 282 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Kyle Morton
@kmorton1988
Mar 18 2016 03:11
haha, no problem. Glad to have helped @stgisi
glad my code is at least somewhat tangible lol.
donghoonkim1226
@donghoonkim1226
Mar 18 2016 03:12
@kmorton1988 - ahh, i will try that, thanks!
CamperBot
@camperbot
Mar 18 2016 03:12
donghoonkim1226 sends brownie points to @kmorton1988 :sparkles: :thumbsup: :sparkles:
prestonk25
@prestonk25
Mar 18 2016 03:12
@rhythmicjump what do you mean?
CamperBot
@camperbot
Mar 18 2016 03:12
:star: 283 | @kmorton1988 | http://www.freecodecamp.com/kmorton1988
Kyle Morton
@kmorton1988
Mar 18 2016 03:12
welcome @donghoonkim1226
Stefan Gisi
@stgisi
Mar 18 2016 03:12
@kmorton1988 Definitely got some practice in with filter now! Which is good
Kyle Morton
@kmorton1988
Mar 18 2016 03:12
yeah, for sure.
I didn't realize what filter was doing.
Stefan Gisi
@stgisi
Mar 18 2016 03:13
help rules
CamperBot
@camperbot
Mar 18 2016 03:13
no wiki entry for: `rules`
Stefan Gisi
@stgisi
Mar 18 2016 03:13
rules
rhythmicjump
@rhythmicjump
Mar 18 2016 03:13
You usually use bracket notation to put a variable in there so `var player = testObj[???];` What would you put in place of ??? if you already have a variable with a number in it?
greg
@wearenotgroot
Mar 18 2016 03:13
@prestonk25
``````var playerNumber = 16;       //<--------------change/set playerNumber value to 16
var player = testObj[playerNumber]; //<-------------------use playerNumber as key``````
Stefan Gisi
@stgisi
Mar 18 2016 03:13
Is it against the rules to use foreign languages here?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:13
Depends on what foreign language. Haha
Stefan Gisi
@stgisi
Mar 18 2016 03:13
@rhythmicjump -_-;;
prestonk25
@prestonk25
Mar 18 2016 03:14
@wearenotgroot THANK YOU SO MUCH!!
CamperBot
@camperbot
Mar 18 2016 03:14
prestonk25 sends brownie points to @wearenotgroot :sparkles: :thumbsup: :sparkles:
:star: 972 | @wearenotgroot | http://www.freecodecamp.com/wearenotgroot
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:14
what is a "two dimensional array"
greg
@wearenotgroot
Mar 18 2016 03:14
@prestonk25 np :)
Kyle Morton
@kmorton1988
Mar 18 2016 03:14
a nested array?
Andrew Charlebois
@andrewchar
Mar 18 2016 03:14
@Jordanmeyer89 an array within an array
Stefan Gisi
@stgisi
Mar 18 2016 03:14
@Jordanmeyer89 [[1,2],[3,4]]
Kyle Morton
@kmorton1988
Mar 18 2016 03:14
or maybe a key/value paired array, which is actually anobject?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:14
@prestonk25 Sorry for being so vague with my answer, I just didn't want to give you the answer...
Stefan Gisi
@stgisi
Mar 18 2016 03:14
`[[1,2],[3,4]]`
greg
@wearenotgroot
Mar 18 2016 03:14
@Jordanmeyer89 arrayception :smile:
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:14
ah okay thank you @andrewchar @stgisi
CamperBot
@camperbot
Mar 18 2016 03:14
jordanmeyer89 sends brownie points to @andrewchar and @stgisi :sparkles: :thumbsup: :sparkles:
:star: 371 | @andrewchar | http://www.freecodecamp.com/andrewchar
:star: 309 | @stgisi | http://www.freecodecamp.com/stgisi
rhythmicjump
@rhythmicjump
Mar 18 2016 03:17
@stgisi Also, I was just kidding, I am curious, however, what language you speak.
Stefan Gisi
@stgisi
Mar 18 2016 03:18
@rhythmicjump I saw that @donghoonkim1226 was Korean so I was gonna try talking to him
rhythmicjump
@rhythmicjump
Mar 18 2016 03:18
Ah, that's cool.
I know quite a few people who speak Korean.
Stefan Gisi
@stgisi
Mar 18 2016 03:19
Yeah, combine programming and foreign language study to cause my brain to explode.
rhythmicjump
@rhythmicjump
Mar 18 2016 03:19
Where are you studying?
Stefan Gisi
@stgisi
Mar 18 2016 03:19
No where right now, just self-study!
rhythmicjump
@rhythmicjump
Mar 18 2016 03:19
I speak Persian-Farsi and Persian-Dari myself.
That's why I am so interested.
Stefan Gisi
@stgisi
Mar 18 2016 03:20
Awesome, did you learn? Or have you spoken since you were young?
Or.... does the acronym DLI mean anything to you?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:21
second one.
or... I guess third one, didn't see the "did you learn?" @stgisi
Stefan Gisi
@stgisi
Mar 18 2016 03:23
@rhythmicjump Gotcha, I was a DLI bypass
@rhythmicjump Wish I coulda gone though
@MisterMan123
Mar 18 2016 03:23
Is there something wrong with the Make a Person bonfire? Every test is passing except the Haskell Ross one, and it looks like an actual error in the test ccases
rhythmicjump
@rhythmicjump
Mar 18 2016 03:23
For what?
are you ANG?
in HI?
Stefan Gisi
@stgisi
Mar 18 2016 03:24
@MisterMan123 I did that one today, I had the same problem
@MisterMan123 After messing around for a while, I got it
@MisterMan123
Mar 18 2016 03:24
How?
Stefan Gisi
@stgisi
Mar 18 2016 03:24
@rhythmicjump No, I'm ex-RA I was a KORLING
@MisterMan123 Hold on a sec
@MisterMan123 Do you want to look at my code?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:25
@stgisi That's cool, definitely a cool language imo.
Stefan Gisi
@stgisi
Mar 18 2016 03:26
@rhythmicjump It is! I had lots of fun when I was in SK, working with the ROKs
rhythmicjump
@rhythmicjump
Mar 18 2016 03:26
Oh, so you got to have a lot more fun than normal people do.
Stefan Gisi
@stgisi
Mar 18 2016 03:26
I was spoiled hahaha
rhythmicjump
@rhythmicjump
Mar 18 2016 03:27
Didn't get stuck in MD did you?
@MisterMan123
Mar 18 2016 03:27
@stgisi Yeah, that would be helpful. I honestly don't know where to go from here lol
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:27
I know some spanish
thats an interesting language
rhythmicjump
@rhythmicjump
Mar 18 2016 03:27
haha! Eso si que es.
Stefan Gisi
@stgisi
Mar 18 2016 03:27
@MisterMan123 How about you show me your code? And then I can point you in the right direction
@MisterMan123
Mar 18 2016 03:27
sure sure
Stefan Gisi
@stgisi
Mar 18 2016 03:28
@rhythmicjump MD?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:28
@MisterMan123
Mar 18 2016 03:28
``````var Person = function(firstAndLast) {
this.setFullName = function(firstAndLast) {
var nameArr = firstAndLast.split(' ');
Person.prototype.first = nameArr[0];
Person.prototype.last = nameArr[1];
};

this.setFirstName = function(newfirst) {
Person.prototype.first = newfirst;
};

this.setLastName = function(newlast) {
Person.prototype.last = newlast;
};

this.getFirstName = function() {
return Person.prototype.first;
};

this.getLastName = function() {
return Person.prototype.last;
};
this.getFullName = function() {
return Person.prototype.first + " " + Person.prototype.last;
};
this.setFullName(firstAndLast);
};

var bob = new Person('Bob Ross');
Stefan Gisi
@stgisi
Mar 18 2016 03:28
@rhythmicjump I was only ever OCONUS
rhythmicjump
@rhythmicjump
Mar 18 2016 03:28
Oh, that's extra lucky.
@MisterMan123
Mar 18 2016 03:28
I'd also like to point out I fixed a typo in one of the functions and now I have two different failed tests
Stefan Gisi
@stgisi
Mar 18 2016 03:29
@MisterMan123 Okay, one moment sir
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:29
why would I use .splice in slasher instead of just ```function slasher(arr, howMany) { // it doesn't always pay to be first for (var i=0; i < howMany; i++){ arr.shift(); } return arr; }```
this was way easier
@MisterMan123
Mar 18 2016 03:30
@stgsi I just got it
@stgsi I replaced the test I had in the code currently with `bob.getFirstName();` and it just worked
@kfowers17
Mar 18 2016 03:31
```````
delete collection[id][prop];
```
Anybody know why this code only works if prop refers to an object property that holds an array? If i use it on a property that holds a string it only deletes the value.
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:31
same thing i guess
weird stuff
can you link wole code @kfowers17
Stefan Gisi
@stgisi
Mar 18 2016 03:32
@MisterMan123 Anytime I made changes to the name (first, full, or last) I always changed a global variable, one that was outside of all the properties... for example
``````var Person = function(firstAndLast) {
var arr = firstAndLast.split(" ");
var first = arr[0];
var last = arr[1];``````
@kfowers17
Mar 18 2016 03:33
``````var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

return collection;
}``````
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:33
I am working on record collection. I am having a hard time getting started. I know I need to set ID to the number before each function
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:33
When I did it, I think I made it an if inside an iff instead of using ||
Actually one sec
samamsam
@samsamam
Mar 18 2016 03:35
Hi Coders I am having problem with this code it does not satisfy one of the conditions please take a look thanks
``````// Setup
var myObj = {
pet: "kitten",
bed: "sleigh"
};

function checkObj(checkProp)
{

if((myObj.hasOwnProperty(checkProp)) === true)
{
return (myObj[property]);
}
else
{
}
}

// Test your code by modifying these values
checkObj("pet");``````
Stefan Gisi
@stgisi
Mar 18 2016 03:35
@MisterMan123 And then with the setName property/functions I would change the global variable so that way if any of the displayName functions were run after, the updated name would be displayed
samamsam
@samsamam
Mar 18 2016 03:35
Its from Testing Objects for Properties
Michael Aubrey
@mca62511
Mar 18 2016 03:35

hey, I was looking at some javascript I copy/pasted/modified back before I really learned anything about javascript, and noticed that I was doing

``````var doTheThing = function() {
console.log("Consider it done.");
}

doTheThing();``````

as a way to create functions... which now having learned about JavaScript from FCC seems really weird. Is there any case where you'd want to do it this way?

greg
@wearenotgroot
Mar 18 2016 03:36
@mca62511 if you create an object, example a person object
Stefan Gisi
@stgisi
Mar 18 2016 03:38
@dylanneil Hey Dylan, are you still having a hard time?
greg
@wearenotgroot
Mar 18 2016 03:38
@mca62511 function you want to expose to the outside usually is stored in some variable
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:38
@stgisi yes!
Stefan Gisi
@stgisi
Mar 18 2016 03:39
@DylanNEil Okay, you'll have to write a few lines to fulfill all the test requirements for the challenge
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:39
okay
@stgisi I'm going to try something, even if it's off, just to have a place to start.
Stefan Gisi
@stgisi
Mar 18 2016 03:40
@DylanNeil So, the basic format for the lines you need to write is `collection[####].key = "SOMETHING";`
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:40
okay
@stgisi okay
Michael Aubrey
@mca62511
Mar 18 2016 03:41
@samsamam You haven't defined the variable `property`.
Stefan Gisi
@stgisi
Mar 18 2016 03:41
@DylanNeil Try it out and see if you can get it from there
Michael Aubrey
@mca62511
Mar 18 2016 03:41
@samsamam I think you meant to make that `checkProp` instead of `property` anyway. Just changing that will make your code word, I think.
@samsamam
``````    if((myObj.hasOwnProperty(checkProp)) === true)
{
return (myObj[checkProp]);
}``````
@wearenotgroot Thanks, though I can't say I totally understand. I guess I will once I learn more.
samamsam
@samsamam
Mar 18 2016 03:43
oh it works thanks @mca62511
CamperBot
@camperbot
Mar 18 2016 03:43
samsamam sends brownie points to @mca62511 :sparkles: :thumbsup: :sparkles:
:star: 389 | @mca62511 | http://www.freecodecamp.com/mca62511
Stefan Gisi
@stgisi
Mar 18 2016 03:43
@DylanNeil Actually, `collection[####][PROP] = VALUE` might be better >_>
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:45
@stgisi dumb question, should the brackets where you put #### be blank?
rhythmicjump
@rhythmicjump
Mar 18 2016 03:46
no @DylanNeil
@DylanNeil Not a dumb question
If it helps you learn, that's what matters.
Think about your three inputs, which one of those three would make most sense in there? @DylanNeil
greg
@wearenotgroot
Mar 18 2016 03:47
@mca62511 you'll get it later, another use is, if you want to change the behaviour of a given function later then you can assign it to a variable
Michael Aubrey
@mca62511
Mar 18 2016 03:48
@wearenotgroot That makes sense.
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:50
@rhythmicjump id!
okay
thanks
rhythmicjump
@rhythmicjump
Mar 18 2016 03:51
np
Andrew Charlebois
@andrewchar
Mar 18 2016 03:52
anyone here able to answer a question about sorted union, the algorithm
@kfowers17
Mar 18 2016 03:52
i'm also working on Record Collection. Having trouble with this line of code trying to add a value to the end of the array
`collection[id].tracks.push(value);`
I get this error: collection[id].tracks.push is not a function.
rhythmicjump
@rhythmicjump
Mar 18 2016 03:52
@kfowers17 that is in the ` if ( prop === "tracks" && value !== "") {
Michael Aubrey
@mca62511
Mar 18 2016 03:52
without looking at it, sounds like tracks isn't an array
rhythmicjump
@rhythmicjump
Mar 18 2016 03:53
correcti?
yea, try `collection[id][prop].push(value);` @kfowers17
@kfowers17
Mar 18 2016 03:53
@mca62511 tracks is an array, but it is empty
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:54
Yes, I started with collection[id][prop]=[value];
rhythmicjump
@rhythmicjump
Mar 18 2016 03:54
Since it's in that `else if` statement, you just put prop not `.tracks.push(value);`.
Also, Dylan, take the array off of value
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:55
Which, alone, satisfied this: After update(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.
@rhythmicjump
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:55
what if our browser is hung up
just says testing challenge
for like 5 mins
rhythmicjump
@rhythmicjump
Mar 18 2016 03:55
JackeL
@jackel27
Mar 18 2016 03:55
bonfire reverse a string
CamperBot
@camperbot
Mar 18 2016 03:55

## :fire:Bonfire: Reverse a String :link:

``````function reverseString(str) {
return str;
}

reverseString('hello');``````

Reverse the provided string.

more info:  `bf details` | `bf links` | `hint`

Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:56
``````function mutation(arr) {
arr.slice(" ");
var word1 = arr[0].toLowerCase;
var word2 = arr[1].toLowerCase;

return word2;

//word1.indexOf(word2);

}
mutation(["hello", "hey"]);``````
i was just checking to make sure word2 was a string
JackeL
@jackel27
Mar 18 2016 03:57
just checking a few thing sout
rhythmicjump
@rhythmicjump
Mar 18 2016 03:57
@stgisi Might be able to help you more, @Jordanmeyer89 I was asking @DylanNeil to paste his code.
Sorry, not that far, @Jordanmeyer89
Jordan Meyer
@Jordanmeyer89
Mar 18 2016 03:57
ah sorry lol
BRlau
@BRlau
Mar 18 2016 03:57
Escape Sequences in Strings
Instructions
Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:57

function update(id, prop, value) {

collection[id][prop]=[value];

return collection;
}

@stgisi
this is all I have so far
Stefan Gisi
@stgisi
Mar 18 2016 03:58
@DylanNeil HAhaha, now that i look back at my record collection challenge code... I just did everything manually, no ifs or anything
greg
@wearenotgroot
Mar 18 2016 03:58
@BRlau literally put then between '' or "" and make a string
@BRlau example '\t \r' <-------------------
Andrew Charlebois
@andrewchar
Mar 18 2016 03:59
question about looping... how am i suppose to loop multiple arguments like this one `function unite(arr1, arr2, arr3)` with one loop? also, the amount of arguments are different as well.
Dylan Pagillo
@DylanNeil
Mar 18 2016 03:59
@stgisi haha, can I see it?
Stefan Gisi
@stgisi
Mar 18 2016 03:59
@DylanNeil Sure
``````function update(id, prop, value) {
collection["5439"].artist = "ABBA";
delete collection["2548"].artist;
delete collection["2548"].tracks;
return collection;
}``````
@DylanNeil But I'm actually gonna go back and do it with a couple if statements now...
greg
@wearenotgroot
Mar 18 2016 04:01
Dylan Pagillo
@DylanNeil
Mar 18 2016 04:01
@stgisi This defeats the purpose of update
Andrew Charlebois
@andrewchar
Mar 18 2016 04:01
i am on the page
Stefan Gisi
@stgisi
Mar 18 2016 04:02
@DulanNeil shrug It didn't say it wasn't "one-time"update
Dylan Pagillo
@DylanNeil
Mar 18 2016 04:03
@stgisi haha
rhythmicjump
@rhythmicjump
Mar 18 2016 04:03
``````function update(id, prop, value) {

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

return collection;
}``````
@DylanNeil
use if statements.
greg
@wearenotgroot
Mar 18 2016 04:05
@andrewchar you mainly need two for loops (if you want for to use for loop, you can alsoe use reduce and filters)
Andrew Charlebois
@andrewchar
Mar 18 2016 04:06
@wearenotgroot yeah i coded it so it passed the first two tests but just realized that the last two tests have different number of arguments
so im figuring out how to do it with random number of arguments
greg
@wearenotgroot
Mar 18 2016 04:06
@andrewchar what you do is every ith argument in arguments object of the function, put it in a temp variable then loop through the value and check with indexOf if it already exist
Andrew Charlebois
@andrewchar
Mar 18 2016 04:07
```for (var i = 0; i < bar.length; i++) { if (foo.indexOf(bar[i]) === -1) { foo.push(bar[i]); }```
is what i started by doing
just need to deal with the argument thing now
i think maybe `var args = Array.prototype.slice.call(arguments);` will solve problem
we shall see
greg
@wearenotgroot
Mar 18 2016 04:08
@andrewchar something like
``````finalarray
for loop
var temp = arguments[i];
for loop     //loop through temp
if  check if the value exist in the final array using indexOf, if index < 0 from result of .indexOf
//push value in finalarray
end if
end loop

end loop``````
joyam09
@joyam09
Mar 18 2016 04:10
how do i encode escape sequences in strings Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr
Dylan Pagillo
@DylanNeil
Mar 18 2016 04:10
@rhythmicjump I'm looking at your code and trying to analyze it
rhythmicjump
@rhythmicjump
Mar 18 2016 04:11
help record collection
CamperBot
@camperbot
Mar 18 2016 04:11

# Checkpoint: Record Collection

Instructions

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

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

For the given id in collection:

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

If the prop is "tracks" and value is non-blank, push the value onto the end of the tracks array.

If value is blank, delete that prop.

Always return the entire collection object.

Dylan Pagillo
@DylanNeil
Mar 18 2016 04:14
@rhythmicjump So if value is not blank, and property is not tracks then the prop of the given id will be equal to the given value
@rhythmicjump so if the property is artist or album then the given value in Update will be placed there
rhythmicjump
@rhythmicjump
Mar 18 2016 04:16
correct
Trust me, that thing took me three days, I just finished it today.
@DylanNeil
Andrew Charlebois
@andrewchar
Mar 18 2016 04:19
@wearenotgroot ty for help :)
greg
@wearenotgroot
Mar 18 2016 04:19
@andrewchar np
Andrew Charlebois
@andrewchar
Mar 18 2016 04:20
i knew how i had to do it but didnt know how i would loop the arguments
i did not know that looping arguments would do that
go from one to the next like that
i thought it would stop on the first argument it finished with
because of arguments.length
@wearenotgroot should of seen my first try. i had 3 loops haha
@wearenotgroot it passed the first tests that had 3 arguments :P
This message was deleted
greg
@wearenotgroot
Mar 18 2016 04:25
@andrewchar indexOf will return -1 if the value is not found or doesnt exist
Andrew Charlebois
@andrewchar
Mar 18 2016 04:26
i know i read the solution wrong it said smaller then not greater then lol
rhythmicjump
@rhythmicjump
Mar 18 2016 04:26
help profile lookup
CamperBot
@camperbot
Mar 18 2016 04:26

# Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

greg
@wearenotgroot
Mar 18 2016 04:26
:smile:
kangyao
@kay78
Mar 18 2016 04:27
dear all, like to get some help on the coding below. If I use option A, the instanceof Person returns true, but option B will return false. why?
``````var Person = function(firstAndLast) {

var firstName = firstAndLast.split(' ')[0];
var lastName = firstAndLast.split(' ')[1];

/* option A */
this.getFirstName = function(){return firstName;};
this.getLastName  = function(){return lastName;};
this.getFullName  = function(){return firstName + " " + lastName;};
this.setFirstName = function(first){firstName = first;};
this.setLastName  = function(last){lastName = last;};
this.setFullName  = function(full){firstName = full.split(" ")[0]; lastName = full.split(" ")[1]; };

/* option B doesn't work, is it due to closure?*/
return {
getFirstName: function(){return firstName;},
getLastName:  function(){return lastName;},
getFullName:  function(){return firstName + " " + lastName;},
setFirstName: function(first){firstName = first;},
setLastName: function(last){lastName = last;},
setFullName: function(full) {
firstName = full.split(' ')[0];
lastName = full.split(' ')[1];
}
};

};

var bob = new Person('Bob Ross');
bob instanceof Person;``````
why 'bob instanceof Person' returns false when use option B code?
rhythmicjump
@rhythmicjump
Mar 18 2016 04:30
Goodnight all, my brain has officially stopped working for the night.
greg
@wearenotgroot
Mar 18 2016 04:31
@kay78 well you are returning an object(anonymous) which is not declared/assigned as Person
Josh Fisk
@JoshFisk
Mar 18 2016 04:36
@kay78 try and return this
Shahriar raju
@Rajudevo
Mar 18 2016 04:51
i don't understand 181 queue function.help plz
Andrew Charlebois
@andrewchar
Mar 18 2016 04:55
help Convert HTML Entities
CamperBot
@camperbot
Mar 18 2016 04:55

# Problem Explanation:

• You have to create a program that will convert HTML entities from string to their corresponding HTML entities. There are only a few so you can use different methods.
Shahriar raju
@Rajudevo
Mar 18 2016 05:04

```
function queue(arr, item) {
testArr=arr*1;

return testArr; // Change this line
}

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

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

```function queue(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(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));

@JoshFisk can you help me

Boris
@boris-in-london
Mar 18 2016 05:04
``````if ( "geolocation" in navigator ) {
console.log("yeah we have geolaction");
navigator.geolocation.getCurrentPosition(function(pos) {
console.log(pos);
});
} else {
weatherId.innerHTML = "Geolocation" +
" is not supported by this browser.";
}``````
wondering why getCurrentPostion wont work at line 3
`console.log(pos)` don't show up in console`
Andrew Charlebois
@andrewchar
Mar 18 2016 05:06
i thought your console.log said yeah we have lactation for a second
lol
Boris
@boris-in-london
Mar 18 2016 05:07
lol the first console.log was test to see if we went into the if statement. it gets that far fine.
everything after that is a mystery.
Andrew Charlebois
@andrewchar
Mar 18 2016 05:08
``````if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;

\$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat=' + latitude + '&lon=' + longitude + '&units=metric&appid=80f8b2429407d4784a3e920826f54555', function(json) {
updateWeather = json;
presentWeather();
weatherIcon();
});
});
}``````
thats how i did mine
your not getting their lat and lon
or maybe the getcurrentpossition does that?
im not sure
Boris
@boris-in-london
Mar 18 2016 05:09
thank you for that andrew. any way to see the geolocation object?
Shahriar raju
@Rajudevo
Mar 18 2016 05:10
@andrewchar i am stuck on queue step no 181
Boris
@boris-in-london
Mar 18 2016 05:10
appreciate the input andrew, i'll have another look at it.
Andrew Charlebois
@andrewchar
Mar 18 2016 05:11
@Rajudevo we dont really use numbers for the exercises, what is the name or just post your code and question
Shahriar raju
@Rajudevo
Mar 18 2016 05:15
stand in line queue(arr, item)
Andrew Charlebois
@andrewchar
Mar 18 2016 05:16
help format
CamperBot
@camperbot
Mar 18 2016 05:16

## :point_right: code formatting [wiki]

### Multi line Code

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

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

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

### Single line Code

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

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

Andrew Charlebois
@andrewchar
Mar 18 2016 05:16
@Rajudevo use the above format to post your code
Victory
@victttoryrose
Mar 18 2016 05:22
I need some help on 178
Connor Murphy
@papasmurph
Mar 18 2016 05:23
Hi guys, I'm kind of stuck on Return Largest Numbers in Arrays. Can anyone offer some pointers?
Shahriar raju
@Rajudevo
Mar 18 2016 05:24
function queue(arr, item) @andrewchar
Andrew Charlebois
@andrewchar
Mar 18 2016 05:26
@Rajudevo what you written code for it?
Shahriar raju
@Rajudevo
Mar 18 2016 05:26
i tried to follow the format but its not happening
Andrew Charlebois
@andrewchar
Mar 18 2016 05:27
Shahriar raju
@Rajudevo
Mar 18 2016 05:27
Write a function queue which takes an array (arr) and a number (item) as arguments. Add the number to the end of the array, then remove the first element of array. The queue function should then return the element that was removed
Connor Murphy
@papasmurph
Mar 18 2016 05:28
@andrewchar That's the problem, I don't really have any haha. I'm struggling with the comparsion. I can't figure out how to compare the elements of the sub array without comparing them to themselfs
Andrew Charlebois
@andrewchar
Mar 18 2016 05:29
@papasmurph you can simply compare in an if statement
@papasmurph start by making a variable right, set that = to something and go from there
DJ
@qualitymanifest
Mar 18 2016 05:30
@papasmurph create an empty array to hold the largest parts. create a variable to temporarily hold the largest part of each subarray. change that variable if a part of the subarray is larger than your "largest" variable. after iterating through each subarray, put the largest one into your (previously empty) array. rinse and repeat.
Shahriar raju
@Rajudevo
Mar 18 2016 05:30
@andrewchar help plz
Andrew Charlebois
@andrewchar
Mar 18 2016 05:31
@Rajudevo what is the problem you're having
Connor Murphy
@papasmurph
Mar 18 2016 05:32
That's what I'm attempting to do , but I'm screwing something up. Here's basically waht I got
``````  var y = [];
for(i=0; i < arr.length; i++){
for(j = 0; j < arr[i].length; j++){
x = 0;
if(x <= arr[i][j]){
x = arr[i][j];
y.push(x);
}
}

}``````
Andrew Charlebois
@andrewchar
Mar 18 2016 05:33
so whats happening here
you have both your x and y doing something inside of one loop
you only want to push once per loop
here, you're pushing every iteration of the loop
This message was deleted
This message was deleted
Connor Murphy
@papasmurph
Mar 18 2016 05:38
That's what I figured about the iteration, I just can't figure out the comparsion part.
DJ
@qualitymanifest
Mar 18 2016 05:38
@papasmurph also it would be good to get into the practice of using descriptive variable names. for example instead of `var y = [];` maybe `var largestArr = [];` and `x` could be `largest` or `temp`
Andrew Charlebois
@andrewchar
Mar 18 2016 05:39
you only want to push if it is greater then
Connor Murphy
@papasmurph
Mar 18 2016 05:40
@andrewchar Can you clarify that last part?
DJ
@qualitymanifest
Mar 18 2016 05:40
yeah. you should reset x at the beginning of the first for loop and push x after the second for loop ends
that way you're always starting with a clean slate and you're only pushing after you've compared all parts of each subarray
if you fix those two things it will pass
Andrew Charlebois
@andrewchar
Mar 18 2016 05:41
`if(x <= arr[i][j]){` here you have it setting a value to x if its greater then or equal to. you dont want that, youll be ending up with multiple of the same number
only set value to x if its greater then
Connor Murphy
@papasmurph
Mar 18 2016 05:42
@qualitymanifest BOOM
Andrew Charlebois
@andrewchar
Mar 18 2016 05:43
This message was deleted
This message was deleted
Connor Murphy
@papasmurph
Mar 18 2016 05:43
@qualitymanifest +1 That's where I was getting it wrong, resetting x. @andrewchar +1 aswell, funnily enough I removed the or equal to part about 2 minutes before you suggested it
Shivam Arora
@shivamarora13
Mar 18 2016 06:11
help Truncate a string
CamperBot
@camperbot
Mar 18 2016 06:11

# Explanation:

We need to reduce the length of the string or truncate it if it is longer than the given maximum lengths specified and add `...` to the end. If it is not that long then we keep it as is.

Connor Murphy
@papasmurph
Mar 18 2016 06:24
Ehhh that's what I need help with! Passing 5/6 tests just the last 1 is a pain
Manikanth
@manikanth1024
Mar 18 2016 06:26

unction myTest(val) {
// Only change code below this line

if (val<20 || val>10) {
return "outside ";
}

// Only change code above this line
return "inside";
}

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

Whats wrong with this solution>
Michael Aubrey
@mca62511
Mar 18 2016 06:35
hey for the JavaScript calculator frontend project, what is "ANS" supposed to do?
DJ
@qualitymanifest
Mar 18 2016 06:41
@papasmurph still having problems with it?
@manikanth1024 a few things. the returns they expect are exact. so, get rid of the space after `outside`, and capitalize the first letters (Outside instead of outside, Inside instead of inside)
second, your logic is reversed. you're returning outside if val IS in between 10 and 20, but you should be returning that if val ISNT between 10 and 20.
Manikanth
@manikanth1024
Mar 18 2016 06:46

function myTest(val) {
// Only change code below this line

if (val>10||val<20) {
return "Inside";
}

// Only change code above this line
return "Outside";
}

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

Is it correct now?
cannelflow
@cannelflow
Mar 18 2016 06:47
@manikanth1024 which exercise?
Manikanth
@manikanth1024
Mar 18 2016 06:47
javascript exercise.
Comparisons with the Logical Or Operator
Connor Murphy
@papasmurph
Mar 18 2016 06:48
@qualitymanifest Nope :)
cannelflow
@cannelflow
Mar 18 2016 06:50
@manikanth1024 nope o is less then 20 so it will return inside
This message was deleted
This message was deleted
Manikanth
@manikanth1024
Mar 18 2016 06:53

function myTest(val) {
// Only change code below this line

if (val>10||val<20) {
return "Inside";
}

// Only change code above this line
return "Outside";
}

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

DJ
@qualitymanifest
Mar 18 2016 06:53
yeah you had it closer before, just needed to fix the typos and reverse the comparisons.you fixed the typos, the problem is now you're saying if val is greater than 10 OR val is less than 20, return Inside. but that returns inside for anything less than 10, or over 20
Manikanth
@manikanth1024
Mar 18 2016 06:53
Yes.
DJ
@qualitymanifest
Mar 18 2016 06:54
here's some pseudocode:
if value is less than 10 or greater than 20, it's outside
otherwise, it's inside
Manikanth
@manikanth1024
Mar 18 2016 06:56
Thank you guys now its fixed.
Eve Ploysiri
@eveploysiri
Mar 18 2016 07:21
Hi everyone. I can't pass this one: queue([5,6,7,8,9], 1) should return 5. And this is my code:

function queue(arr, item) {
testArr.push(item);
testArr.shift();
return arr; // Change this line
}

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

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

Harsh Khandelwal
@harsh2602
Mar 18 2016 07:22

Help needed with Record Collection question. This is what I have written

function update(id, prop, value) {
var identifier = id;
var property = prop;
var val = value;

if(collection.identifier.hasOwnProperty(property)){
collection.identifier.property = val;
}

if(collection.identifier.property === ""){
delete collection.identifier.property;
}

for(i = 0; i < collection.identifier.property.length ; i++){
if (collection.identifier.property[i] != val){
collection.identifier.property[length] = val;
}
}
return collection;
}

Getting Error that collection.identifier is undefined

CamperBot
@camperbot
Mar 18 2016 07:22
no wiki entry for: `needed with record collection question this is what i have writtenfunction updateid prop value add value to array var identifier id var property prop var val value ifcollectionidentifierhasownpropertyproperty collectionidentifierproperty val ifcollectionidentifierproperty delete collectionidentifierproperty fori 0 i collectionidentifierpropertylength i if collectionidentifierpropertyi val collectionidentifierpropertylength val return collectiongetting error that collectionidentifier is undefined`
Danny McCollins
@dmccollins
Mar 18 2016 07:22
Does anyone here use Firefox Developer Edition? If so, do you ever use Scratchpad?
Markus Kiili
@Masd925
Mar 18 2016 07:23
@harsh2602 You don't need to assign function parameters to new variables. Just use id, prop, and value.
@harsh2602 The dot notation only works if the property key string is a valid JS identifier (for example "12" and "lives left" are not) and you write the key after the dot: `var cat={clothes:"pants", "lives left":3}; cat.clothes; //returns "pants"`. Bracket notation works with keys that can be arbitrary strings `cat["lives left"]; //returns 3`, variables `var key="clothes"; cat[key]; //returns "pants"`, or expressions `cat["lives"+" "+"left"]; //returns 3`.
So `.identifier` and `.property` don't work there.
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:27
@Masd925 id is an integer...using it in a . notation will not work, right?
Markus Kiili
@Masd925
Mar 18 2016 07:27
@harsh2602 You are correct, because for example "1" is not valid JS identifier. All property keys in JS are actually strings, even array indices.
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:29
@Masd925 so exactly what am I doing incorrect here in my function?
@Masd925 If I want to use . notation I would have to assign function parameter to variables first?
Markus Kiili
@Masd925
Mar 18 2016 07:30
@harsh2602 When accessing property value with the key in a variable, use bracket notation. No need to use own variables.
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:31
@Masd925 Ok let me try using brackets..
Markus Kiili
@Masd925
Mar 18 2016 07:31
`.identifier` looks for property key "identifier", not for the key stored in variable identifier. It does the same as `["identifier"]`.
`[identifier]` looks for the key stored in variable identifier.
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:35
@Masd925 to access artist in this question would collection[id][prop] work?
Markus Kiili
@Masd925
Mar 18 2016 07:37
@harsh2602 Yes it accesses property with key prop in track with given id.
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:42
@Masd925 thanks...I made some change to conditions in code and used your advice for accessing the property..It works fine now
CamperBot
@camperbot
Mar 18 2016 07:42
harsh2602 sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1182 | @masd925 | http://www.freecodecamp.com/masd925
Markus Kiili
@Masd925
Mar 18 2016 07:43
@harsh2602 You're wellcome.
lalith mulpuri
@lalith99
Mar 18 2016 07:46
Quoting Strings with Single Quotes pls help me with that waypoint
Harsh Khandelwal
@harsh2602
Mar 18 2016 07:48
@lalith99 make sure you enclose string within single quotes
lalith mulpuri
@lalith99
Mar 18 2016 07:52
@harsh2602 thanks alot !!
CamperBot
@camperbot
Mar 18 2016 07:52
lalith99 sends brownie points to @harsh2602 :sparkles: :thumbsup: :sparkles:
:star: 227 | @harsh2602 | http://www.freecodecamp.com/harsh2602
Manikanth
@manikanth1024
Mar 18 2016 07:52

function myTest(val) {
if (val < 5) {
return "Less than 5";
}
else if(val<10){
return "less than 10";
}
else {
return "Greater than or equal to 10";
}
}
// Change this value to test

myTest(4);

help me w/the above code.
CamperBot
@camperbot
Mar 18 2016 07:53
no wiki entry for: `me wthe above code`
Marina
@chandra90
Mar 18 2016 07:56
Hello!
``````
// Setup
var myArr = [ 2, 3, 4, 5, 6];

// Only change code below this line
var myTotal = 0;
for (var i = 0; i< myArr.length; i++) {
myTotal += myArray[i];
}``````
Iterate Through an Array with a For Loop
Connor Murphy
@papasmurph
Mar 18 2016 07:57
@chandra90 Check out the for loops construction
Marina
@chandra90
Mar 18 2016 07:59
``````var myTotal = 0;
for (var i = 0; i < myArr.length; i++) {
myTotal += myArr[i];
}``````
Niko Salonen
@nikosalonen
Mar 18 2016 08:15
that should work
Connor Murphy
@papasmurph
Mar 18 2016 08:17
@chandra90 that does work
KortsF
@KortsF
Mar 18 2016 08:25
This message was deleted

Struggling with the Profile Lookup challenge. I've tried several things and all work to return "No such contact" and "No such property", but I can't find the way for the loop to return the property when both exist.

Here's my latest try:

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

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

else {
if (contacts[i].lastName !== prop || contacts[i].number !== prop || contacts[i].likes !== prop) {
return "No such property";
}
else {
return contacts[i].prop;
}
}
}``````
33ndgr
@33ndgr
Mar 18 2016 08:33

Ignoring that the code does test non-alphabetical characters (will fix it later), why do the decrypted message return some characters right and others bad?

``````function rot13(str) { // LBH QVQ VG!

var arrData = str.split("");

var newArr = arrData.map(function(letter) {
return letter.charCodeAt() - 13;
});

//Spaces :(
for (var i = 0; i < newArr.length; i++) {
if (newArr[i] === 19){
newArr[i] += 13;
}
}

var finalArr = newArr.map(function(number) {
return String.fromCharCode(number);
});

return finalArr.join("");
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");``````

That returns `F8EE C5DE CAM6`

Mooli
@Mooli88
Mar 18 2016 08:34
@KortsF a. do you know what's happening once a function hits return ?
b. try to make a use of `hasOwnProperty`
33ndgr
@33ndgr
Mar 18 2016 08:34
This message was deleted
help Caesars Cipher
CamperBot
@camperbot
Mar 18 2016 08:38

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
KortsF
@KortsF
Mar 18 2016 08:38
@Mooli88 Right! I forgot that the function exits. That was one thing.
The other was I was trying to access the property with the dot notation and it doesn't seem to work. But it does with the bracket notation. I still don't understand well when I must use one but not the other.
Max Plakhuta
@maxplakhuta
Mar 18 2016 08:40
hi folks) can you please tell me where did I make a mistake in my code:
``````function mutation(arr) {
if (arr.indexOf(arr[1]) >= 0){
return true;
} else {
return false;}
}

mutation(["hello", "hey"]);``````
it's the Mutations algorithm
for some reason it doesnt return false when arr[i]<0
Connor Murphy
@papasmurph
Mar 18 2016 08:47
@33ndgr hmmm that's a lot more elegant than mine
I'm working on it now, I've created 2 functions
Mooli
@Mooli88
Mar 18 2016 08:48
Max Plakhuta
@maxplakhuta
Mar 18 2016 08:52
help Mutations
CamperBot
@camperbot
Mar 18 2016 08:52

# Problem Explanation:

• Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
33ndgr
@33ndgr
Mar 18 2016 08:55
@papasmurph Had to see a little the solution. Didn't see that if the utf-16 number is higher than 78, there is overflow. have to work on it too >.<
Pedro Abel Díaz Sánchez
@coderHook
Mar 18 2016 08:59
apart from setTimeout(); which other ways do I have to delay smt? or at least to make the code wait for a while and then continue.
Michael Botes
@MichaelFF
Mar 18 2016 09:01
Hey guys about to start wiki Return Largest Numbers in Arrays
wiki Return Largest Numbers in Arrays
CamperBot
@camperbot
Mar 18 2016 09:01

# Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

Michael Botes
@MichaelFF
Mar 18 2016 09:01
any tips ? :D
Connor Murphy
@papasmurph
Mar 18 2016 09:12
ManBearPigg
@ManBearPigg
Mar 18 2016 09:25
Anyone do this one and have advice?
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

// Only change code below this line
function update(id, prop, value) {
if (value !== "" && prop !== "tracks") {
switch (update) {
case 1:
break;
case 2:
break;
}
collection.prop = update;
}
if (prop == "tracks" && value !== "") {
tracks.push(value);
}
if (value === ""){
delete collection.prop;
}
return collection;
}

// Alter values below to test your code
update(5439, "artist", "ABBA");``````
ManBearPigg
@ManBearPigg
Mar 18 2016 09:46
got it figured out
Michael Botes
@MichaelFF
Mar 18 2016 09:46
@ManBearPigg would you mind posting your answer, i did mine a while ago in a completely different way and am curious.
ManBearPigg
@ManBearPigg
Mar 18 2016 09:47
``````// Setup
var collection = {
2548: {
album: "Slippery When Wet",
artist: "Bon Jovi",
tracks: [
"Let It Rock",
"You Give Love a Bad Name"
]
},
2468: {
album: "1999",
artist: "Prince",
tracks: [
"1999",
"Little Red Corvette"
]
},
1245: {
artist: "Robert Palmer",
tracks: [ ]
},
5439: {
album: "ABBA Gold"
}
};
// Keep a copy of the collection for tests
var collectionCopy = JSON.parse(JSON.stringify(collection));

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

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

// Alter values below to test your code
update(5439, "artist", "ABBA");``````
im logging off now sry can’t answer questions about it now ttyl
Michael Botes
@MichaelFF
Mar 18 2016 09:47
all good thanks
its that switch case you were using that confused me:D see you removed it
wiki Return Largest Numbers in Arrays
CamperBot
@camperbot
Mar 18 2016 09:52

# Explanation:

You will get an array that contains sub arrays of numbers and you need to return an array with the largest number from each of the sub arrays.

Michael Botes
@MichaelFF
Mar 18 2016 09:52
hey guys can anyone tell me if i am on the right track
``````function largestOfFour(arr) {
// You can do this!
for (i = 0; i < arr.length; i++) {
var largest = 0;
resArr = [];
for (j = 0; j < arr[i].length; j++) {
if (largest < arr[i][j]) {
largest = newArr[j];
resArr = newArr[j];
}
}
}
return resArr;
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);``````
Markus Kiili
@Masd925
Mar 18 2016 09:58
@MichaelFF Declare the result array before the loop.
@MichaelFF In the j loop figure out the largest number in subarray arr[i]. Then after j loop, push largest to result array.
ManBearPigg
@ManBearPigg
Mar 18 2016 10:19
``````var myArray = [];

for (var i = 0; i < 5; i++) {
myArray.push(i);
}``````
The output is [0,1,2,3,4], but I think it should be [1,2,3,4,5]. I will explain why, can someone please tell me why I’m wrong.
Start with 0, its less than 5, add one so have 1, push 1, i = 1, its less than 5, add 1 so have 2, push 2, i = 2, its less than 5, add 1 so have 3, push 3, i =3, it’s less than 5, add 1 so have 4, push 4, i = 4, it’s less than 5, add 1 so have 5, push 5, i = 5, its not less than 5, stop. result [1,2,3,4,5]
Markus Kiili
@Masd925
Mar 18 2016 10:24
@ManBearPigg `var i=0` happens once before the loop. `i<5` is the condition whether to execute the loop. `i++` happens at the end of the loop block. So the first number to push is 0 and the last is 4. Variable i will be 5 after the code is run.
Shivam Arora
@shivamarora13
Mar 18 2016 10:25
can anyone help, how to delete certain specific value from an array?
Markus Kiili
@Masd925
Mar 18 2016 10:26
This message was deleted
Shivam Arora
@shivamarora13
Mar 18 2016 10:26
@MichaelFF U need to make one more array and in the inner j loop push the largest value into that array so that at the end of for loop, u have one array that got all the largest four values from arrays!

@gofighting123
Mar 18 2016 10:27
@shivamarora13 first indexOf >=0 to make sure it exist , then delete array[i]
Shivam Arora
@shivamarora13
Mar 18 2016 10:27
@gofighting123 ok, got ya!
thanks! @gofighting123
CamperBot
@camperbot
Mar 18 2016 10:28
shivamarora13 sends brownie points to @gofighting123 :sparkles: :thumbsup: :sparkles:
:star: 246 | @gofighting123 | http://www.freecodecamp.com/gofighting123

@gofighting123
Mar 18 2016 10:28
@shivamarora13 np
Markus Kiili
@Masd925
Mar 18 2016 10:28
@shivamarora13 To remove element(s) from certain index, use .splice(). To remove certain elements, use .filter(). Delete will create array with hole in it, so don't use it.
Shivam Arora
@shivamarora13
Mar 18 2016 10:29
function bouncer(arr) {
// Don't show a false ID to this bouncer.
var indexFalse = arr.indexOf(false);
var indexNull = arr.indexOf(null);
var indexZero = arr.indexOf(0);
var indexQuote = arr.indexOf("");
var indexUndefined = arr.indexOf(undefined);
var indexNan = arr.indexOf(NaN);
arr.filter(function(value){
if (indexFalse > -1) {
arr.splice(indexFalse, 1);
}
else if (indexNull > -1) {
arr.splice(indexNull, 1);
}
else if (indexZero > -1) {
arr.splice(indexZero, 1);
}
else if (indexQuote > -1) {
arr.splice(indexQuote, 1);
}
else if (indexUndefined > -1) {
arr.splice(indexUndefined, 1);
}
else if (indexNan > -1) {
arr.splice(indexNan, 1);
}
});
return arr;
}
bouncer([false, null, 0, NaN, undefined, ""]);
@Masd925 this is my code, and i have used both
.splice and filter

@gofighting123
Mar 18 2016 10:30
@Masd925 ya, delete it will be undfined :worried:
Shivam Arora
@shivamarora13
Mar 18 2016 10:30
@Masd925 but its still not working!
Markus Kiili
@Masd925
Mar 18 2016 10:32
@gofighting123 Actually a hole differs from element with value undefined, because the property with the deleted index doesn't exist anymore.
@shivamarora13 You could do it with just filter. Splice not needed at all.
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:36
i need help with the roman numeral convertor
Connor Murphy
@papasmurph
Mar 18 2016 10:37
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:38
@papasmurph i don't know how to start this.. no code yet.
Connor Murphy
@papasmurph
Mar 18 2016 10:38
@Masd925 I've noticed filter being used in a couple of the challenges, I've always done it another way but I was just looking at some code and it looks way more efficent/elegant
Gonna have to find out how it compares speed wise
Shivam Arora
@shivamarora13
Mar 18 2016 10:39
help Falsy Bouncer
CamperBot
@camperbot
Mar 18 2016 10:39

# Problem Explanation:

Remove all falsy values from an array.

Markus Kiili
@Masd925
Mar 18 2016 10:40
@papasmurph Almost always using loops and basic operations is somewhat faster, but produce more and less elegant code.
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:40
@shivamarora13 paste the link to the problem?
Connor Murphy
@papasmurph
Mar 18 2016 10:42
@surbhioberoi Personally I haven't done the challenge yet but I took a look and looks relatively simple if num 1 then x = I
Shivam Arora
@shivamarora13
Mar 18 2016 10:42
@surbhioberoi This is the problem
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:42

@shivamarora13 this was my solution-
function bouncer(array) {
return array.filter(function(x) {
return x;
});
}

bouncer([7, "ate", "", false, 9]);

@papasmurph i don't get it!
FavoriteFave
@FavoriteFave
Mar 18 2016 10:44

hey. i'm reading through the "closures" definition and i dont understand a code example there. can someone explain this to me ?

``````function makeSizer(size) {
return function() {
document.body.style.fontSize = size + 'px';
};
}

var size12 = makeSizer(12);
var size14 = makeSizer(14);
var size16 = makeSizer(16);``````

this is a closure example in the definition. i dont understand why there is the 2. function in the makeSizer function. It works the same way if i delete that second function. why is it in there ?

Connor Murphy
@papasmurph
Mar 18 2016 10:45
@surbhioberoi What don't you get? In terms of literal translation 1= I, 2 = II, 3= III, 4 = IV, 5 = V and so on and so fourth
Shivam Arora
@shivamarora13
Mar 18 2016 10:46
@surbhioberoi can u make me understand this?
It was really quite simple..but din't got it.
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:47
Markus Kiili
@Masd925
Mar 18 2016 10:47
@FavoriteFave Those functions size12 etc. remember the size and thus set different fontSize on body when invoked. Size is in the closure that is returned from makeSizer.
Shivam Arora
@shivamarora13
Mar 18 2016 10:47
@surbhioberoi Ok thanks! :)
CamperBot
@camperbot
Mar 18 2016 10:47
shivamarora13 sends brownie points to @surbhioberoi :sparkles: :thumbsup: :sparkles:
:star: 291 | @surbhioberoi | http://www.freecodecamp.com/surbhioberoi
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:47
FavoriteFave
@FavoriteFave
Mar 18 2016 10:49

@Masd925 yes i get that bit but

``````function makeSizer(size) {

document.body.style.fontSize = size + 'px';

}

var size12 = makeSizer(12);
var size14 = makeSizer(14);
var size16 = makeSizer(16);``````

this does the same thing, no ? why is there this "return function()" in the original

Connor Murphy
@papasmurph
Mar 18 2016 10:50
@surbhioberoi How you implement it is up to you, but yes I would probably use 2 arrays or a multidimensionial 1
Markus Kiili
@Masd925
Mar 18 2016 10:50
@FavoriteFave The first code assigned three functions to variables to be used later for changing fontsize. The second code changes font size three times, and assigns undefined to the variables.
Surbhi Oberoi
@surbhioberoi
Mar 18 2016 10:50
@papasmurph thanks :)
CamperBot
@camperbot
Mar 18 2016 10:50
surbhioberoi sends brownie points to @papasmurph :sparkles: :thumbsup: :sparkles:
:star: 270 | @papasmurph | http://www.freecodecamp.com/papasmurph
FavoriteFave
@FavoriteFave
Mar 18 2016 10:51
@Masd925 ohhh ok. thanks :D
CamperBot
@camperbot
Mar 18 2016 10:51
favoritefave sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1183 | @masd925 | http://www.freecodecamp.com/masd925
Geo Galagaran
@geeofree
Mar 18 2016 10:54
``````function destroyer(arr) {
var myArgs = arguments;
var filtered = arr.filter(function(val){
return val !== myArgs[1] && val !== myArgs[2] && val!==myArgs[3];
});
return filtered;
}

destroyer([3, 5, 1, 2, 2], 2, 3, 5);``````
Hey guys. Can anyone tell me how I can make this code a little "automated" rather than typing out myArgs[x]
Markus Kiili
@Masd925
Mar 18 2016 10:56
@da7thsin You could loop arguments out.
Pedro Abel Díaz Sánchez
@coderHook
Mar 18 2016 10:57
Is there smt wrong with freecodecamp today? I tried to submit smt but didn't get the mark for it
Geo Galagaran
@geeofree
Mar 18 2016 10:57
@Masd925 I'm thinking about putting them into an array and then return val != that Array. Is there a way I could do that?
Brendan Kinahan
@BKinahan
Mar 18 2016 10:57
This message was deleted
Markus Kiili
@Masd925
Mar 18 2016 10:57
@da7thsin If you turn arguments into an array, you can use indexOf inside the filter callback.
Geo Galagaran
@geeofree
Mar 18 2016 11:00
@Masd925 Okay. I will try and see what I can do. Thank you!
CamperBot
@camperbot
Mar 18 2016 11:00
da7thsin sends brownie points to @masd925 :sparkles: :thumbsup: :sparkles:
:star: 1184 | @masd925 | http://www.freecodecamp.com/masd925
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 11:10
Can someone please explain to me why in the following code `func(arr[1])` doesn't return true when it's inside the for loop?
``````function drop(arr, func) {
// Drop them elements.
//return func(arr[1]);

for (var i = 0; i < arr.length; i++) {
if (func(arr[i]) === true) {
break;
} else {
arr.shift();
}
}

return arr;
}

//drop([1, 2, 3], function(n) {return n < 3; });
drop([0, 1, 2, 3], function(n) {return n === 1;});``````
Lokendra Sharma
@kuroop
Mar 18 2016 11:13
is codepen.io working ?
kirbyedy
@kirbyedy
Mar 18 2016 11:14
yes ?
Lokendra Sharma
@kuroop
Mar 18 2016 11:14
I am at the tribute page making stage
but when I open the sample link
it doesn't show the view of the project..
but instead show that the site is suffering through error
Brendan Kinahan
@BKinahan
Mar 18 2016 11:15
@motoko-11 It's working fine for me.
@motoko-11 what error are you seeing?
Lokendra Sharma
@kuroop
Mar 18 2016 11:16
it's showing this in my browser

We have fancy error reporting systems in place, so this error has been logged and probably even emailed directly to the people responsible. But if you'd like to vent, help us out with some context of what happened, or would like a reply, fill out the form below.

Shivam Arora
@shivamarora13
Mar 18 2016 11:16
help seek and destroy
CamperBot
@camperbot
Mar 18 2016 11:16

# Explanation:

This problem is a bit tricky because you have to familiarize yourself with Arguments, as you will have to work with two or more but on the script you only see two. Many people hardcode this program for three arguments. You will remove any number from the first argument that is the same as any other other arguments.

Brendan Kinahan
@BKinahan
Mar 18 2016 11:16
@motoko-11 odd. try a different browser, perhaps.
Lokendra Sharma
@kuroop
Mar 18 2016 11:16
okay .. I will :)
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 11:17
help Drop it
CamperBot
@camperbot
Mar 18 2016 11:17

# Explanation:

Basically while the second argument is not true, you will have to remove the first element from the left of the array that was passed as the first argument.

Lokendra Sharma
@kuroop
Mar 18 2016 11:18
can anyone tell me how to logout from a session of frecodecamp ?
@BKinahan Tried chrome.. same problem
@BKinahan http://snag.gy/gWOM4.jpg this is a screenshot of how it looks to me
Davide
@DavOnGit
Mar 18 2016 11:21
@AchiPapakon inside the if function put only arr[i]
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 11:21
@DavOnGit I want to check the function in the second argument.
if it's true or not
Davide
@DavOnGit
Mar 18 2016 11:23
Then u have to use the 'arguments' object....
...this gives u acces to an array of arguments
Codemzy
@codemzy
Mar 18 2016 11:26
@motoko-11 you can log out from freecodecamp on your profile page click 'settings' and then you can log out
@motoko-11 not sure whats going on with your codepen though :(
Brendan Kinahan
@BKinahan
Mar 18 2016 11:26
@motoko-11 sign out link can be found here: https://www.freecodecamp.com/settings
Lokendra Sharma
@kuroop
Mar 18 2016 11:27
Thanks
Markus Kiili
@Masd925
Mar 18 2016 11:27
@AchiPapakon You are on the right track. You are just mutating the array you iterate over which screws the indices up.
Brendan Kinahan
@BKinahan
Mar 18 2016 11:27
@motoko-11 do you get the same 404 errors in a chrome incognito window?
Markus Kiili
@Masd925
Mar 18 2016 11:27
@AchiPapakon You could do a while loop that checks and removes the first element.
Lokendra Sharma
@kuroop
Mar 18 2016 11:28
@BKinahan it was not a incognito but error was same..
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 11:28
@Masd925 Yes you're right... The indexes... :/
Lokendra Sharma
@kuroop
Mar 18 2016 11:28
some how this works fine
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 11:28
@Masd925 thanks
Lokendra Sharma
@kuroop
Mar 18 2016 11:29
I googled a tribute page ( though I didn't wanted to ... but this doens't show any errors ) @BKinahan
jovbe
@jovbe
Mar 18 2016 11:33
``````function myTest(val) {
// Only change code below this line

case 1:
val = "alpha";
break;

case 2:
val = "beta";
break;

case 3:
val = "gamma";
break;

case 4:
val = "delta";
break;

}
}

// Only change code above this line
}

// Change this value to test
myTest(1);``````

Write a switch statement which tests val and sets answer for the following conditions:
1 - "alpha"
2 - "beta"
3 - "gamma"
4 - "delta"

I'm doing something wrong..

Lokendra Sharma
@kuroop
Mar 18 2016 11:35
@jovbe what you are doing wrong is inside switch you got the variables wrong... val should be inside the switch bracket and while assiging you should set asnwer="alpha"(or anythign else)
@BKinahan thanks. I kind of work now don't know why.
CamperBot
@camperbot
Mar 18 2016 11:36
motoko-11 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1098 | @bkinahan | http://www.freecodecamp.com/bkinahan
Eve Ploysiri
@eveploysiri
Mar 18 2016 11:36

Hi I'm stuck here. I have to : Cards Sequence 2, J, 9, 2, 7 should return "1 Bet" to past the test. My Code is: 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 = 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
break;
}

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

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

Michael Botes
@MichaelFF
Mar 18 2016 11:36
@Masd925 and @shivamarora13 thanks!
CamperBot
@camperbot
Mar 18 2016 11:36
michaelff sends brownie points to @masd925 and @shivamarora13 :sparkles: :thumbsup: :sparkles:
:star: 1185 | @masd925 | http://www.freecodecamp.com/masd925
:star: 243 | @shivamarora13 | http://www.freecodecamp.com/shivamarora13
Geo Galagaran
@geeofree
Mar 18 2016 11:37
Can anyone explain to me what charCodeAt() does? I don't quite get what the returned numbers are for...
Peter
@xor4
Mar 18 2016 11:38

var result = "";
// Your code below this line

// Your code above this line
return result;
}

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

Brendan Kinahan
@BKinahan
Mar 18 2016 11:38
Peter
@xor4
Mar 18 2016 11:38
what am I supposed to do in this challenge?
Brendan Kinahan
@BKinahan
Mar 18 2016 11:40
@xor4 Return a phrase in the form of "My favorite NOUN was so ADJECTIVE that it couldn't VERB unless I threw it ADVERB(ly)"
Michael Botes
@MichaelFF
Mar 18 2016 11:40
wiki code
CamperBot
@camperbot
Mar 18 2016 11:40

# Learn how to plan your future project!

Blog post written by BiancaMihai - GitHub / Twitter

An ounce of preparation is worth a pound of cure. That's true in medicine, and that's definitely true in software development.

Here's a structured 10-step workflow that will guide you through the app planning process, with the goal of saving you from writing a lot of unnecessary code.

Together, we'll plan out a simple "To-do" single-page web app. We'll also plan for an API backend for a future mobile app.

Michael Botes
@MichaelFF
Mar 18 2016 11:40
whoops :D
Geo Galagaran
@geeofree
Mar 18 2016 11:41
@BKinahan I know. But, the unicode for what? Just the first letter or something? o_o
Brendan Kinahan
@BKinahan
Mar 18 2016 11:42
@da7thsin the method takes an argument, the index of the character within the string. so `"Hello".charCodeAt(1) === (the code for "e")`
@da7thsin without an argument, it defaults to `0`, the first character
jovbe
@jovbe
Mar 18 2016 11:42
@motoko-11
That's what i had before, but doesn't work..
``````function myTest(val) {
// Only change code below this line

switch (val){
case 1:
break;

case 2:
break;

case 3:
break;

case 4:
break;

}
}

// Only change code above this line
}

// Change this value to test
myTest(1);``````
Geo Galagaran
@geeofree
Mar 18 2016 11:42
@BKinahan ohhh. That makes sense now. Haha thanks!! :D
CamperBot
@camperbot
Mar 18 2016 11:42
da7thsin sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1099 | @bkinahan | http://www.freecodecamp.com/bkinahan
Peter
@xor4
Mar 18 2016 11:43
thanks @BKinahan
CamperBot
@camperbot
Mar 18 2016 11:43
xor4 sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1100 | @bkinahan | http://www.freecodecamp.com/bkinahan
Lokendra Sharma
@kuroop
Mar 18 2016 11:44
@jovbe is it me or you can also see more closing brackets ?
return answer is looking outside the function call to me..
*function defination
jovbe
@jovbe
Mar 18 2016 11:45
@motoko-11 got it, thank you!
CamperBot
@camperbot
Mar 18 2016 11:45
jovbe sends brownie points to @motoko-11 :sparkles: :thumbsup: :sparkles:
:star: 140 | @motoko-11 | http://www.freecodecamp.com/motoko-11
Lokendra Sharma
@kuroop
Mar 18 2016 11:45
:smile:
Eve Ploysiri
@eveploysiri
Mar 18 2016 11:51
``````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 = 0;
break;
case 10:
case 'J':
case 'Q':
case 'K':
case 'A':
count -= 1;
break;
}

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

// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');``````
can someone help me with this? I have to finish: Cards Sequence 2, J, 9, 2, 7 should return "1 Bet"
Brendan Kinahan
@BKinahan
Mar 18 2016 11:53
@eveploysiri why should `count = 0;` if the card is between 7 and 9?
Michael Botes
@MichaelFF
Mar 18 2016 11:54
@eveploysiri change it to count += 0;
Russell Wheatley
@Rusticman
Mar 18 2016 11:54
wiki pairwise
CamperBot
@camperbot
Mar 18 2016 11:54

# Explanation:

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

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

Brendan Kinahan
@BKinahan
Mar 18 2016 11:54
@eveploysiri that causes you to disregard what any cards before the final `7` were
Geo Galagaran
@geeofree
Mar 18 2016 11:57
wiki Caesars Cipher
CamperBot
@camperbot
Mar 18 2016 11:57

## :point_right: algorithm caesars cipher [wiki]

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

# :checkered_flag: Problem Explanation:

• You need to write a function, which will take string encoded with
Caesar cipher as a parameter and decode it.
• The one used here is ROT13 where the value of the letter is
shifted by 13 places.
e.g. 'A' ↔ 'N', 'T' ↔ 'G'.
• You have to shift it back 13 positions, such that 'N' ↔ 'A'.
Eve Ploysiri
@eveploysiri
Mar 18 2016 11:57
@BKinahan OK.. But how to not do that 😅
Brendan Kinahan
@BKinahan
Mar 18 2016 11:57
@eveploysiri simply make no change to `count` for that range :)
@eveploysiri aka do nothing
Eve Ploysiri
@eveploysiri
Mar 18 2016 11:58
@BKinahan @MichaelFF Thanks!!!
CamperBot
@camperbot
Mar 18 2016 11:58
eveploysiri sends brownie points to @bkinahan and @michaelff :sparkles: :thumbsup: :sparkles:
:star: 1101 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 255 | @michaelff | http://www.freecodecamp.com/michaelff
Michael Botes
@MichaelFF
Mar 18 2016 11:58
@eveploysiri it work? :)
Eve Ploysiri
@eveploysiri
Mar 18 2016 11:59
@BKinahan Hahah OK thanks. Sometimes I want to make things harder then it is.
CamperBot
@camperbot
Mar 18 2016 11:59
eveploysiri sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:warning: eveploysiri already gave bkinahan points
Eve Ploysiri
@eveploysiri
Mar 18 2016 12:00
@MichaelFF I'm going to try later. I'll let you know! Haha. Had to run
Michael Botes
@MichaelFF
Mar 18 2016 12:00
@eveploysiri good luck :D
NinjaPotato
@hdninjapotato
Mar 18 2016 12:01

Anyone who can explain what im suppose to with this code: function convert(celsius) {
// Only change code below this line

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

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

Brendan Kinahan
@BKinahan
Mar 18 2016 12:03
@hdninjapotato convert the input `celsius` temperature to the correct fahrenheit temperature, and assign it to the `fahrenheit` variable
NinjaPotato
@hdninjapotato
Mar 18 2016 12:03
@BKinahan And how do i do that?
Brendan Kinahan
@BKinahan
Mar 18 2016 12:04
@hdninjapotato first find the formula for converting the temperature, then apply that in code.
Carlos
@socarlosb
Mar 18 2016 12:05
morning :)
NinjaPotato
@hdninjapotato
Mar 18 2016 12:06
@BKinahan and how do i apply it
Eve Ploysiri
@eveploysiri
Mar 18 2016 12:07
@hdninjapotato BKinahan means something like val Fahrenheit = the formula with celsius
Brendan Kinahan
@BKinahan
Mar 18 2016 12:07
@hdninjapotato try reading this if you're still stuck. It's hard to say more without solving it for you.. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
Eve Ploysiri
@eveploysiri
Mar 18 2016 12:07
You can do it @hdninjapotato
Michael Botes
@MichaelFF
Mar 18 2016 12:08
@hdninjapotato just persevere man, i've been stuck on this one algorithm whole morning and just got it now :D i'm always so close and then give up :<
wiki Return Largest Numbers in Arrays
CamperBot
@camperbot
Mar 18 2016 12:08
no wiki entry for: `return largest number in arrays`
NinjaPotato
@hdninjapotato
Mar 18 2016 12:09
im guessing it scould be something like this: var fahrenheit = 9/5 + 32;
but it dosen't convert it
Eve Ploysiri
@eveploysiri
Mar 18 2016 12:12
@hdninjapotato don't forget to use celcius
dhstambolliu
@dhstambolliu
Mar 18 2016 12:14
var fahrenheit = (celsius * 9/5) + 32;
anyone can help me here
Aleksander Gębicki
@Takumar
Mar 18 2016 12:20
@dstambolliu you mistyped `celsius` word.
``var fahrenheit = celsius * 9/5 + 32;``
dhstambolliu
@dhstambolliu
Mar 18 2016 12:21
right @Takumar , edited
Geo Galagaran
@geeofree
Mar 18 2016 12:35

Hey Guys. Can someone help me with this?

``````function rot13(str) { // LBH QVQ VG!
var splitWord = str.split('');
var wordArr = [];
var unicodes;
for(i = 0; i<splitWord.length; i++){
wordArr[i] = splitWord[i].charCodeAt();
if(wordArr[i] === 32){
wordArr[i] = 32;
}
else if(wordArr[i] > 77){
wordArr[i] -= 13;
}
else if(wordArr[i] >= 65){
wordArr[i] += 13;
}
}
unicodes = wordArr.join(',');
return String.fromCharCode(unicodes);
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");``````

I get that unicodes is a string I believe? I tried to use parseInt() but it just returned one number from unicodes.

how do I turn unicodes to an integer?
Michael Botes
@MichaelFF
Mar 18 2016 12:41
charCodeAt()?
i think
Brendan Kinahan
@BKinahan
Mar 18 2016 12:42
@da7thsin charCodeAt() returns a number (an integer), not a string
@da7thsin you should convert them back into characters before joining them into a string, rather than ending up with a string with the value of a long number.
Geo Galagaran
@geeofree
Mar 18 2016 12:44
@BKinahan No no. I meant unicodes.(the variable declaration at the very bottom) Although I checked that unicodes == isNaN(returned false) which means it is a number. I just don't know why String.fromCharCode(unicodes) isn't working. Hmmmm
Brendan Kinahan
@BKinahan
Mar 18 2016 12:45
@da7thsin it doesn't work because the top limit for a unicode value is 65536, but `unicodes` is equal to `"70,82,69,69,32,67,79,68,69,32,67,65,77,80"`
Zubair Ali
@03aliz
Mar 18 2016 12:45
Hi everyone, can someone tell me why this isn't working, it just says charlie isn't defined.

// 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.val;

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

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

Brendan Kinahan
@BKinahan
Mar 18 2016 12:46
@03aliz when setting the value of result, use bracket notation instead. `lookup.val` looks for a property with the name `"val"` and not the value of the variable `val`
@03aliz also I think you might've changed some code you weren't supposed to..
Zubair Ali
@03aliz
Mar 18 2016 12:47
ah I see i though that val was the placeholder and it would just switch with charlie. Thanks
Theodore P.
@Ierofantis
Mar 18 2016 12:47
``````

function palindrome(str) {

var result=str.replace(/[\W_-]/g, '').toLowerCase("").split("");
var res=str.reverse.join("");

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

if (res==str){

return true;
}
else{
return false;
}

}

}``````
where am I wrong?
Brendan Kinahan
@BKinahan
Mar 18 2016 12:48
@03aliz should be `phoneticLookup("charlie");` not `phoneticLookup(charlie);`
Zubair Ali
@03aliz
Mar 18 2016 12:49
yes I know, I changed it becuase I though that it wasn't working becuase it was a string
Brendan Kinahan
@BKinahan
Mar 18 2016 12:49
@Ierofantis `str.reverse.join("");` is incorrect
Zubair Ali
@03aliz
Mar 18 2016 12:49
But its worked with bracket notation, thanks
Geo Galagaran
@geeofree
Mar 18 2016 12:49

@BKinahan

``````function rot13(str) { // LBH QVQ VG!
var splitWord = str.split('');
var wordArr = [];
var unicodes = [];
for(i = 0; i<splitWord.length; i++){
wordArr[i] = splitWord[i].charCodeAt();
if(wordArr[i] === 32){
wordArr[i] = 32;
}
else if(wordArr[i] > 77){
wordArr[i] -= 13;
}
else if(wordArr[i] >= 65){
wordArr[i] += 13;
}
unicodes[i] = String.fromCharCode(wordArr[i]);
}
return unicodes.join('');
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");``````

got the fixed. :D

Brendan Kinahan
@BKinahan
Mar 18 2016 12:49
@da7thsin great :)
Geo Galagaran
@geeofree
Mar 18 2016 12:50
@BKinahan thank you for suggesting :D
CamperBot
@camperbot
Mar 18 2016 12:50
da7thsin sends brownie points to @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1102 | @bkinahan | http://www.freecodecamp.com/bkinahan
Theodore P.
@Ierofantis
Mar 18 2016 12:51
@BKinahan result.reverse.join("")?
Brendan Kinahan
@BKinahan
Mar 18 2016 12:51
@Ierofantis `.reverse()` works on arrays, not strings, and requires the `()`
Theodore P.
@Ierofantis
Mar 18 2016 12:52
@BKinahan but split("") doesn't turn the string to an array?
Brendan Kinahan
@BKinahan
Mar 18 2016 12:53
@Ierofantis it does, but you don't split `str` on that line.
@Ierofantis when you call `split('')` on `str` on the previous line, it makes an array out of `str` and assigns it to `result`, but `str` itself is not changed.
@Ierofantis this allows for things like `if (str === str.split('').reverse().join('')) ...` to be used to see if a string is the same backwards and forwards (note that this does not account for punctuation or capitalization as this challenge requires)
Gabriel Brunette-Savard
@gabrielsavard
Mar 18 2016 12:57

I solved the Truncate a string problem but I am sure their is more elegant ways of solving the problem.

``````function truncate(str, num) {
// Clear out that junk in your trunk

if (str.length > num) {
if (num <= 3) {
return str.slice(0, num) + "...";

} else if (str.length > num ) {
return str.slice(0, num - 3) + "...";
}
} else {
return str;
}
}

can some one please criticize my code.

Theodore P.
@Ierofantis
Mar 18 2016 12:59
@BKinahan something like this?
`````` var result=str.replace(/[\W_-]/g, '').toLowerCase("").split("");
var res=result.reverse().join("");``````
Brendan Kinahan
@BKinahan
Mar 18 2016 13:00
@Ierofantis yes, that will give you `res` as a reversed string, but remember that `result` is still an array.
Aleksander Gębicki
@Takumar
Mar 18 2016 13:01
@Ierofantis call `toLowerCase()` in your chain earlier, so you don't have to add `i` switch (ignore casing) in your regular expression, also do you think you need `-` in your regexp?
Codemzy
@codemzy
Mar 18 2016 13:02
@gabrielsavard I think you have to ifs with the same condition... `if (str.length > num)` and `} else if (str.length > num )` ... so you could just do something like...
``````function truncate(str, num) {
if (str.length > num) {
newStr = str.slice(0, num-3);
return newStr + "...";
}
else {
return str;
}
}``````
Mooli
@Mooli88
Mar 18 2016 13:03

hi i need help with Title Case a Sentence please:

``````function titleCase(str) {

return str.toLowerCase().replace(/\b[a-z]/g, function(letter, index){

return letter.toUpperCase();

});
}

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

i get back "I'M A Little Tea Pot" instead of I'm A Little Tea Pot"

kirbyedy
@kirbyedy
Mar 18 2016 13:06
maybe you should split the string into an array first, then uppercase the first letter and then join the array back to the string
Zach
@Moose1551
Mar 18 2016 13:06
Can anyone hold my hand a bit with "Stand in Line" in Basic javaScript?
I've tried so many different things that I can't remember at what point, if ever, I was on the right track.
My first road block on this second godforsaken attempt at Basic javaScript.
Aleksander Gębicki
@Takumar
Mar 18 2016 13:08
@Moose1551 you have to do three things:
• add element `item` to the end of your `arr` array
• remove first element from your array
• return removed element
Mooli
@Mooli88
Mar 18 2016 13:08
@kirbyedy i've tried that but i got to the point that i must use for loop to apply the uppercase but from there i got stuck
Gabriel Brunette-Savard
@gabrielsavard
Mar 18 2016 13:08
@codemzy thanks. Your solution does not work for: // truncate("A-", 1) should return "A...".
truncate("Absolutely Longer", 2) should return "Ab...".
CamperBot
@camperbot
Mar 18 2016 13:08
gabrielsavard sends brownie points to @codemzy :sparkles: :thumbsup: :sparkles:
:star: 766 | @codemzy | http://www.freecodecamp.com/codemzy
Aleksander Gębicki
@Takumar
Mar 18 2016 13:09
@Moose1551 for sure you have done all required elements in earlier challenges, and you should know methods which operates on array for doing this
`push()` and `shift()` and `return` keyword.
Codemzy
@codemzy
Mar 18 2016 13:09
hmmm @gabrielsavard maybe they changed the challenge since I did it lol
alpox
@alpox
Mar 18 2016 13:11
This message was deleted
Theodore P.
@Ierofantis
Mar 18 2016 13:18
@Takumar thanks that was It
``````  var result=str.replace(/[\W_]/g, '').toLowerCase();
var res=result.split('').reverse().join('');``````
CamperBot
@camperbot
Mar 18 2016 13:18
ierofantis sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2766 | @takumar | http://www.freecodecamp.com/takumar
alpox
@alpox
Mar 18 2016 13:19
Worked
Aleksander Gębicki
@Takumar
Mar 18 2016 13:20
@Moose1551 have you done your challenge?
@Ierofantis you are welcome :-)
Theodore P.
@Ierofantis
Mar 18 2016 13:22
@Takumar so i didn't understand well the returning the string on an array when you split It the you add join
Aleksander Gębicki
@Takumar
Mar 18 2016 13:24
@Ierofantis but you understand now?
Theodore P.
@Ierofantis
Mar 18 2016 13:25
@Takumar yes, this is the reason that I am solving alogorithms to fully understand them
Vivienne Sales
@Natto278
Mar 18 2016 13:34
In regards to the "Stand in Line" exercise, do we need to change the numbers in the Test Setup variable var testArr = [1,2,3,4,5];? We need to write three different function queues, right?
I am not asking for the answer, I just want to see that I'm on the right track for the "Stand in Line" exercise.
cannelflow
@cannelflow
Mar 18 2016 13:37
@Natto278 in function you are passing two argument arr& item now inside function you need to push the argument item to arr then you need to remove a number from arr then return what was removed
Zach
@Moose1551
Mar 18 2016 13:40
@Takumar , this is what I have so far. I understand that push() and shift() need to be used, but even after looking at the old exercises and my notes, I'm at a loss. I just can't figure it. Like @Natto278 , I'm not looking for the answer, I just want to know if I'm even moving in the right direction.
``````function queue(arr, item) {
console.log(arr + item);
arr.push(item);
arr.shift([0]);
return item;  // Change this line
}

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

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));``````
Vivienne Sales
@Natto278
Mar 18 2016 13:41
Thank you for the hint @cannelflow . I'm going to look at some of the previous exercises I did earlier in Basic JavaScript and write some code sets in my paper notebook before I enter them into the FCC webpage. Wish me luck!
CamperBot
@camperbot
Mar 18 2016 13:41
natto278 sends brownie points to @cannelflow :sparkles: :thumbsup: :sparkles:
:star: 952 | @cannelflow | http://www.freecodecamp.com/cannelflow
V Arun Kumar
@arunvkumr
Mar 18 2016 13:44
@Moose1551 you are close... shift removes the first elem of the array automatically. so you don't have to give any arguments to shift.
and shift returns an elem.. so you got to store it in some variable.. :grinning:
cannelflow
@cannelflow
Mar 18 2016 13:45
@Natto278 :+1:
Ryan
@NotSoV
Mar 18 2016 13:58
This message was deleted
What's up with my dot notation. It isn't accessing the nested array. The example to the side doesn't show 'type:' and 'list:' in their examples and how to utilize them.
``````// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line``````
Zach
@Moose1551
Mar 18 2016 14:02
@arunkumrv , I'm slamming my head against the desk over here. Is this closer?
``````function queue(arr, item) {
var myArray = ([arr], item);
myArray = ([5,6,7,8,9] , 1);
console.log(arr + item);
arr.push(item);
arr.shift();
return item;  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(queue(testArr, myArray)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));``````
Ryan
@NotSoV
Mar 18 2016 14:03
@Moose1551 Keep in mind you are after the "Shifted" item. To obtain the "Shifted" item, you have to use arr.shift();
Emil Aasa
@emilaasa
Mar 18 2016 14:05
@Moose1551 what value are you returning now vs what value do you really want to return?
V Arun Kumar
@arunvkumr
Mar 18 2016 14:06
@Moose1551 ya.. you are close.. i would recommend you read the shift() MDN page once, how you can store and use the shifted elem...
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
@Moose1551 and you don't need the statements with myArray.. as you are not using it anywhere..
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:07
Can someone explain to me why in `chopped.shift()`, arr is shifted as well?
``````    arr = [0, 1, 2, 3, 4, 5];
var chopped = arr;
var third= [0, 1, 2, 3, 4, 5];
chopped.shift();
console.log(chopped);
console.log(arr);
console.log(third);``````
kirbyedy
@kirbyedy
Mar 18 2016 14:11
dont understand he question
whats the third array doing ?
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:11
@kirbyedy Nothing.
kirbyedy
@kirbyedy
Mar 18 2016 14:11
you declared it, but I dont see anything happening there
anyway I get this output: [1, 2, 3, 4, 5 ]
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:12
@kirbyedy when I do `chopped.shift()`, both chopped and arr is shifted. And third doesn't follow (arr, chopped and third initially have the same data)
Sujit Karki
@Swoozeki
Mar 18 2016 14:12
@AchiPapakon when you assign an array to another array, you're pointing to the same memory
you should clone one array to another instead
kirbyedy
@kirbyedy
Mar 18 2016 14:13
maybe this will help
This message was deleted
Brendan Kinahan
@BKinahan
Mar 18 2016 14:14
@AchiPapakon `chopped` and `arr` refer to the same array in memory
kirbyedy
@kirbyedy
Mar 18 2016 14:15
@BKinahan <-- what he said
Brendan Kinahan
@BKinahan
Mar 18 2016 14:15
@AchiPapakon if you want to make a copy of an array rather than refer to the same array with a new variable, do something like `var chopped = arr.slice()`
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:16
that was it
Thanks @Swoozeki @BKinahan
CamperBot
@camperbot
Mar 18 2016 14:16
achipapakon sends brownie points to @swoozeki and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 340 | @swoozeki | http://www.freecodecamp.com/swoozeki
:star: 1103 | @bkinahan | http://www.freecodecamp.com/bkinahan
Brendan Kinahan
@BKinahan
Mar 18 2016 14:17
@AchiPapakon note that when using slice, if the array contains a reference to an object, the reference is copied (like with chopped = arr) rather than a new object instance being created.
Ryan
@NotSoV
Mar 18 2016 14:19
I don't recall the lesson going over type/list and how to access them via dot notation. How far is my dot notation off here?
``````// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line``````
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:20
@BKinahan I didn't understand that Honda example when I first read it, but I do now
Zach
@Moose1551
Mar 18 2016 14:21

@NotSoV , @arunkumrv , after reading the link, and redoing the code, here is what I have:

``````function queue(arr, item) {

console.log(arr + item);
arr.push(item);
arr.shift();
var shifted = item.shift();
console.log(item);
return item;  // Change this line
}

// Test Setup
var testArr = [5,6,7,8,9];

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

@emilaasa , I'm returning "TypeError: item.shift is not a function" but I want to return "Before 5,6,7,8,9
(whatever) After 6,7,8,95"

Brendan Kinahan
@BKinahan
Mar 18 2016 14:21
@AchiPapakon woo!
Aleksander Gębicki
@Takumar
Mar 18 2016 14:21
@NotSoV `trees` is value of `type` property, you cannot access it in such way (using dot notation).
Brendan Kinahan
@BKinahan
Mar 18 2016 14:21
@NotSoV `myPlants` is an array. Dot notation doesn't apply to it.
V Arun Kumar
@arunvkumr
Mar 18 2016 14:22
@Moose1551 looks good... now you have to return the variable shifted.. not item..
`return shifted;`
Ryan
@NotSoV
Mar 18 2016 14:22
@Moose1551 As @emilaasa said earlier, you need to think about what you are returning. What is the value of item?
@Moose1551 Is that the value you really want?
Aleksander Gębicki
@Takumar
Mar 18 2016 14:22
@Moose1551 this line is good: `arr.shift();` because it is removing first element from `arr` array. But when you remove value without storing it somewhere it is lost.
This: `var shifted = item.shift();` rather not, because item is single value and you cannot use `shift()` method on it.
V Arun Kumar
@arunvkumr
Mar 18 2016 14:23
@Moose1551 ya i didn't see that item.shift... remove it.. and do as @Takumar suggested :point_up_2:
Ryan
@NotSoV
Mar 18 2016 14:26

@Takumar @BKinahan But the instructions say to use .notation and bracket notation, so I did: myPlants.trees[1]

"Instructions
Retrieve the second tree from the variable myPlants using object dot and array bracket notation."

Aleksander Gębicki
@Takumar
Mar 18 2016 14:26
@NotSoV you use dot or bracket notation with properties, but `trees` is not a property!
Brendan Kinahan
@BKinahan
Mar 18 2016 14:27
@NotSoV So if dot notation doesn't apply for accessing elements of an array, that only leaves bracket notation ;)
Mooli
@Mooli88
Mar 18 2016 14:27
``````function titleCase(str) {

var newstr = str.toLowerCase().split(" ");
for(var i=0;i<newstr.length;i++){

newstr[i][0].toUpperCase();
console.log(newstr[i][0].toUpperCase());

}

return str ;
}
titleCase("I'm a little tea pot");``````
CamperBot
@camperbot
Mar 18 2016 14:27
no wiki entry for: `please function titlecasestr var newstr strtolowercasesplit forvar i0inewstrlengthi newstri0touppercase consolelognewstri0touppercase return str titlecaseim a little tea pot`
Aleksander Gębicki
@Takumar
Mar 18 2016 14:28
@Mooli88 `newstr[i][0]` is first letter of every word you check with your loop, but you cannot make it upper case in such way: `newstr[i][0].toUpperCase();`
Brendan Kinahan
@BKinahan
Mar 18 2016 14:28
@Mooli88 `newstr[i][0].toUpperCase()` is equal to the uppercase version of whatever character is at the start of each element of `newstr`, but it's not assigned to any variable and it doesn't change anything either.
Francis
@Francis-p
Mar 18 2016 14:29
@Mooli88
Aleksander Gębicki
@Takumar
Mar 18 2016 14:30
@Mooli88 hint for you
``````var str = "abc";
str.toUpperCase(); // this is not working
str = str.toUpperCase(); // now str === "ABC"``````
Mooli
@Mooli88
Mar 18 2016 14:30
@BKinahan thats my problem. im not sure how to append the transformed letter
Aleksander Gębicki
@Takumar
Mar 18 2016 14:30
@Mooli88 remember also that you learned about `+` - concatenation operator for joining strings.
Mooli
@Mooli88
Mar 18 2016 14:31
@Takumar you mean var str += ?
Aleksander Gębicki
@Takumar
Mar 18 2016 14:32
@Mooli88 no, I meant only `+`: `str = "AB" + "cd";`
Colin
@CThor
Mar 18 2016 14:32
Hey guys, have any of you had an issue where previous problems are not populating the previous answers you had?
Ryan
@NotSoV
Mar 18 2016 14:33
@Takumar @BKinahan That gave me one of those eureka moments! Thanks to the both of you!
CamperBot
@camperbot
Mar 18 2016 14:33
notsov sends brownie points to @takumar and @bkinahan :sparkles: :thumbsup: :sparkles:
:star: 1104 | @bkinahan | http://www.freecodecamp.com/bkinahan
:star: 2768 | @takumar | http://www.freecodecamp.com/takumar
Mooli
@Mooli88
Mar 18 2016 14:33
@Takumar oh but by what i know , it will only work if i'll put those pluses a beforehand :/
ok i'll see if i got you hint . brb thanks
Brendan Kinahan
@BKinahan
Mar 18 2016 14:34
@CThor solutions are stored in local storage so they'll load when you open a challenge from the map, but your solutions are also stored in your account via your profile page (you can click on the 'view solution' link next to a challenge name on your profile to load your successful solution there)
Zubair Ali
@03aliz
Mar 18 2016 14:34
Hello guys,
can someone tell me why this doesn't work?

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

// Only change code below this line

var secondTree = myPlants[]; // Change this line

Aleksander Gębicki
@Takumar
Mar 18 2016 14:35
@NotSoV you're welcome :-)
Brendan Kinahan
@BKinahan
Mar 18 2016 14:35
@CThor this also means using a different device or browser won't access your local storage code
Zubair Ali
@03aliz
Mar 18 2016 14:35
sorry wrong one
Aleksander Gębicki
@Takumar
Mar 18 2016 14:35
Zubair Ali
@03aliz
Mar 18 2016 14:35

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

// Only change code below this line

var secondTree = myPlants.trees[1]; // Change this line

Ryan
@NotSoV
Mar 18 2016 14:36
Brendan Kinahan
@BKinahan
Mar 18 2016 14:36
Should just copy/paste 'myPlants is an array' in this chat every now and then
Aleksander Gębicki
@Takumar
Mar 18 2016 14:36
@03aliz notice that your array `myPlants` contains two objects
Ryan
@NotSoV
Mar 18 2016 14:36
@BKinahan LOL
Aleksander Gębicki
@Takumar
Mar 18 2016 14:36
@BKinahan it should hand on below `FreeCodeCamp/HelpJavaScript title of room ;-)
Brendan Kinahan
@BKinahan
Mar 18 2016 14:36
@Takumar haha
Ryan
@NotSoV
Mar 18 2016 14:36
Yeah, I think this lesson stumps people because the examples for that lesson are different than the task at hand.
Brendan Kinahan
@BKinahan
Mar 18 2016 14:37
@Takumar (I know what you meant because of the context, but 'hand on below' is not a familiar phrase to me)
@NotSoV that is being worked on actually FreeCodeCamp/FreeCodeCamp#7559
richardmoyer
@richardmoyer
Mar 18 2016 14:40
hi all. im stuck early in javascript, track 205 returning boolean values from functions.
Dylan Pagillo
@DylanNeil
Mar 18 2016 14:40
I'm working on RecordCollection. This is what I have so far. My syntax is off, but I believe my logic is correct. Any advice/direction would be greatly appreciated!

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

else if(id !== "" && value == ""){
prop().delete;
}

return collection;
}

richardmoyer
@richardmoyer
Mar 18 2016 14:41
looking for any clues. i feel like its something obvious missing but google hasnt helped.
Ryan
@NotSoV
Mar 18 2016 14:41
@BKinahan Awesome, because it needs it. lol
Zubair Ali
@03aliz
Mar 18 2016 14:43
@Takumar Thanks figured it out.
CamperBot
@camperbot
Mar 18 2016 14:43
03aliz sends brownie points to @takumar :sparkles: :thumbsup: :sparkles:
:star: 2769 | @takumar | http://www.freecodecamp.com/takumar
Achilleas Papakonstantinou
@AchiPapakon
Mar 18 2016 14:45
help steamroller