Jump to content

L8V2L

Members
  • Posts

    788
  • Joined

  • Last visited

Posts posted by L8V2L

  1. function kryptonite(){var test = 1;document.getElementById('out1').innerHTML = 'test 1';if(test==='1'){return test}document.getElementById('out1').innerHTML += 'test 2';if(test===1){return test}document.getElementById('out1').innerHTML += 'test 3';return 'dog';return 'cat';alert('Done');}/*Comparing test to string 1, number 1... Which it return "test 1" + " test 2", which it shouldn't had for test one, and it's not even under the first if statement... unless it really did just turn in test two, but concatenated with test one by +=... less check by changing test one = with +=. OH YOU TRIED TO TRICK ME!!! .... less just check one more time by just changing the test 2 += to just a =. Yep it does. So it concatenate 'test 1' with 'test 2' ... And I'm guessing if I put the last three items in a console, it will log back 'dog' and 'cat' and alert will popup with the word 'Done'.*/
  2. //How is this recursive(repeating over and over)?function power(base, exponent) {  if (exponent == 0)    return 1;  else    return base * power(base, exponent - 1);}console.log(power(2, 3));// → 8
  3. /*What's the flow here? What's the route that 24 take? When I exchange it for 2 it return null, even know at that point it see if start is greater than goal, which it isn't if goal is 2 and start is 1. Why is that?*/function findSequence(goal) {  function find(start, history) {    if (start == goal)      return history;    else if (start > goal)      return null;    else      return find(start + 5, "(" + history + " + 5)") ||             find(start * 3, "(" + history + " * 3)");  }  return find(1, "1");}print(findSequence(24));
  4. /*A stack is when the computer bring with it the memory of where it stop to back track into a code, and so it throw the last code from which cause it to backtrack on top of the code it self to remember that it stop there to go back, and once the code is done being read an computed, it take the memory of where it left off the top of the block of code and resume from that point. Is that correct? So print(chicken()+" came first."); is thrown on top of the function chicken as a bookmark, and ones it's done going through the function, it take the book mark off the top of the function and consume reading from that point?*/    function chicken() {  return egg();}function egg() {  return chicken();}print(chicken() + " came first.");//And this too:function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;//}What's the different between putting clury braces bhind this, outputing 1024. And the one underneath?return result;//} Why do result turn 2 when curly braces includ the return result in the for stament.}show(power(2, 10)); 
  5. /*A stack is when the computer bring with it the memory of where it stop to back track into a code, and so it throw the last code from which cause it to backtrack on top of the code it self to remember that it stop there to go back, and once the code is done being read an computed, it take the memory of where it left off the top of the block of code and resume from that point. Is that correct? So print(chicken()+" came first."); is thrown on top of the function chicken as a bookmark, and ones it's done going through the function, it take the book mark off the top of the function and consume reading from that point?*/    function chicken() {  return egg();}function egg() {  return chicken();}print(chicken() + " came first.");And this too:function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;//}What's the different between putting clury braces bhind this, outputing 1024. And the one underneath?return result;//} Why do result turn 2 when curly braces includ the return result in the for stament.}show(power(2, 10)); 
    
    

    Why would I want you to explain code that you can't write?

    To get filmier with such with reading a program, I may can't call back the answer that I can't seem to remember of how to put the component together. But working on reading and recognize the code when I see it, will build a database in my memory bank to which when I sit down to write the code, it'll be easier for me to remember. If not that is okay.

  6. <!DOCTYPE html><html><head><meta charset="utf-8"><title>showpower</title><script>window.onerror = function(m, u, l){alert('Javascript Error: '+m+'nURL: '+u+'nLine Number: '+l);return true;}</script><script>function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;}return result;}//end of functionwindow.onload = function(){str = '';for(var i=0 ; i<12 ; i++){str += '<b>2<sup>'+i+'</sup> = '+ power(2, i) +'</b><br/>';}document.getElementById('out1').innerHTML = str;}//end of function<p><strong>I was right than. You using str to hold an empty string, to which you add into it, even it's self with the += which is str = str +. Like I said, I understand the concept, but putting it in use is another thing. I'm working toward getting a strong foundation of this, learning the building block, really concentrate on the beginner tutorials more than any thing, so I can understand more of it to apply it. I'm still a nob... I'm still not at such at level to compose, only read... But keep challenging me! Even know... Even know it was hard to turn in something, that even I felt I should know how to do, it's good to be challenge against a opponents that you can't beat, but don't give up trying to beat.</strong></p></script></head>

    What's LT GT? I don't see it. I see open and close bracket.

  7. davej, I was working on another tutorial, which is why I came here for clarity on something, but then I saw your post:function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;//}What's the different between putting clury braces bhind this, outputing 1024. And the one underneath?return result;//} Why do result turn 2 when curly braces includ the return result in the for stament.}show(power(2, 10));

  8. function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;//}What's the different between putting clury braces bhind this, outputing 1024. And the one underneath?return result;//} Why do result turn 2 when curly braces includ the return result in the for stament.}show(power(2, 10));I wish I could type, I didn't have to look back, that I did it all from my head. I wish I could tpe it, that it didn't even take me long to do this simple problem... But I did, and it did... I don't care if that referancing is apart of programming, I want to be able to do it straight out my head. I know that comes with time... But that don't change the feeling of defeat. I'm writing this half way... or maybe a quater of the way through, depending on the time it take me to do it, that is.<p>How about writing some code? How about writing an example that accepts six words from a user and then sorts the words and then prints them on the screen?</p><!DOCTYPE html><html><head><meta charset="utf-8"><title>title</title><style>#output1{border:1px dotted #000;min-height:20px;width:300px;}</style><script>/*function btn1(){x=document.getElementById("input1").value;z=document.getElementById("output1");z.innerHTML=x;}<p>this what I had first, before I found the last link</p>function sortNum(a, B){return(a- B);}function btn1(x){y=document.input1.value.split(' ') I'm guessing Value is a reserved word. Try to search for it, but found only suggestion toward it. Seeing that it didn't work, I look back over the original code, and saw that value isn't a reserved word but is just referring to the value of the form, which is the inputif(x==0) //if sort alphabetically{y.sort();}else // if sort numerically{y.sort(sortNum);}document.input1.value='';for(i = 0; i < y.length -1; i++){{};}document.input1.value=document.input1.value+y+' ';document.input1.value+=y;[y.length -1] //I'm not advance enough to modify the last reference.*//*I'mma try this way again*///leaving it like this cause of the interest result it gives./*function btn1(){x=document.getElementById("input1").value.split('');x.sort();z=document.getElementById("output1");z.innerHTML=x;} *///Another copy of this to get right to preserved the on above it.function btn1(){x=document.getElementById("input1").value.split(' ');x.sort();z=document.getElementById("output1");z.innerHTML=x;}/*document.getElementById('input1').value='';document.input1.value='';for(i = 0; i < y.length -1; i++){{};}document.getElementById("input1").value=document.getElementById("input1").value+y+' ';document.getElementById("input1").value+=y;[y.length -1]*//*I can't do it, this is as close as I can get it to it.*/function btn1(){x=document.getElementById("input1").value.split(' ');x.sort();z=document.getElementById("output1");z.innerHTML=x;}/*I never said I can apply it, I just understood the concept about it being a empty string to be a place holder to put strings in.*/</script></head><body><h3>Please enter six words one at a time:</h3><input type="text" id="input1"/><input type="button" onclick="btn1()" value="Enter Word"/><h3>Here is the sorted words list:</h3><div id="output1"></div><!--<h3>Here is the sorted words list:</h3><div name="output1"><p>Why changing the number one cause the dotted line dash to disappear?</p></div><p>JavaScript is a language, and like all language. Their many ways to say one thing, but they don't deliver the same way. This deliverance to me is the most important part when programming with JavaScript. I know this isn't the way that you wanted me to do this, which I could have done it with out referring to anything else... But I'm just a nob at this point.</p>-></body></html>referance in order:www.w3Schools.comhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_text_gethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort2http://www.javascriptkit.com/javatutors/arraysort4.shtmlP.S: Those sunglasses faces are appose to be b's, I don't know what happen their.I think this: b ) must be what make that face... let's see. b ) Yes it does.

  9. I really can't tell if you have an understanding of this. You say you understand it now, but do you? How about writing some code? How about writing an example that accepts six words from a user and then sorts the words and then prints them on the screen?

    <!DOCTYPE html><html><head><meta charset="utf-8"><title>title</title><style>#output1{border:1px dotted #000;min-height:20px;width:300px;}</style><script></script></head><body><h3>Please enter six words one at a time:</h3><input type="text" id="input1"/><input type="button" id="btn1" value="Enter Word"/><h3>Here is the sorted words list:</h3><div id="output1"></div></body></html>

     

    function power(base, exponent){var result = 1;for(var count = 0; count < exponent; count++){result *= base;//}What's the different between putting clury braces bhind this, outputing 1024. And the one underneath?return result;//} Why do result turn 2 when curly braces includ the return result in the for stament.}show(power(2, 10));I wish I could type, I didn't have to look back, that I did it all from my head. I wish I could tpe it, that it didn't even take me long to do this simple problem... But I did, and it did... I don't care if that referancing is apart of programming, I want to be able to do it straight out my head. I know that comes with time... But that don't change the feeling of defeat. I'm writing this half way... or maybe a quater of the way through, depending on the time it take me to do it, that is.<p>How about writing some code? How about writing an example that accepts six words from a user and then sorts the words and then prints them on the screen?</p><!DOCTYPE html><html><head><meta charset="utf-8"><title>title</title><style>#output1{border:1px dotted #000;min-height:20px;width:300px;}</style><script>/*function btn1(){x=document.getElementById("input1").value;z=document.getElementById("output1");z.innerHTML=x;}<p>this what I had first, before I found the last link</p>function sortNum(a, B){return(a- B);}function btn1(x){y=document.input1.value.split(' ') I'm guessing Value is a reserved word. Try to search for it, but found only suggestion toward it. Seeing that it didn't work, I look back over the original code, and saw that value isn't a reserved word but is just referring to the value of the form, which is the inputif(x==0) //if sort alphabetically{y.sort();}else // if sort numerically{y.sort(sortNum);}document.input1.value='';for(i = 0; i < y.length -1; i++){{};}document.input1.value=document.input1.value+y+' ';document.input1.value+=y;[y.length -1] //I'm not advance enough to modify the last reference.*//*I'mma try this way again*///leaving it like this cause of the interest result it gives./*function btn1(){x=document.getElementById("input1").value.split('');x.sort();z=document.getElementById("output1");z.innerHTML=x;} *///Another copy of this to get right to preserved the on above it.function btn1(){x=document.getElementById("input1").value.split(' ');x.sort();z=document.getElementById("output1");z.innerHTML=x;}/*document.getElementById('input1').value='';document.input1.value='';for(i = 0; i < y.length -1; i++){{};}document.getElementById("input1").value=document.getElementById("input1").value+y+' ';document.getElementById("input1").value+=y;[y.length -1]*//*I can't do it, this is as close as I can get it to it.*/function btn1(){x=document.getElementById("input1").value.split(' ');x.sort();z=document.getElementById("output1");z.innerHTML=x;}/*I never said I can apply it, I just understood the concept about it being a empty string to be a place holder to put strings in.*/</script></head><body><h3>Please enter six words one at a time:</h3><input type="text" id="input1"/><input type="button" onclick="btn1()" value="Enter Word"/><h3>Here is the sorted words list:</h3><div id="output1"></div><!--<h3>Here is the sorted words list:</h3><div name="output1"><p>Why changing the number one cause the dotted line dash to disappear?</p></div><p>JavaScript is a language, and like all language. Their many ways to say one thing, but they don't deliver the same way. This deliverance to me is the most important part when programming with JavaScript. I know this isn't the way that you wanted me to do this, which I could have done it with out referring to anything else... But I'm just a nob at this point.</p>-></body></html>referance in order:www.w3Schools.comhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_text_gethttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_sort2http://www.javascriptkit.com/javatutors/arraysort4.shtmlP.S: Those sunglasses faces are appose to be b's, I don't know what happen their.I think this: b ) must be what make that face... let's see. . B)
  10. Specifically, the value "" is an empty string. It is a string of text with length 0, it is a string but has no characters. If you have a variable that is eventually going to hold a string, initializing the variable to an empty string is common.

    <script>function myFunction(){var x='',i; //Why this var x = '', i; and not just var x = '', i; I see that the code don't work.for (i=0;i<5;i++){x=x + "The number is " + i + "<br>";}document.getElementById("demo").innerHTML=x;}</script>I was reading that book Eloquent JavaScript, and I came across this again. Well after fiddling with it. I came to the conclusion of that cause x is going to hold the value of which the statement produce, so it need the right... How to put it... area to store it in, which in term is this '' or this "". And so that is why x is equal assign to that. Thanks for your help with it... I figure it's only right of me to report this to you. Cause I came to the realization of this due to the fact of reading the book you brought back in to my mind towards. Cause of your consideration, which cause me to reconsider reading it, is why I came to the clarity of this. In hindsight, your statement or better yet, explanation makes sense to me, to which the concept that it describe.Thanks justsomeguy, for just some guy, you are okay by me. Here's a cookie.(warm smile toward justsomeguy) COOKIE!!!!!!!!(crazy stare at justsomeguy) COOKIE!!!!!! COOKIE!!!!!!!!!! and milk...(a calm warm smile toward justsomeguy) ENJOY!!!!!(back to the crazy stare)
  11. Saying you want "learn Javascript" is a rather broad statement. You can spend time on many areas of Javascript usage, such as those associated with every element of HTML5, or DOM manipulation, or traditional form validation, or Javascript OOP constructs. One stage of learning a language is to learn every command in the language. Have you done that? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference http://msdn.microsoft.com/en-us/library/x85xxsf4(v=vs.90).aspx

    All jQuery syntax is legal Javascript syntax. It has to be, because the only thing the browser understands is Javascript. jQuery code just uses features that aren't common in vanilla Javascript, like closures and JSON objects being passed to functions. It's all legal Javascript though. When I first started seeing the Javascript toolkits that people were making I was initially very confused, because they all used "$". I thought that $ was some operator or class in Javascript that I had never heard of, but it's not true. $ is just a valid variable name. You could write your own code to use it.

    var $ = 'test';alert($);
    I would highly recommend not using arbitrary symbols as variable names, because they don't provide any hint on what the variable is for and they make the code look confusing. But trying to figure out those libraries and toolkits finally clicked for me when I realized that $ was just an identifier like any other function or variable name.For what it's worth, I would recommend to stay away from jQuery or any other library while you're learning. Learn vanilla Javascript, once you know that you will be able to figure out how things like jQuery work. Besides, Vanilla Javascript is fast. There's no reason to add all of the bloat of something like jQuery just to have a different way to get an element by ID or class name. jQuery just slows your code down. It might make certain things faster to write, but you pay for that in execution speed. Like you can see from that site, getting an element by ID using jQuery is about 35 times slower than using document.getElementById. Getting elements by tag name is 425 times slower using jQuery. If you're using jQuery, then your application better be highly complex and needing to work on 99% of browsers. Otherwise, use vanilla JS. Your browser already supports it.Just forget that VBScript exists. If you find a VBScript developer, make fun of them. Anything that VBScript can do, Javascript can do better. That way you're not stuck trying to do complex and important things using a language whose primary design goal was to be easy to learn.

     

    Thanks for that link. I feel somewhat vindicated about concentrating on JS rather than the multitude of libraries and frameworks.

    THANKS JUSTSOMEGUY, YOU MAY BE JUST SOME GUY, BUT YOU THE GUY! Thank you for such the detail reply, I enjoy with excitement reading what you wrote... Don't think cause your amazing... Which you are but that's not why. I want to understand, I want to know, jQuery seem awesome, but to my prospective, it's more of a child or a some what short cut way to writing JavaScript. And I don't want that, I want to learn JavaScript, if I need to use such framework, I want to use them, after I understand JavaScript foundation, and intermediate, to where I can just going into advance. So if I ever need to use such frameworks, I want to do so cause I don't really feel like typing up something I could just copy and paste... Which will be NEVER!!!! The only thing closely to copy and paste I'll do, is use it as a guide to rewrite it as of how I want it to look and act. JavaScript is a language, and as all other language program coded and non-coded, there is many ways to say one thing, but not entirely true, for how it couvade when said. So... Yeah!!!!Thanks!!!!!! Appreciate it, as always!Here something you might like to watch, very educational and insightful:
  12. because it's good practice to initialize your variables. And

    var = "";
    is invalid syntax. (nor would it make sense)

     

    It won't work if you don't initialize x. Look at the code, test the code. ---If you simply declare a variable it is given the value of undefined. This becomes a big problem if you immediately try to concatenate a string to it...

    x=x + "The number is " + i + "<br>";

     

    Specifically, the value "" is an empty string. It is a string of text with length 0, it is a string but has no characters. If you have a variable that is eventually going to hold a string, initializing the variable to an empty string is common.

    Thanks guys... justsomeguy, your explanation is more to what... I guess I could say satisfied me... I can just go with that it's necessary to do is to initializing the string a head of time with in the variable with the value... but to some instance I want to know 'WHY', not just cause that what you have to do, but why most it be done like that, why must I add the string to a variable when a variable it just use to hold information, what so important to that initialization that if I don't do it, the code it self don't work. I want to understand... I want to know JavaScript.I do appreciation all of you sharing your knowledge with me... I understand that this is what you would have done with anyone that would have ask... But it mean something more to me of which you are doing... Really, with out you, this site would only be a book with knowledge, but you are the teacher to go to when stump, I could search the web for this, but the web is both a benefit and an un-control variable of which you don't know if the information you reading are correct. I can say the same of you guys, but to see your words matching up to what I am studying are telling me your words are with truth.Codeacademy is nice but... if this site had a choice or a course of interface like codeacademy, I feel as if this site would be a lot more enjoyable... After I went through the tutorial of JavaScript two times, I found all these other resource that the tutorial did not have, your reference, and example... I could take all of this, and design a site of my own that have the component that both you, codeacademy, and htmldog are missing to truly have a site that would draw people in, not cause of the drive to learn, but cause of the enjoyment they will get from learning.But I rather improve a site that help educate me on my journey of learning... If you could are just think over it to a least hearing some of my suggestion if you want to... other wise, I'm stilling going to try to implement them using f12 interface to change the look of this site up to make it more enjoyable for me to learn, and save it as a fire to use on each page.Either way, thank you for all your help.Here something you might like to watch, very educational and insightful:
  13. jQuery is written only in Javascript. You are free to download jQuery and read through the source. Browsers only understand Javascript as a scripting language, with the exception of IE that also supports VBScript.

    But jQuery isn't writing as JavaScript is writing. I want to learn JavaScript, even know I like how jQuery look, and enjoy learning it. But I want to have JavaScript as my foundation, not a form of JavaScript which is easier to understand, but the actually language of JavaScript.Beside that question could you also explain more in detail of the responses you gave me of jQuery, even know I know... I still would like more information on your part. If not, than please responses to the repost to the question that have a little more detail above this.Thank you again, I do appreciate you taking your time out to reply to my nobs question... Wizard.. or warlock(eyes go back and forth with dramatic music playing).Also a brief info on VBscript. You don't have to, I rather not get on any other scripting language but JavaScript for now, after I'm comfortable and confident that I know JavaScript's basic and intermediate. To where I can move on to advance easy. Next language is serve side scripting PHP.
  14. what isn't working about it? It loops 5 times, each time overwriting x, then when the loop is done, displays the value of x from the final iteration. Are you expecting it to do something else?

     

    var x="", i;
    ...is the same as...
    var x="";var i;
    ...or they could have waited and declared i inside the for-loop...
    for (var i=0;i<5;i++) {

     

    Davejwhy do they have the '' in var x='', i; or just var='';?Thanks for explaining and refreshing my mind of that fact of var x=a, y=b, z=c;
  15. I don't know what else to do... Anyone have any ideals? I want to learn JavaScript, I went through this tutorial two times, and have to module on codeacademy left, but it just feel like I'm not advancing. I want to have a strong foundation of the basic, so I can understand everything else.

  16. are-you-wizard.jpg

    <!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><script>function myFunction(){var x='',i; //Why this var x = '', i; and not just var x = '', i; I see that the code don't work.for (i=0;i<5;i++){x=x + "The number is " + i + "<br>";}document.getElementById("demo").innerHTML=x;}</script></body></html>
×
×
  • Create New...