These are chat archives for FreeCodeCamp/HelpJavaScript

10th
Sep 2017
Eric Hasegawa
@EricHasegawa
Sep 10 2017 01:25
Can someone tell me what I'm doing wrong here? It's the "Diff Two Arrays" challenge

function diffArray(arr1, arr2) {
  var longerArr = 0;
  if (arr1.length > arr2.length) {
    longerArr = arr1.length;
  } else {
    longerArr = arr2.length;
  }
  var newArr = [];
  for (var i=0; i < longerArr.length; i++ ) {
    if (arr1.indexOf(i) != arr2.indexOf(i) );
     newArr.push(i);
  }

  return newArr;
}

diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);
luccifer00
@luccifer00
Sep 10 2017 01:39
@EricHasegawa you are not using .filter?
@EricHasegawa you are returning always the same result []
an empty array
Ogundele Olumide
@Lumexralph
Sep 10 2017 01:41
@EricHasegawa you need to check the element in the array not iterator i
Eric Hasegawa
@EricHasegawa
Sep 10 2017 01:42
@Lumexralph How can I do that
luccifer00
@luccifer00
Sep 10 2017 01:51
@EricHasegawa i am not sure at all.... but you should check this things
longerArr.length this retutn nothing... u only want longerArr
also chek the if statement
if(something){so...}, and you forget the {}
korzo
@korzo
Sep 10 2017 01:53
@EricHasegawa It's wrong.
You have to iterate over both arrays
luccifer00
@luccifer00
Sep 10 2017 01:54
@EricHasegawa also newArr.push(i), probably push a number... you want to push arr1[i]
and @korzo is rigth, you can't compare arr1[i] with arr2[i], becouse the names not always are in the same position
jinvey-china
@jinvey-china
Sep 10 2017 02:03
how to send the problem?
korzo
@korzo
Sep 10 2017 02:08
@EricHasegawa Iterate over arr1, find all elements that are not in arr2 and push them in newArr. Then do the same with arr2 and return newArr
Eric Hasegawa
@EricHasegawa
Sep 10 2017 02:08
@korzo I think I figured it out, thanks!
CamperBot
@camperbot
Sep 10 2017 02:08
erichasegawa sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 469 | @korzo |http://www.freecodecamp.com/korzo
Stephen James
@sjames1958gm
Sep 10 2017 02:09
@johnotu
You could clear the input after selection
Maybe a little more hover contrast it is hard to see the change when you hover
The same with the item borders
jinvey-china
@jinvey-china
Sep 10 2017 02:16
@sjames1958gm I want to send the question,because i can't write the code.
Fernando
@lestairon
Sep 10 2017 04:17
How do i check something between the ...>example<... on Javascript?
I mean
If i have <p>whatever</p> i want to check whatever
piteto
@piteto
Sep 10 2017 04:20
@lestairon with jQuery, use .html(), or .text(). With vanilla javascript, user .innerHTML or .textContent
Fernando
@lestairon
Sep 10 2017 04:21
.html checks also the <p>
Am i wrong?
piteto
@piteto
Sep 10 2017 04:21
only the content inside of <p></p>
var text = $('p').html();
best to give it an ID though, in case you have multiple p elements
<p id="whatever">whatever</p>
var text = $("#whatever").html()
or var text = $("#whatever").text()
Fernando
@lestairon
Sep 10 2017 04:24
if ($("#text").text() != $("#shadow-text").text()){... Then this will work, right?
piteto
@piteto
Sep 10 2017 04:25
yes
Fernando
@lestairon
Sep 10 2017 04:25
@piteto Thanks ^^
CamperBot
@camperbot
Sep 10 2017 04:25
lestairon sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:cookie: 78 | @piteto |http://www.freecodecamp.com/piteto
Ogundele Olumide
@Lumexralph
Sep 10 2017 05:21
@lestairon with VanillaJS, you can get element and access its textContent or innerText property/attributes
Markus Kiili
@Masd925
Sep 10 2017 06:16
@lestairon Another way is to access the textNode and use .nodeValue.
Mukul Agrawal
@mukul09
Sep 10 2017 06:18
I do have some confusions regarding GSOC. Is there anyone who can guide me about the same?
WAINGOR
@WAINGOR
Sep 10 2017 06:45
Hi all, I have no idea where I am going wrong here:
intermediate algo challenges, sum all odd fibonacci numbers
function sumFibs(num) {
var viboArray= [1,1,2];
var secondLast = viboArray[viboArray.length-2];
var last = viboArray[viboArray.length-1];

do {
viboArray.push(secondLast+last);
}
while(viboArray[viboArray.length-1]<=num ) ;

console.log(last);

var sumAll = 1;
for (var i=0; i<viboArray.length; i++) {
 if (!viboArray[i]%2) {
     sumAll += viboArray[i];
 }
}
return sumAll;

}
Pethaf
@Pethaf
Sep 10 2017 06:47
@WAINGOR Doesn't the challenge ask you to sum the first n fibbonaccis?
WAINGOR
@WAINGOR
Sep 10 2017 06:49
it does not actually,,,
and what I rlly want to know is why this above code will cause an infinite loop...
Markus Kiili
@Masd925
Sep 10 2017 06:58
@WAINGOR Values of secondLast and last are only calculated once. So they are not raising.
Morchid Chellali
@Morched23MJ
Sep 10 2017 08:31
And the condition !viboArray[i]%2, must have forgotten the ==0 after it? @WAINGOR
WAINGOR
@WAINGOR
Sep 10 2017 08:32
@Morched23MJ no...
that is implied :)
Morchid Chellali
@Morched23MJ
Sep 10 2017 08:32
?
heroiczero
@heroiczero
Sep 10 2017 08:33
1 is true and 0 is false
Morchid Chellali
@Morched23MJ
Sep 10 2017 08:33
Owh, yeah yeah, sry
Shouldn't you inverse the loop while?
heroiczero
@heroiczero
Sep 10 2017 08:35
@WAINGOR i think you are summing all evens currently
Stephen James
@sjames1958gm
Sep 10 2017 09:33
@WAINGOR Your sumAll should start at zero not 1
and you will push one too many values with a do while
Kelechi Chinaka
@kelechy
Sep 10 2017 10:35
:wave: guys
https://www.codewars.com/kata/what-is-type-of-variable/train/javascript @sjames1958gm am having issues with the last case Date() how do i fix?
Stephen James
@sjames1958gm
Sep 10 2017 10:45
@kelechy You can use value.constructor.name - to get the constructor name and convert to lower case
What I did was go to the console and create d = new Date() then looked at properties of d that might work.
Recalled that functions have name property
function type(value) {
  if (value !== null && value !== undefined)
    return value.constructor.name.toLowerCase()

  return (value === null) ? "null" : "undefined"
}
The real trick was remembering that functions have name property
Kelechi Chinaka
@kelechy
Sep 10 2017 10:49
o cool
makes sense thanks @sjames1958gm
CamperBot
@camperbot
Sep 10 2017 10:49
kelechy sends brownie points to @sjames1958gm :sparkles: :thumbsup: :sparkles:
:star2: 8455 | @sjames1958gm |http://www.freecodecamp.com/sjames1958gm
Kelechi Chinaka
@kelechy
Sep 10 2017 11:01
if (value instanceof Date) return 'date' @sjames1958gm
Stephen James
@sjames1958gm
Sep 10 2017 11:03
That handles that specific case yes
Kelechi Chinaka
@kelechy
Sep 10 2017 11:07
yes
Krittiya Clark
@krittiyaclark
Sep 10 2017 13:55

I want to loop array and display to HTML as a list. How can I do that?

Array:

var array = ['Slide 1', 'Slide 2', 'Slide 3', 'Slide 4', 'Slide 5', 'Slide 6', 'Slide 7', 'Slide 8', 'Slide 9'];
Markus Kiili
@Masd925
Sep 10 2017 13:59
@krittiyaclark Take a look at methods Document.createElement() and Node.appendChild(). You can use a for loop for example and append content to the DOM inside the loop.
Krittiya Clark
@krittiyaclark
Sep 10 2017 14:02
@Masd925 I know my code is wrong but how can I solve it?
function listItem(item){
  for (var i = 0; i < item.array.length; i++){
    var list = item.array[i];

    list = document.createElement('li');
    document.getElementByClass(box).appendChild(list);

  }  
 }
Ronique Ricketts
@RoniqueRicketts
Sep 10 2017 14:03
@krittiyaclark This works you can make it simpler
var array = ['Slide 1', 'Slide 2', 'Slide 3', 'Slide 4', 'Slide 5', 'Slide 6', 'Slide 7', 'Slide 8', 'Slide 9'];
array.forEach(function(list){
 var div = document.createElement("div");
 var text = document.createTextNode(list);
  div.appendChild(text);
  var currentDiv = document.getElementById("div1"); 
  document.body.insertBefore(div, currentDiv); 
})
Krittiya Clark
@krittiyaclark
Sep 10 2017 14:05
@RoniqueRicketts Thank you. What about for loop?
CamperBot
@camperbot
Sep 10 2017 14:05
krittiyaclark sends brownie points to @roniquericketts :sparkles: :thumbsup: :sparkles:
:cookie: 389 | @roniquericketts |http://www.freecodecamp.com/roniquericketts
Ronique Ricketts
@RoniqueRicketts
Sep 10 2017 14:08
@krittiyaclark ot works too. U can change the forEach on a regular for loop. For each is just a fancy loop
Markus Kiili
@Masd925
Sep 10 2017 14:11
@krittiyaclark You can iterate over an array with a for loop or with one of the array iterators. for...in loop is not meant for iterating over an array.
Morchid Chellali
@Morched23MJ
Sep 10 2017 14:12
Anyone familiar with Github pages? Trying to change title and icon of my Github page.
Krittiya Clark
@krittiyaclark
Sep 10 2017 14:31

@RoniqueRicketts I had this code. Can you point it why it did not work?

var array = ['Slide 1', 'Slide 2', 'Slide 3', 'Slide 4', 'Slide 5', 'Slide 6', 'Slide 7', 'Slide 8', 'Slide 9'];

function listItem(item){
for (var i = 0; i < item.array.length; i++){
var list = item.array[i];
var newList = document.createElement('li');
var text = document.createTextNode( item.array[i]);
document.getElementByClass('box').appendChild(li);

console.log(array[i]);

}
}

Thayyeb salim
@Thayyebsalim
Sep 10 2017 14:41

guys I'm stuck at this challenge

https://www.freecodecamp.org/challenges/smallest-common-multiple
smallest common multiple

function smallestCommons(arr) {
  var checkNum=0;
  for(var i=1,min=Math.min(arr[1],arr[0]),max=Math.max(arr[1],arr[0]);;i++){
     checkNum=i*min;
    if(lcm(checkNum,min,max))
      return checkNum;
  } 
  function lcm(num,min,max){
    while (min<=max){
      if (num%min==0){
        min++;
    }
      else 
        return false;
    }
    return true;
  }
}


smallestCommons([1,14]);

it works for 1,12 range
not above it

Can I get some help please?
Sandip Shrestha
@saninmersion
Sep 10 2017 14:52
@krittiyaclark you should review arrays. your item variable is an array so you use it like item.length, item[i] and so on. Read/ watch some examples on arrays, might help you.
@Thayyebsalim your code is far too complicated to find lcm of two numbers
Thayyeb salim
@Thayyebsalim
Sep 10 2017 14:58
Its the lcm of the range @saninmersion
Sandip Shrestha
@saninmersion
Sep 10 2017 15:49
can someone suggest me any way to hide the lastchild from my panel in this flex layout. https://codepen.io/saninmersion/full/gxVjed/
Jen
@jenniredfield
Sep 10 2017 16:07
anyone stuck on Diff Two Arrays Challenge ?
Pieter Stokkink
@forkerino
Sep 10 2017 16:08
@Thayyebsalim You are checking way too many numbers. You can safely assume that the lcm of a range is a multiple of the largest number in the range. So you should only check multiples of that number.
Neel
@NeelDVirus
Sep 10 2017 16:57

There is a simple bug and i am not getting it.

    z= following; //"following" is an array
    x1= z; // x1 gives the value array with 9 element as expected 
    x2=z.length; //x2 gives '0'. why??

The code is a part from this codepen. check the line-31,32,33 and try executing the values of x1 and x2 in the console
https://codepen.io/neel111/pen/oeKGJL?editors=0111

Jen
@jenniredfield
Sep 10 2017 16:59

function diffArray(arr1, arr2) {
  var newArr = [];

  var arrConcat = arr1.concat(arr2);
  arrConcat.sort();
  for(var i = 0; i < arrConcat.length; i++) {
    if(arrConcat[i] !== arrConcat[i+1]) {
      newArr.push(arrConcat[i]);

    }

  }

  return newArr;
could anyone help me figure out why all elements are being push into my new array...I just specified I only want the elements that are not equal to their neighbour :/
Pieter Stokkink
@forkerino
Sep 10 2017 17:02
@NeelDVirus z and following point to the same array. x2 will be set to the length of z at the time of initialization (which is still 0, because .getJSON is asynchronous and will only populate the array after the data gets back from the api
Neel
@NeelDVirus
Sep 10 2017 17:07
@forkerino but x1 is already having the array and it is shown explicitly in the console. then if this is the case which you told then x1 should also be an empty array. what i am missing here?
Pieter Stokkink
@forkerino
Sep 10 2017 17:08
@NeelDVirus if you console.log(x1) on the line after declaring it, you'll see it'll log an empty array.
Neel
@NeelDVirus
Sep 10 2017 17:09
@jenniredfield your code seems fine to me. what was your arguments with which you were trying to check?
Pieter Stokkink
@forkerino
Sep 10 2017 17:11
@jenniredfield the problem as I see it is that you will keep one of the two if the item is in both arrays, while you should throw both of them out.
Neel
@NeelDVirus
Sep 10 2017 17:11
@forkerino yeah you are right. i cant reconcile one thing that how did x1 got the array value?
Moisés Man
@moigithub
Sep 10 2017 17:13
[1,1,2,2,3,3,4,4]
1 is diff than 2 .. then 1 is pushed
2 is diff than 3 then 2 is pushed
3 is diff than 4 then 3 is pushed
4 is diff than undefined.. then 4 is pushed @jenniredfield
Pieter Stokkink
@forkerino
Sep 10 2017 17:13
@NeelDVirus arrays are a reference type, which means that the variables z, following and x1 point to the same array. If you add an item to one of them, the others will also point to the array with that item in it.
Jen
@jenniredfield
Sep 10 2017 17:15
Hi Moises Man
But Im telling it to check index of 0 + 1
1 is equal to 1
Pieter Stokkink
@forkerino
Sep 10 2017 17:16
So when following is populated, the other two will also check those.
Jen
@jenniredfield
Sep 10 2017 17:16
and should not be pushed?
Pieter Stokkink
@forkerino
Sep 10 2017 17:16
@NeelDVirus ^
@jenniredfield but then you check index 1 and 2 (which is 1 and 2)
so 1 will be pushed
Jen
@jenniredfield
Sep 10 2017 17:17
Ahh yeah... scheiss....
Neel
@NeelDVirus
Sep 10 2017 17:17
@forkerino Thanks a lot man. i just missed a bit concept of reference type and pointer
CamperBot
@camperbot
Sep 10 2017 17:17
neeldvirus sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2929 | @forkerino |http://www.freecodecamp.com/forkerino
Pieter Stokkink
@forkerino
Sep 10 2017 17:19
@NeelDVirus :+1: It is useful to know. It also means that if you need a copy of an array, you have to use another way to make an actual copy, or you might get unexpected behavior. One common way to make a copy is to use .slice()
Neel
@NeelDVirus
Sep 10 2017 17:20
@forkerino can you suggest me how shall i do this statement for (var i=0; i<following.length; i=i+1); where i am using following.length which will show 0 i presume when the code will be executed because the array is not being populated. line-36
Pieter Stokkink
@forkerino
Sep 10 2017 17:25
@NeelDVirus The general rule of thumb is that if you need to do something with data coming back from a .getJSON, you do that inside the callback (so put the last part inside the second .getJSON, much like you put the second getJSON inside the first) Of course it is possible to extract it in a separate function, so the code looks cleaner and less like nested functions inside nested functions.
Neel
@NeelDVirus
Sep 10 2017 17:25
@forkerino hey man this is the forked pen of my pen. here console.log(z, x2) is executing the value of the array and its length.
same code but different behaviour :o
https://codepen.io/anon/pen/mMNQjj?editors=1111
Pieter Stokkink
@forkerino
Sep 10 2017 17:26
well, yes, that is precisely because you put the z, x1, x2 inside the .getJSON callback
Neel
@NeelDVirus
Sep 10 2017 17:28
@forkerino oh oh yeah yeah. i am being stupid again. thanks again, i presume you saved my several hours of figuring it out
CamperBot
@camperbot
Sep 10 2017 17:28
neeldvirus sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
api offline
Pieter Stokkink
@forkerino
Sep 10 2017 17:29
np
Ogundele Olumide
@Lumexralph
Sep 10 2017 17:35
@forkerino Hallo! :smile:
piteto
@piteto
Sep 10 2017 17:50
I haven't worked with functions that look like: addTogether(2)([3]). What's the use case for calling a function like that?
Seems like an IIFE style, but I presume it could also be addTogether(2)([3])(8) ?
I vaguely get currying and closures, but not seeing the real benefit compared to traditional functions
Joseph
@revisualize
Sep 10 2017 18:31
@piteto Currying
@piteto Use case.. IDK.
Moisés Man
@moigithub
Sep 10 2017 18:32

function factories

function add(x){
  return function(n){
    return x + n;
  }
}

var addTwo = add(2)
addTwo(4) :point_right: 6

Pieter Stokkink
@forkerino
Sep 10 2017 18:39
@Lumexralph :wave: Closed my tab earlier, doing some coding challenges on exercism.io
Thayyeb salim
@Thayyebsalim
Sep 10 2017 18:58
thanks @forkerino
CamperBot
@camperbot
Sep 10 2017 18:58
thayyebsalim sends brownie points to @forkerino :sparkles: :thumbsup: :sparkles:
:star2: 2930 | @forkerino |http://www.freecodecamp.com/forkerino
Garrus Napp
@GarrusNapp
Sep 10 2017 19:48
I'm writing an html5 canvas game and I want to separate JS into two files, so I have global variables in different place than functions for the code to be more readable. How could I go about it? Is requireJS a right tool for such thing?
Joseph
@revisualize
Sep 10 2017 21:12
@GarrusNapp Or just use JavaScript?
Garrus Napp
@GarrusNapp
Sep 10 2017 21:12
@revisualize How?
Joseph
@revisualize
Sep 10 2017 21:13
@GarrusNapp Do you know how to link to a JavaScript file?
Garrus Napp
@GarrusNapp
Sep 10 2017 21:13
@revisualize just one <script></script> below the other ?
Joseph
@revisualize
Sep 10 2017 21:13
@GarrusNapp Yup
Garrus Napp
@GarrusNapp
Sep 10 2017 21:15
@revisualize yea, may work for now, probably it won't grow bigger than 2-3 files. Thanks
CamperBot
@camperbot
Sep 10 2017 21:15
garrusnapp sends brownie points to @revisualize :sparkles: :thumbsup: :sparkles:
:star2: 4449 | @revisualize |http://www.freecodecamp.com/revisualize
Joseph
@revisualize
Sep 10 2017 21:19
@GarrusNapp Just break your stuff apart.
@GarrusNapp You could even do some stuff with promises
Load this file .then() load this file .then() load this file
LydaTech
@lydatech
Sep 10 2017 22:08
anyone useing lite-server?
John
@AnonymousLords
Sep 10 2017 22:37
:point_up: September 10, 2017 6:33 PM anyone help ?:D
Inferfire
@Inferfire
Sep 10 2017 23:08
Hey anyone online here?
piteto
@piteto
Sep 10 2017 23:09
@Inferfire yes
a few of us :)
Inferfire
@Inferfire
Sep 10 2017 23:09
Hey
Gersho
@Gersho
Sep 10 2017 23:09
i was pondering if i should say i'm offline
Inferfire
@Inferfire
Sep 10 2017 23:09
Any chance someone can help me with some js collision detection?
Gersho
@Gersho
Sep 10 2017 23:10
collision detection ? paste what you have and explain what you are trying to achieve, and we'll help if we can
Inferfire
@Inferfire
Sep 10 2017 23:10
if (player.y < entity.y && (player.x + player.w) > entity.x + 10 &&
player.x < (entity.x + entity.w) - 10 && player.velY >= 0) {
player.y = entity.y - player.h;
player.velY = 0;
}
            if ((player.x <= (entity.x + entity.w)) && ((player.x + player.w) >= entity.x) && (player.y < (entity.y + entity.h +1)) && (player.velY > 0)) {
                player.y = (entity.y + entity.h + 2);
                player.velY = 0;
piteto
@piteto
Sep 10 2017 23:11
I think that's <canvas> terminology, I'm no good at that yet
Inferfire
@Inferfire
Sep 10 2017 23:11
I am using some aspects of the canvas, but that's really not important though, this is math if I'm not mistaken
Gersho
@Gersho
Sep 10 2017 23:12
oh, funny coincidence, i was starting to wonder how i'll be making the roguelike (i just finished getting the basics of reacts)
so i'm sorry to say i'm absolutely unable to help D:
Inferfire
@Inferfire
Sep 10 2017 23:12
S'all righty
Gersho
@Gersho
Sep 10 2017 23:12
what's player.w ?
Inferfire
@Inferfire
Sep 10 2017 23:12
The width of the player
Likewise, player.h is the player's height
Same goes for the entity
Gersho
@Gersho
Sep 10 2017 23:13
oh so it's the manifestation of the hitbox
Inferfire
@Inferfire
Sep 10 2017 23:13
I would say sure, but I have no idea what that is
Gersho
@Gersho
Sep 10 2017 23:14
in games the hitbox is some sort of invisible box around object that is here to detect collisiobn
Inferfire
@Inferfire
Sep 10 2017 23:14
Yeah, it's pretty much that
The top part that's written in normal font is working and detects the player when it hits the floor, and keeps it up, but I'm not so sure how to make it work for the ceiling, which is the second part
Gersho
@Gersho
Sep 10 2017 23:17
floor and ceiling, are we talking bottom and top of the screen ?
max#237
@maximilientoumi
Sep 10 2017 23:18
please guys check this out i need your feedback
Inferfire
@Inferfire
Sep 10 2017 23:19
Yeah
Gersho
@Gersho
Sep 10 2017 23:20
@maximilientoumi Here you Go! title seems unnecesarry, and your interface is already pretty charged, if you could make your buttons more visible you wouldn't need the text explaining them, on the left, you have chosen multiple quotes, so you should make it plural, the calls for quote themselves work great, good work !
max#237
@maximilientoumi
Sep 10 2017 23:22
@Gersho thanks for ur feedback
CamperBot
@camperbot
Sep 10 2017 23:22
maximilientoumi sends brownie points to @gersho :sparkles: :thumbsup: :sparkles:
:cookie: 409 | @gersho |http://www.freecodecamp.com/gersho
juni
@junipberry
Sep 10 2017 23:22
hey guys, so I can’t delete a property..how can I fix this so I delete its value instead?
function removeNumbersLargerThan(num, obj) {
  let prop = obj[key];
  if (prop > num) {
    delete prop;
  }
}
Gersho
@Gersho
Sep 10 2017 23:23
@Inferfire then both blocks should be more similar than this, y being your vertical operator in both cases, most of the differences should be in > becoming < and vice versa (we are talking about 2 borders that are in front of each other/paralel ) (after reading myself, i'm not sure it makes sense)
Jody LeCompte
@jodylecompte
Sep 10 2017 23:23
The issue is that when you do let prop = obj[key]; you are creating a "reference" to that item, but it does not actually contain the item
So when you use delete prop rather than deleting the actual key from the object, it deletes the secondary reference to the property
A secondary issue is that key is not defined in your function, you'll need to adjust how you look at each item to check the number
Inferfire
@Inferfire
Sep 10 2017 23:32
@Gersho So what do you think I should do?
Gersho
@Gersho
Sep 10 2017 23:34
try copying the first one and modify bits until it works ? :p sorry
Inferfire
@Inferfire
Sep 10 2017 23:35
Well, I might as well
Jody LeCompte
@jodylecompte
Sep 10 2017 23:39
It's the exact same but mirrored
I didn't see the original question but I remember you asking about JS collison in teh main channel
Can I assume you're drawing on a canvas?
piteto
@piteto
Sep 10 2017 23:43
@junipberry key isn't defined in your function and your function doesn't return anything
I assume you also need to iterate through your object
function removeNumbersLargerThan(num, obj) {
  for (var prop in obj) if (obj[prop] > num) delete obj[prop];
  return obj;
}