These are chat archives for FreeCodeCamp/HelpJavaScript

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?

mosaic-greg
@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
can someone please help me with this.
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
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;
}

$(document).ready(function() {
$("#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

:point_right: algorithm factorialize a number [wiki]

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

:pencil: read more about algorithm factorialize a number on the FCC Wiki

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

:point_right: algorithm sorted union [wiki]

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.
:pencil: read more about algorithm sorted union on the FCC Wiki
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.
cause it already exists.
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
hold please.
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
Spoiler alert
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
@donghoonkim1226 post your code :)
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

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

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

:point_right: algorithm seek and destroy [wiki]

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.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

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
Daniel Adams
@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
Daniel Adams
@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?
Daniel Adams
@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
Daniel Adams
@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
Meade
Daniel Adams
@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');
bob.setFirstName("Haskell");
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.
Daniel Adams
@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
Instead of Haskell it's 4 and 6
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
Daniel Adams
@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
Kade
@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];
Kade
@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 = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp)
{
  // Your Code Here

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

// 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
Kade
@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
Kade
@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
can you past your code?
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
i am not sure what its asking me to do? can anyone pplease help
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;
  collection["1245"].tracks = ["Addicted to Love"];
  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
@andrewchar read about arguments
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

:point_right: checkpoint record collection [wiki]

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.

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

:pencil: read more about checkpoint record collection on the FCC Wiki

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

:point_right: checkpoint profile lookup [wiki]

Checkpoint: Profile Lookup

Instructions

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

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

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

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

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

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

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

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

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

:point_right: algorithm convert html entities [wiki]

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.

:pencil: read more about algorithm convert html entities on the FCC Wiki

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) {
// Your code here

return item; // Change this line
}

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

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

@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

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

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
@papasmurph post your code
@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
@Rajudevo i cant help you if you dont show your code
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

:point_right: algorithm truncate a string [wiki]

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.

:pencil: read more about algorithm truncate a string on the FCC Wiki

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) {
// Your code here
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) {
//add value to array
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!
please help

// 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'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

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
Max Plakhuta
@maxplakhuta
Mar 18 2016 08:52
help Mutations
CamperBot
@camperbot
Mar 18 2016 08:52

:point_right: algorithm mutations [wiki]

Problem Explanation:

  • Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array..
:pencil: read more about algorithm mutations on the FCC Wiki
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

:point_right: algorithm return largest numbers in arrays [wiki]

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.

:pencil: read more about algorithm return largest numbers in arrays on the FCC Wiki

Michael Botes
@MichaelFF
Mar 18 2016 09:01
any tips ? :D
Connor Murphy
@papasmurph
Mar 18 2016 09:12
@MichaelFF check your comparasion operators
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:
      answer = "album";
      break;
    case 2:
      answer = "artist";
      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

:point_right: algorithm return largest numbers in arrays [wiki]

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.

:pencil: read more about algorithm return largest numbers in arrays on the FCC Wiki

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
post your code with ```
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

:point_right: algorithm falsy bouncer [wiki]

Problem Explanation:

Remove all falsy values from an array.

:pencil: read more about algorithm falsy bouncer on the FCC Wiki

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
@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
@papasmurph so i need to start with two arrays?
@shivamarora13 read about filter prototype.
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
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
I am talking about this link @kirbyedy http://codepen.io/FreeCodeCamp/full/wMQrXV
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

Our Bad. Probably.

404 (Page Not Found)

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

:point_right: algorithm seek and destroy [wiki]

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.

:pencil: read more about algorithm seek and destroy on the FCC Wiki

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

:point_right: algorithm drop it [wiki]

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.

:pencil: read more about algorithm drop it on the FCC Wiki

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... :/
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) {
  var answer = "";
  // Only change code below this line

  switch (answer){
    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  
  return answer;  
}

// 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
}

// Add/remove calls to test your function.
// 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

function wordBlanks(myNoun, myAdjective, myVerb, myAdverb) {
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

:point_right: 10 steps to plan better so you can write less code [wiki]

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.

:pencil: read more about 10 steps to plan better so you can write less code on the FCC Wiki

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) {
  var answer = "";
  // Only change code below this line

  switch (val){
    case 1:
      answer = "alpha";
      break;

    case 2:
      answer = "beta";
      break;

    case 3:
      answer = "gamma";
      break;

    case 4:
      answer = "delta";
      break;     

      }
  }

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

// 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
}

// Add/remove calls to test your function.
// 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

:point_right: algorithm pairwise [wiki]

Explanation:

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

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

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

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'.

:pencil: read more about algorithm caesars cipher on the FCC Wiki

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