Jump to content

davej

Moderator
  • Posts

    3,988
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by davej

  1. If you would carefully indent your code you might see your problem.
  2. Your first while loop seems to be missing an opening curly brace. Have you tried single-stepping through your code? That is a good way to find logic errors.
  3. Since you seem to want to learn OOP Javascript maybe you should read through this... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript
  4. If the html file is... C:\Phaser\phaser-2.4.4\DownloadExamples\phaser-examples-master\examples\arcade-physics\asteroid-movement\asteroids-movement.html and the Javascript file is... C:\Phaser\phaser-2.4.4\DownloadExamples\phaser-examples-master\examples\lib\Phaser.js then this should work... <script src="..\..\lib\Phaser.js"></script> or this... <script src=".\..\..\lib\Phaser.js"></script>
  5. You specify the path from the calling file to the target file. If both files are in the same folder then no path beyond the filename is necessary. https://www.google.com/?gws_rd=ssl#q=relative+path
  6. Up in the <head> section of the page you should find a <style> block. Inside the style block you can create styles. css styles are used to assign colors and to adjust the appearance of the items on the page. You should look at the css tutorial... http://www.w3schools.com/css/default.asp
  7. Yes, I too am curious. Where are these questions coming from and what tutorials have you looked at? http://lmgtfy.com/?q=javascript+tutorial
  8. Are you having some problem with this? The following seems to work... <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>title</title> <style> </style> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c); return true; } </script> </head> <body> <div id="out"> </div> <script> 'use strict'; var mystr = "clarissaeiou"; function someStr(str){ var i; var vLent = str.length; var cntArr = 0; var ch; for (i=0; i<vLent; i++){ ch = str.charAt(i).toUpperCase(); if ((ch == 'A') || (ch == 'E') || (ch == 'I') || (ch == 'O') || (ch == 'U')) { cntArr++; } } return cntArr; }//end of func document.getElementById('out').innerHTML = 'Number of vowels in ['+ mystr +'] = ' + someStr(mystr); </script> </body> </html>
  9. Have you looked at the tutorial? http://www.w3schools.com/js/default.asp The obvious approach would be to step through the string and accumulate totals. var str = "zquiabcdefghijklmnopqrstuvwxyzzzzui"; function countVowels(str){ var i; var len = str.length; var vowel_cnt = 0; var ch; for(i=0 ; i<len ; i++){ ch = str.charAt(i).toUpperCase(); if ((ch == 'A')||(ch == 'E')||(ch == 'I')||(ch == 'O')||(ch == 'U')){ vowel_cnt++; } }//end for return vowel_cnt; }//end of function
  10. You might look at... http://www.w3schools.com/cssref/pr_text_white-space.asp For other issues you probably need to use media queries with a min and max on each... http://www.w3schools.com/cssref/css3_pr_mediaquery.asp
  11. How much data? How likely is the average user to want this data?
  12. Documentation of what? There are color pickers available, such as... http://www.w3schools.com/tags/ref_colorpicker.asp
  13. Do you think so? Of course it is just semantics, but a webpage is a collection of routines. Is it one program or many?
  14. It's simply hexadecimal RGB and can be in the format 0 to F or 00 to FF for each color. http://www.w3schools.com/cssref/css_colors_legal.asp
  15. As you can see, your problem description wasn't very clear to those of us who responded. And you don't really write a "program" in Javascript, you write a collection of functions and event handlers, which interact with a particular set of page elements. And you did not really define the desired user interface or provide enough test cases. We do have a Javascript tutorial and reference that you might look at as a refresher... http://www.w3schools.com/js/default.asp http://www.w3schools.com/jsref/default.asp
  16. All you need to do is look at substring(i,j) and translate the values if they are negative. http://www.w3schools.com/jsref/jsref_substring.asp Perhaps something like... String.prototype.supersubstring = function(i,j){ var len = this.length; while(i<0){ i = len + i; } while(j<0){ j = len + j; } return this.substring(i,j); }; --edited jan 10, 1:55pm cdt
  17. This would be much simpler if you actually provided an example of what you want this function to do. You seemed to do this in your first post above, but now I'm not sure.
  18. Again, your question is oddly worded. Are you saying that you want to supply three values to a function and receive the "middle" value back? function middle(a,b,c){ if ((a > b && a < c)||(a > c && a < ){ return a; }else if ((b > a && b < c)||(b > c && b < a)){ return b; }else if ((c > a && c < ||(c > b && c < a)){ return c; }else{ return -999; // if a = b or a = c or b = c } }//end of function
  19. Three given values? Why not use an exhaustive if-then-else construct? Your question is oddly worded because you might also be implying the arithmetic average which is 45.45.
  20. You should buy a textbook or perhaps two, because there is a considerable difference in the way programs are written in each of these languages. http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Dstripbooks&field-keywords=c&rh=n%3A283155%2Ck%3Ac http://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Dstripbooks&field-keywords=c%2B%2B
  21. What the heck are you talking about? It looks like you are describing SQL database queries. Have you looked at these tutorials? http://www.w3schools.com/sql/default.asp http://www.w3schools.com/php/php_mysql_intro.asp
  22. See... http://www.stroustrup.com/compilers.html
  23. Best in what way? Best for what language?
  24. I would insert the following block above your current script block... <script> window.onerror = function(a,b,c,d){ alert('Javascript Error: '+a+'\nURL: '+b+'\nLine Number: '+c+' Col Number: '+d); return true; } </script> And add 'use strict'; to the first line of your script block.
×
×
  • Create New...