Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28538 > unrolled thread
| Started by | Ajinkya Joshi <ajinkya.joshi.d@gmail.com> |
|---|---|
| First post | 2015-08-19 00:19 -0700 |
| Last post | 2015-08-19 19:26 +0200 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Ajinkya Joshi <ajinkya.joshi.d@gmail.com> |
|---|---|
| Date | 2015-08-19 00:19 -0700 |
| Subject | How to solve this ? |
| Message-ID | <ed7fa790-443f-4e27-8bca-0d9f194dc36a@googlegroups.com> |
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"
[toc] | [next] | [standalone]
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2015-08-19 11:29 +0200 |
| Message-ID | <mr1i9h$22i$1@adenine.netfront.net> |
| In reply to | #28538 |
Ajinkya Joshi wrote:
> 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 } } };
Should needle be a string literal 'needle'? Or is that another variable
defined elsewhere?
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-08-19 17:02 +0000 |
| Message-ID | <mr2cr9$j0a$2@dont-email.me> |
| In reply to | #28538 |
On Wed, 19 Aug 2015 00:19:22 -0700, Ajinkya Joshi wrote: > Write a javascript function .... coursework yourself do! -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2015-08-19 19:26 +0200 |
| Message-ID | <XnsA4FBC5D157576eejj99@194.109.6.166> |
| In reply to | #28544 |
Denis McMahon <denismfmcmahon@gmail.com> wrote on 19 Aug 2015 in comp.lang.javascript: > On Wed, 19 Aug 2015 00:19:22 -0700, Ajinkya Joshi wrote: > >> Write a javascript function .... > > coursework yourself do! courseoff. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web