Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28693 > unrolled thread
| Started by | pinapalmieri@gmail.com |
|---|---|
| First post | 2015-09-16 07:42 -0700 |
| Last post | 2015-09-16 22:00 +0200 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.javascript
structure data : array pinapalmieri@gmail.com - 2015-09-16 07:42 -0700
Re: structure data : array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 16:02 +0100
Re: structure data : array "Bruce M. Axtens" <bugmagnet@outlook.com> - 2015-09-16 23:17 +0800
Re: structure data : array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-09-16 16:23 +0100
Re: structure data : array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-09-16 22:00 +0200
| From | pinapalmieri@gmail.com |
|---|---|
| Date | 2015-09-16 07:42 -0700 |
| Subject | structure data : array |
| Message-ID | <39d7a0ae-6b71-44a9-83eb-0e46928d6be3@googlegroups.com> |
Hi,
If I have two array:
arr1 = "Bananas", "Kiwi", "Mixed nuts" and
arr2 = 8,3,1
how i can create the following structure data?
['Bananas', 8],
['Kiwi', 3],
['Mixed nuts', 1]
Any suggestions?
thanks,
Giusy
[toc] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-09-16 16:02 +0100 |
| Message-ID | <87lhc6e7a8.fsf@bsb.me.uk> |
| In reply to | #28693 |
pinapalmieri@gmail.com writes:
> If I have two array:
>
> arr1 = "Bananas", "Kiwi", "Mixed nuts" and
> arr2 = 8,3,1
>
> how i can create the following structure data?
>
> ['Bananas', 8],
> ['Kiwi', 3],
> ['Mixed nuts', 1]
You are missing lots of []s. You have
var arr1 = ["Bananas", "Kiwi", "Mixed nuts"];
var arr2 = [8, 3, 1];
and you want
[ [ 'Bananas', 8 ],
[ 'Kiwi', 3 ],
[ 'Mixed nuts', 1 ] ]
> Any suggestions?
What have you tried so far? Do you have any constraints on the
potability of the solution? Is this coursework?
Maybe
Array.prototype.zip = function (a) {
return this.map(function (e, i) {return [e, a[i]]; });
};
does what you want.
--
Ben.
[toc] | [prev] | [next] | [standalone]
| From | "Bruce M. Axtens" <bugmagnet@outlook.com> |
|---|---|
| Date | 2015-09-16 23:17 +0800 |
| Message-ID | <op.x41921e4q1fxl5@bugmagnet-a6> |
| In reply to | #28694 |
On Wed, 16 Sep 2015 23:02:55 +0800, Ben Bacarisse <ben.usenet@bsb.me.uk> wrote: > What have you tried so far? Do you have any constraints on the > potability of the solution? I'll drink to that! -- Using Opera's mail client: http://www.opera.com/mail/
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2015-09-16 16:23 +0100 |
| Message-ID | <87fv2ee6ci.fsf@bsb.me.uk> |
| In reply to | #28695 |
"Bruce M. Axtens" <bugmagnet@outlook.com> writes: > On Wed, 16 Sep 2015 23:02:55 +0800, Ben Bacarisse > <ben.usenet@bsb.me.uk> wrote: > >> What have you tried so far? Do you have any constraints on the >> potability of the solution? > > I'll drink to that! Obviously I already have! -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2015-09-16 22:00 +0200 |
| Message-ID | <3207929.zk9MQche6M@PointedEars.de> |
| In reply to | #28694 |
Ben Bacarisse wrote: > pinapalmieri@gmail.com writes: >> If I have two array: >> >> arr1 = "Bananas", "Kiwi", "Mixed nuts" and >> arr2 = 8,3,1 >> >> how i can create the following structure data? >> […] >> Any suggestions? > > What have you tried so far? Do you have any constraints on the > potability of the solution? *g* > Is this coursework? What else could it be? In my experience, people ending their postings with “Any hints?” or “Any suggestions?” are like black holes for your free time, and thus it is a waste of that precious commodity to reply to them with anything other than <http://www.catb.org/~esr/faqs/smart-questions.html>, if at all. The percentage among those people who anonymously post viathe buggy Google Groups interface is particularly high, which is also why I do not read postings injected into Usenet via that, by default. -- PointedEars FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix> Please do not cc me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web