Trying to make a function that pushes an element

Hello all,

I’m trying to write a function that pushes ‘Waldo: unknown’ onto the end of an object. Can someone help me as to why ‘push’ isn’t working in this scenario.

here is my code

var addWaldo = (obj) =>  {
  var element = {}
  element['Waldo'] = 'unknown'
  return obj

What is the result you are getting? It looks like you are pushing onto the object a second object that contains Waldo: unknown.

I’m not sure that push works on objects?

You might want to review this lesson.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.