-
-
Notifications
You must be signed in to change notification settings - Fork 0
Listing4-2.js doesn't work #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The code works OK if you iterate over headers[0] rather than headers:
|
Thanks for your feedback. I've just tried the code direct from GitHub and it works ok for me. Here is what I did:
Output:
Is this how you run the code? Maybe you have a different version of Node.js? I have version 10.15.2. Also, which operating system are you running on? Please open a terminal and run |
Hi Ashley,
I found the issue. I originally copied the listing from the the book, and
there's a discrepancy between that version and the listing in GH (which
works OK for me).
At line 12 in the book the return statement wraps the result in an array
whereas the GH version doesn't. See attachment.
Regards,
David
…On Mon, 9 Sep 2019 at 22:16, Ashley Davis ***@***.***> wrote:
I've just tried the code direct from GitHub and it works ok for me.
Here is what I did:
git clone https://github.com/Data-Wrangling-with-JavaScript/Chapter-4.git
cd Chapter-4
npm install
node listing-4.2.js
Output:
> node listing-4.2.js
[ { Mag: '9.5',
Location: ' Bio-Bio, Chile',
'Alternative Name': 'Valdivia Earthquake',
'Date (UTC)': '1960-05-22',
'Time (UTC)': '19:11',
Latitude: '38.14°S',
Longitude: '73.41°W',
References: 'Kanamori & Anderson, 1975' },
{ Mag: '9.2',
Location: ' Southern Alaska',
'Alternative Name':
'1964 Great Alaska Earthquake, Prince William Sound Earthquake, Good Friday Earthquake',
'Date (UTC)': '1964-03-28',
'Time (UTC)': '03:36',
Latitude: '60.91°N',
Longitude: '147.34°W',
References: 'Kanamori & Anderson, 1975' },
{ Mag: '9.1',
Location: ' Off the West Coast of Northern Sumatra',
'Alternative Name':
'Sumatra-Andaman Islands Earthquake, 2004 Sumatra Earthquake and Tsunami, Indian Ocean Earthquake',
'Date (UTC)': '2004-12-26',
'Time (UTC)': '00:58',
Latitude: '3.30°N',
Longitude: '95.98°E',
References: 'Duputel et al., 2012' },
{ Mag: '9.1',
Location: ' Near the East Coast of Honshu, Japan',
'Alternative Name': 'Tohoku Earthquake',
'Date (UTC)': '2011-03-11',
'Time (UTC)': '05:46',
Latitude: '38.30°N',
Longitude: '142.37°E',
References: 'Duputel et al., 2012' },
...
Is this how you run the code?
Maybe you have a different version of Node.js?
I have version 10.15.2.
Please open a terminal and run node --version and tell me which version
you are using. If you can tell me that I'll be able to try the code with
that version as well.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1?email_source=notifications&email_token=AC4JUXTYFFBC4RCNGRSCUDTQI24KPA5CNFSM4IUYOIIKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6JCB6Q#issuecomment-529670394>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC4JUXRV7NKZBHCYS5POKYLQI24KPANCNFSM4IUYOIIA>
.
|
Ok thanks for letting me know. Hopefully at some point we'll get the book updated. For the moment please use GitHub for the latest code examples! If you spot other problems please report them here. |
Also if you haven't already, please follow me on Twitter for updates on my new book: https://twitter.com/ashleydavis75 |
The following line:
if (fieldName.trim().length > 0) {
has this error:
TypeError: fieldName.trim is not a function
The text was updated successfully, but these errors were encountered: