Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Reverse elements in array, they can be integers or strings. Date: Sat, 16 May 2015 13:11:19 +0100 Organization: A noiseless patient Spider Lines: 59 Message-ID: <87wq08n2mw.fsf@bsb.me.uk> References: <2ddccd07-49e4-42c3-9ecc-27f047078f84@googlegroups.com> <87382wokfa.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="31752"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18mkG8zV9YgMYBBgR8gACfXhmrhRJKsSLI=" Cancel-Lock: sha1:iXljCfM4/ukcx7HzaSEdOrEJtQs= sha1:bE4TMNqETqO/m2QRklorMfQa8eM= X-BSB-Auth: 1.1b924c1e49e8d8016907.20150516131119BST.87wq08n2mw.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:27673 jonas.thornvall@gmail.com writes: > Den lördag 16 maj 2015 kl. 13:01:50 UTC+2 skrev Ben Bacarisse: >> jonas.thornvall@gmail.com writes: >> >> > 21 should encode to [1,10] in base eleven because 11+10. >> > But is stored in array as [01,1] >> > >> > Now i want a printout 1,10 >> >> You are still confusing numbers and their representations (or, maybe, >> you now understand but have not found a way to write about the >> distinction). Either way, it makes it impossible to communicate about >> numbers and their representations. There is a simple solution: >> console.log prints an unambiguous representation of a value. You could >> use that even if you don't fully understand the distinction it's making. >> For example, this method will distinguish between a string "[01,1]", an >> array of numbers [1,1], and an array of strings ["01","1"]. >> >> You seem to be asking how to turn [1,10] into "1,10" but that's too easy >> to be the question. > No thar is not the question, i want to reverse the array and reverse > the digits of *each element* within array on *decimal level*. At some point you will start to take people's advice. Until then I don't think you will make much headway. Show the output from console.log of the array you are starting with. Then show the output from console.log of the "thing" you want. I don't even know if you want a string or an array, and if you want an array, I don't know what type of elements it should have. The output from console.log will make it clear to other what task you are trying to perform. > I am doing arithmetic upon the elements so i know they are not stored > as characters and strings. OK. (I note, however, that in one bit of code you once posted you pointlessly converted them to strings only to immediately re-convert them back to numbers. This made me think that, at the time, you did not know which you had in the array.) > So i *assume* that the element stored at each index within array is an > integer. Since this is your program, you can know what it is. There should be no need to assume it. This makes you statement "stored in array as [01,1]" very odd. That looks like an array of two integers, both of which are 1. > Really how hard can it be to understand. And how hard is it to do what I ask? Show the console.log output for the array you have and then do the same for the string you want to print. -- Ben.