spbooks / jsninja2 Goto Github PK
View Code? Open in Web Editor NEWA repo for the code archive for JavaScript: Novice to Ninja, 2nd Edition
A repo for the code archive for JavaScript: Novice to Ninja, 2nd Edition
When adding the focus and blur event listeners then previewing the search.html, multiple alert windows keep opening. I have to just close the page because I can't go any further. Is there a way to make it so just 1 alert happens?
const form = document.forms[0];
const input = form.elements.searchInput;
//input.addEventListener('focus', () => alert('focused'), false);
//input.addEventListener('blur', () => alert('blurred'), false);
input.addEventListener('change', () => alert('changed'), false);
form.addEventListener('submit', search, false);
function search (event) {
alert('Form Submitted');
event.preventDefault();
}
they are commented out so I can keep going. This is happening in Chrome. I haven't checked Firefox.
The CodePen link to the live example for adding the "Click to Start" button does not actually show such a button. The code does not match what the chapter says needs to be added.
Using a downloaded copy of the archive's main.js file, gets the following error:
main.js:78 Uncaught TypeError: Cannot read property 'addEventListener' of null
Jen
I think that there is a problem with the indices in page 122.
for(let i=1 ; j<13 ; i++){
for(let i=1 ; j<13 ; j++){
console.log(`${j} multiplied by ${i} is ${i*j}`);
}
}
I think that the correct example should be the one below, or maybe I am missing something.
for(let i=1 ; i<13 ; i++){
for(let j=1 ; j<13 ; j++){
console.log(`${j} multiplied by ${i} is ${i*j}`);
}
}
When trying to do the example on pages 523-527, click either the numbers or chuck buttons and an error is returned: net::ERR_CONNECTION_RESET. Is there updated URLs or code?
I've finished chapter 15 and am trying to run the build. When I run the command npm run build in the quiz directory, I get the following errors:
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: webpack --progress --colors --profile
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I looked in the dist folder and there is not a bundle.min.js file. What is happening and how do I fix it?
Just finished translating the Bootstrap repo for my native language. So Im free.
top of p134
There seems to be a line missing before the line
<< 'hello'
On page 534, the exercise needs access to
http://spbooks.github.io/questions.json
but this gives a 404.
The answer I was given that the code is in the code archive isn't helpful since it needs to be online somewhere to use JSON fetch().
There seems to be issues with the link for the background image.
The link below says they are closing down. Is there an updated link?
https://cdn.rawgit.com/alexmwalker/6acbe9040d9fe65e9fd758a25e1b2a5/raw/9c8131eb2ccc1e3839a5a114cb16b5dc74daf04/dojo.svg
top of p236
wonderWoman.classList.toggle('sport'); // will add the
โฅ 'hero' class back
<< true
Doesn't that add the class sport?
a support ticket suggests the following correction to page 255 in JavaScript Novice to Ninja, 2nd Edition:
==== Correction ====
wonderWoman.classList.toggle('hero'); // will remove the
โฅ 'hero' class
<< false
wonderWoman.classList.toggle('sport'); // will add the
โฅ 'hero' class back
<< true
"sport" needs to be changed to "hero"
bottom of p201
Notice that the backslash character needs to be used twice in the last example.
Unless I'm missing something there are no backslashes in the last example!!
The line of code that reads
** NEW HIGH SCORE! **');
should be
view.render(view.info,'** NEW HIGH SCORE! **');
I think that there is a small mistake on pg 168
const ironMan = ( name: name, realName: realName };
should be
const ironMan = { name: name, realName: realName };
Please let me know if this the right way to point mistakes or if I should email you.
bottom of p44 it says
Variables that start with an underscore, generally refer to private properties and
methods, so it's best to not follow this convention for your own variable names.
The $ character is also used by the popular jQuery library, so using this in your
variable names may also cause problems.
This is a repeat of what is in an earlier pull-out. Does it really belong here too?
On page 470, in the example for adding methods to the Number prototype, the code to add the functions is correct:
Number.prototype.isEven = function() { return this%2 === 0; } Number.prototype.isOdd = function() { return this%2 === 1; }
However the code in the next block showing how to invoke the newly added functions on numbers will throw a syntax error (tested in JSBin and node console via Terminal). The book has:
42.isEven() << true 765234.isOdd() << false
Since the method is being called on an integer, there should be two dots:
42..isEven() << true 765234..isOdd() << false
Anyhow, loving the book, but this threw me off so I wanted to post an issue here for future revisions/releases, or in case this trips up anyone else.
Also, if there's a better place to post this, let me know and I'll be happy to revise or resubmit.
In Chapter 2, one of the code blocks reads:
typeof answer;
<< "number"
A reader pointed out that everywhere else it's << 'number'
.
https://www.sitepoint.com/community/t/double-and-single-quotes/422615
bottom of p40 (last but 3 line) it says "But then a is defined inside the local block using let."
Is it? It looks like it was defined using const.
it('should throw an exception for non-numerical data', ()=> { expect(factorsOf('twelve').toThrow(); });
is incorrect.
It should be:
it('should throw an axception for non-numerical data', () => { expect( () => factorsOf('twelve').toThrow()); });
Hello. there is an error in the exemple of use of reduce() in Array.
[1,2,3,4,5].reduce( (acc,val) => prev + val ); << 15
I think it's better with
[1,2,3,4,5].reduce( (acc,val) => acc + val ); << 15
JS novice to Ninja >>> node
function mean(array, callback) {
... if (callback) {
..... array.map(callback);
..... }
...
... const total = array.reduce((a, b) => a + b);
... return total / array.length;
... }
undefined
mean([8, 4, 7, 9], x => x*2);
7
mean([8, 4, 7, 9]);
7
In Chapter 12 Ninja Project, after adding fetch, the answers on the quiz are incorrect. I'm no master on superheros so I don't know the real answers but the three you can choose from do not contain the name that is given when you get the answer wrong. I have included some screen shots to show you what is happening. I even copied the code from the file here and it does the same thing.
From page 162 and so on, the author refers to a function called play(), when he actually meant start().
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.