Jump to content

L8V2L thoughts on JavaScript...


L8V2L

Recommended Posts

for (i = 4; i <= 6; i++)

Then the code will have to be
for(var i = 4; i < demo1.length-15; 1++){demo1[i].innerHTML="Hello World!";}//assuming there are only 21 p elements/nodes.
Edited by L8V2L
Link to comment
Share on other sites

<!DOCTYPE html><html><body><p>Click the button to loop through a block of code five times.</p><button onclick="myFunction()">Try it</button><p id="demo"></p>/*result:The number is 0The number is 0 <-- This should not be zero... a least to my logic.The number is 1The number is 2The number is 3The number is 4*/<script>function myFunction() {    var text = "";    for (var i = 0, e = 0; i < 5; i=e++) {    //i is zero, then, it should be one next time around.        text += "The number is " + i + "<br>";    }    document.getElementById("demo").innerHTML = text;}//i is 0, (i = e++) == (0 == 0),eval(i = e++); i = 0, e = 1; i = 1, e = 2; </script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

Then the code will have to be

If you want to loop over 4 to 6, then loop over 4 to 6. That is far less confusing than looping from 4 to length - 15. If I saw that code I would be wondering what the significance of 15 is, why 15? If you want 4 through 6 then just do 4 through 6. You can also access each element individually without a loop.

This should not be zero... a least to my logic.

Look at the Wikipedia article. Pay attention to the difference between pre and post increment. After that for loop ends, what will the values of i and e be?
Link to comment
Share on other sites

If you want to loop over 4 to 6, then loop over 4 to 6. That is far less confusing than looping from 4 to length - 15. If I saw that code I would be wondering what the significance of 15 is, why 15? If you want 4 through 6 then just do 4 through 6. You can also access each element individually without a loop.Look at the Wikipedia article. Pay attention to the difference between pre and post increment. After that for loop ends, what will the values of i and e be?

Huh? How do I just go with 4 through 6? That code I present to you is the way I can only see how to do it. If you could show me what you mean...
Link to comment
Share on other sites

Let me give you a piece of advice. You like to scream in all caps about how you want more online documentation and guides. You say that you have already read a lot of online documentation and guides. You obviously don't understand very well how this stuff works, so I would suggest that the online documentation and guides are not working for you nearly as well as you think they are. I would suggest it is time for a book that contains exercises that you can practice with. What you are doing now is not working well, you should change it up. Something like MDN is not there to teach people how to write Javascript, it is a reference for people who already know Javascript where they can look up the details about how to use a specific thing. I do not consider that a learning resource, it is documentation for existing developers. Documentation isn't there to teach you how to program, it is only a reference. Look at the reference for a for loop, for example:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/forThat is not teaching you what a for loop is, why you might want to use it, where to use a for loop instead of a while loop, do loop, etc, any of that. It is not teaching theory, it is describing how to use it. The intended audience for that is not someone who doesn't know how to program, it is someone who is familiar with looping in other languages and wants to know how to do it in Javascript.An analogy is a dictionary. The purpose of an English dictionary is not to teach people how to speak English, it is a reference for existing English speakers to look up words they don't know. That's what documentation is. If someone wants to learn how to speak English, they take classes.Pay attention to the quote in my signature from the man who invented C++:

Know the foundations of computer science: algorithms, machine architectures, data structures, etc. Don't just blindly copy techniques from application to application. Know what you are doing, that it works, and why it works. Don't think you know what the industry will be in five years time or what you'll be doing then, so gather a portfolio of general and useful skills. Try to write better, more principled code. Work to make "programming" more of a professional activity and less of a low-level "hacking" activity (programming is also a craft, but not just a craft). Learn from the classics in the field and the better advanced textbooks; don't be satisfied with the easily digested "how to" guides and online documentation - it's shallow.-- Bjarne Stroustrup

He is the computer science chair at Texas A&M University. You can go there and learn directly from someone who created one of the most commonly used languages today. If you don't want to take our advice, take his - online documentation is shallow.
  • Like 1
Link to comment
Share on other sites

=js:0]<!DOCTYPE html><html><body><p>Finding the largest number.</p><p id="demo"></p><script>function findMax() {  var max = 0;  for(var i = 0; i < arguments.length; i++) {    if (arguments[i] > max) max = arguments[i];/*are you telling me, because this is a number, every time i increment, it's going to increment to the highest integer in the arguments object length property?... I hate that I have to ask this, I just want to be able to look at it, and understand it... (GIVE ME DOCUMENT, GUIDE, MANUEL YOU DAM DIRTY APES!!!!!)<~~~~ignore this.*/  }  return max;} document.getElementById("demo").innerHTML = findMax(4,56,6);</script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

Let me give you a piece of advice. You like to scream in all caps about how you want more online documentation and guides. You say that you have already read a lot of online documentation and guides. You obviously don't understand very well how this stuff works, so I would suggest that the online documentation and guides are not working for you nearly as well as you think they are. I would suggest it is time for a book that contains exercises that you can practice with. What you are doing now is not working well, you should change it up. Something like MDN is not there to teach people how to write Javascript, it is a reference for people who already know Javascript where they can look up the details about how to use a specific thing. I do not consider that a learning resource, it is documentation for existing developers. Documentation isn't there to teach you how to program, it is only a reference. Look at the reference for a for loop, for example:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/forThat is not teaching you what a for loop is, why you might want to use it, where to use a for loop instead of a while loop, do loop, etc, any of that. It is not teaching theory, it is describing how to use it. The intended audience for that is not someone who doesn't know how to program, it is someone who is familiar with looping in other languages and wants to know how to do it in Javascript.An analogy is a dictionary. The purpose of an English dictionary is not to teach people how to speak English, it is a reference for existing English speakers to look up words they don't know. That's what documentation is. If someone wants to learn how to speak English, they take classes.Pay attention to the quote in my signature from the man who invented C++: He is the computer science chair at Texas A&M University. You can go there and learn directly from someone who created one of the most commonly used languages today. If you don't want to take our advice, take his - online documentation is shallow.

.... WOW! That always been there? That's like a laugh in my face... that is, that it always been there...... What book should I read, their so many books, and the author love to talk side stuff a lot, and not just straight (here, this is that, and that is this, and this would be desirable to be use as that, and so on.) Edited by L8V2L
Link to comment
Share on other sites

for (i = 4; i <= 6; i++)

I UNDERSTAND!!! After reading what you type up(which I do extremely appreciate you taking the time to bye the way) I look at the code to actually look at it for a second, and it came to me as, I put i in the demo1, and the number that is i will correspond with the placement of that p element tag!!!!! So simple put:
<!DOCTYPE html><html><body><h1>My First JavaScript</h1><p>JavaScript can change the content of an HTML element:</p><button type="button" onclick="myFunction()">Click Me!</button><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><p class="demo1">This is a demonstration.</p><script>function myFunction() {var demo1 = document.getElementsByClassName("demo1")for(i = 4; i <= 6; i++){demo1[i].innerHTML="Hello World!";}}/*This had a little something to do with it to in passing that is:for (var i = 0; i < 9; i++) {   n += i;   myfunc(n);}*//*Me: JavaScript... JavaScript: Yes, my child?Me: There so much to learn.JavaScript: There is my son there is.Me: But the more I learn... the more I see I can do... the more powerful I become.JavaScript: Yes, as it is natural to happen, it is the order of nature.Me: ... I want to learn more, I want to learn more JavaScript.JavaScript: then go search my son... you remind me so much of my son child.Me: Really?!JavaScript: Yes, his name is Luke, like him, the force is strong with in you.Me: Wow!JavaScript: Now go young one, and let the force consume you.Me: YES JAVASCRIPT! I will!*/ </script></body></html>
Edited by L8V2L
Link to comment
Share on other sites

What book should I read

I've already suggested several books to you. Look in your old threads. I'm not here to do research for you, if you want to know what the most respected books about Javascript are then do the research yourself.
Link to comment
Share on other sites

I've already suggested several books to you. Look in your old threads. I'm not here to do research for you, if you want to know what the most respected books about Javascript are then do the research yourself.

:sorry:

Link to comment
Share on other sites

From Nodejs.org:

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

It's a scripting language that employs Javascript syntax to build networking applications.

Link to comment
Share on other sites

Javascript is a glue. It's becoming more popular as more than just a browser scripting language but it's always been a glue. You can't JUST lean javascript and do everything you want to do. Learn it along-side your server language (###### if it's nodejs more power to you) and your client language (probably html). But in technology there isn't just one language. You'l end up learning many languages to accomplish your goals.

Link to comment
Share on other sites

<!DOCTYPE html><html><body><h1 id="intro">My First Page</h1><p id="demo">Hello World!</p><script>var myText = document.getElementById("intro").childNodes[0].nodeValue;var innerhtml = childNodes[0].nodeValue;//<--How to make thisdocument.getElementById("demo").innerhtml = myText;//<--work?</script></body></html>
Link to comment
Share on other sites

Javascript is a glue. It's becoming more popular as more than just a browser scripting language but it's always been a glue. You can't JUST lean javascript and do everything you want to do. Learn it along-side your server language (###### if it's nodejs more power to you) and your client language (probably html). But in technology there isn't just one language. You'l end up learning many languages to accomplish your goals.

What do you mean in this --> (###### if it's nodejs more power to you), with the ######... Might be a curse word... The s curse word...Oh, I know... there is many different(I like to call them, programming interface language since they are like... a form for people who want to program... but not... binary programming...)programming language out there, from the beginning I was thinking of learning PHP with JavaScript, like that was the plan... but then I became a little more knowledge of the language, and the wizardry world of programming... I still might, but there are other programming language, that can act as an api for JavaScript!!! So I might head in that route.What is a node(I ask such question for more clarity. Everything by W3C standard is consider a node; node element, node attribute, node value, node text, etc)... What is a node?As I walk away with eyes full of rages, speaking under my breath...Me: JavaScript is more than a glue.Cut to black screenMe: I'll show you, I'll show you all. Edited by L8V2L
Link to comment
Share on other sites

From Nodejs.org:It's a scripting language that employs Javascript syntax to build networking applications.

Are you a sonic fan? I'm a sonic fan! We are sonic fans. :)
Link to comment
Share on other sites

What do you mean in this --> (###### if it's nodejs more power to you), with the ######... Might be a curse word... The s curse word...Oh, I know... there is many different(I like to call them, programming interface language since they are like... a form for people who want to program... but not... binary programming...)programming language out there, from the beginning I was thinking of learning PHP with JavaScript, like that was the plan... but then I became a little more knowledge of the language, and the wizardry world of programming... I still might, but there are other programming language, that can act as an api for JavaScript!!! So I might head in that route.What is a node(I ask such question for more clarity. Everything by W3C standard is consider a node; node element, node attribute, node value, node text, etc)... What is a node?As I walk away with eyes full of rages, speaking under my breath...Me: JavaScript is more than a glue.Cut to black screenMe: I'll show you, I'll show you all.

 

The term "node" refers to an element in a data structure that all programming languages can implement. It's called a tree, a node is any part of the tree that contains data. Here's the Wikipedia article about trees: http://en.wikipedia.org/wiki/Tree_%28data_structure%29

Link to comment
Share on other sites

<!DOCTYPE html><html><head><script>function startTime() {    var today=new Date();    var h=today.getHours();    var m=today.getMinutes();    var s=today.getSeconds();    m = checkTime(m);    s = checkTime(s);    document.getElementById('txt').innerHTML = h+":"+m+":"+s;    var t = setTimeout(function(){startTime()},500);/*How is window.setTimeout() method acting as setInterval() method?*/}function checkTime(i) {    if (i<10) {i = "0" + i};    return i;}</script></head><body onload="startTime()">//Is window.onload causing it to act as a setInterval() window method?<div id="txt"></div></body></html>
Edited by L8V2L
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...