-2

How could i get the mark and mary by using searchstring and current_object? I have to use array_push for pushing new searchstring and current_object for create new output like mark and mary.

function get_suggestion_array_from_object(searchstring, current_object) {
  var suggestion_array = [];
  console.log(current_object);
}

var test_searchstring = 'Ma';
var test_current_object_string = '{"r":{"k":0,"y":0}}';

var test_current_object = JSON.parse(test_current_object_string);

get_suggestion_array_from_object(test_searchstring, test_current_object);
Yusuf Kandemir
  • 810
  • 7
  • 16
rai
  • 27
  • 1
  • 7

1 Answers1

0

I'm not sure at all what it is you're asking but just a simple optimization would be this:

instead of writing a JSON string and then parsing it to an object, write the object immediatly:

var test_current_object_string = '{"r":{"k":0,"y":0}}';
var test_current_object = JSON.parse(test_current_object_string);

into:

var test_current_object = {r:{k:0, y:0}};
CodeAt30
  • 874
  • 6
  • 17