Chapter 6 is flawed


#1

I do not understand why chapter six stops before the program is working properly.

The name of the array "hits" is misleading. I on my part would expect an array of numbers marking every spot where there is a correct occurrence of the name.

My suggestion to improve this chapter would be to ether do the task after learning about while loops or use a boolean variable before the second loop to check whether the hit is still valid every step of the way.

Coding a program that doesn't solve the problem is simply bad practice.


#2

paste-in following code....then submit....
you will get an reference-error..no problem !!
analyze the console-output and the code provided to get a better insight...
the \n is new-line
the \t is a tab

var text = "alex is the alex";
var myName = "alex";
var hits = [];
console.log("\n\nThe variable myName =" + myName);
console.log(
"Taking the first-letter of myName[0] = " + myName[0] );
console.log(
"Taking the 2nd -letter of myName[1] = " + myName[1] );
console.log(
"Taking the 3rd -letter of myName[2] = " + myName[2] );
console.log(
"Taking the 4th -letter of myName[3] = " + myName[3] );

console.log("\n\nLooping over the whole of text::");
for (var i = 0; i < text.length; i++) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">"
);
}

console.log("\n\nFinding the position's"+
"\n\tof the 1st-myName-letter in text");
for (var i = 0; i < text.length; i++) {
if ( text[i] === myName[0] ) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">");
}
}

console.log("\n\n-Now find-pos AND "+
"\n-from pos, gather letters"+
"\n-untill pos+myName.length");

console.log('===================');
for (var i = 0; i < text.length; i++) {
if ( text[i] === myName[0] ) {
console.log(
"i=",i," letter of text at pos",i," is "+"<"+text[i]+">");

for(var j=i; j<(myName.length+i); j++){
console.log(
">j=",j," letter of text at pos",j," is "+"<"+text[j]+">");
hits.push(text[j]);
}

console.log('===================');
}
}
console.log( hits );
error

References:

google search
javascript push array site:developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push

javascript push array site:stackoverflow.com

www.crockford.com
http://javascript.crockford.com/survey.html
http://javascript.crockford.com/code.html


#3

I swear to God, Leonhard, I never understand what the hell you're trying to say...maybe some plain English, please??

Seriously, when you reply to someone it's a whole long post but not clear at all what you mean.


#4

3 things:
1. im no tech wizard
2. leonard didnt really explain
3. BUT what (i think) he DID do was give us a step by step script of what the exercise was doing behind the scenes...(a copy of which is going in my toolbox)

its not clear, but keep doin what you are doing, sir.


#5

Oh, forgive me, thought he was offering an explanation -- you know, in response to the question about a problem....

Carry on, then. Lord knows anything goes in an internet forum!


#6

Well, since MTF ABUSED HIS MODERATOR PRIVILEGES BY CENSORING MY OWN THREAD ON THIS MATTER AFTER TAKING POTSHOTS AT ME WITH UNWARRANTED ACCUSATIONS (viz., to complain is to denigrate, which is so obviously false), let me agree with you here:

1) Right at the outset, in 1/7, the "text" variable (in the pre-populated code editor) is missing the "var" declaration required of variables in Javascript. To be wrong on such a basic matter is a bit like misspelling your own name! To continue to ignore it and not correct it is puzzling and speaks ill of the "commitment" MTF was bloviating about in my censored thread making just these complaints.

2) After spending 2/7, 3/7, and 4/7 on a review of basic looping and array concepts already thoroughly covered, the instruction suddenly jumps in 5/7 to new territory with .push() and two loops interacting at once -- lots of brand-new moving parts all of a sudden but without much of an explanation!! While spending 2/7 through 4/7 belaboring the obvious, belaboring old basic material, 5/7 just suddenly throws a bunch of new things all at once without much background. This is unhelpful pedagogy: again, too many new concepts/practices all at once interacting with one another...just look at all the cries for help -- the common denominator is that they can't make sense of all the various moving parts! Couple this with a paucity of explanation and the result is DISASTER.

3) Generally, code is accepted that should not work; in 5/7, code that doesn't actually solve the problem is ignored and the student passed along to 6/7 under erroneous auspices. While I suppose there are technical reasons involved (I've noticed this on occasion with other lessons), it's still not useful to the complete beginners Code Academy purports to help.

4) Finally, more generally -- throughout the lessons so far -- text strings not exactly like what the instruction has expected have been rejected, causing unnecessary confusion...I'm talking about the instruction looking for "My name is Batman" but if the user writes instead "I'm the Queen of England!" -- which serves the same pedagogical function -- there's an error...at first I couldn't figure out what was going on until finally having to dumb-down myself! This oversight in lesson planning/design has wasted quite a bit of time because I was hunting for coding errors on my part, not imagining careless interface issues instead.

Now NONE OF THIS CRITICISM SHOULD BE TAKEN TO IMPLY ANYTHING personally derogatory about the course creators or Code Academy as an institution -- as was alleged so wantonly by MTF -- but where the substance of my remarks are concerned, well, "if the shoe fits...," as they say, "wear it!"

Do WordPress, Drupal, or Linux users get accused of personal attacks on volunteer-contributors when they complain about bugs and bad UX?? It's unfortunate I have to put forth such a disclaimer in what should be adult company but there it is: I am and have been only criticizing design choices, however colorfully, and not the good intentions of Academy principals, contributors, or even "mere" users. It's because I care very, very much about the experience offered that I speak so strongly!