Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28538

How to solve this ?

Newsgroups comp.lang.javascript
Date 2015-08-19 00:19 -0700
Message-ID <ed7fa790-443f-4e27-8bca-0d9f194dc36a@googlegroups.com> (permalink)
Subject How to solve this ?
From Ajinkya Joshi <ajinkya.joshi.d@gmail.com>

Show all headers | View raw


Write a javascript function, findPath(obj, str), that takes a javascript object and a string parameter and iterates through the object and returns the path to the key that contains the string as a value (using '.' as a separator). For example:

var obj = { bat: bee, bird: plane, bee : { foo : bar, test : { text: needle } } };

var path = findPath (obj, 'needle');

Would yield:

path = "bee.test.text"

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

How to solve this ? Ajinkya Joshi <ajinkya.joshi.d@gmail.com> - 2015-08-19 00:19 -0700
  Re: How to solve this ? Martin Honnen <mahotrash@yahoo.de> - 2015-08-19 11:29 +0200
  Re: How to solve this ? Denis McMahon <denismfmcmahon@gmail.com> - 2015-08-19 17:02 +0000
    Re: How to solve this ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-08-19 19:26 +0200

csiph-web