Javascript exercises (1)

Source: Internet
Author: User

081223

Forum discussion address:

Http://topic.csdn.net/u/20081223/10/dc553644-1580-46fb-8317-99d19909c574.html? Seed = 293528674

  1. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  3. <Head>
  4. <Title> JavaScript syntax learning </title>
  5. <SCRIPT type = "text/JavaScript">
  6. Function f (){
  7. VaR STR = '1, 2, 3, 4 ';
  8. VaR str1 = '1, 4, 5, 6 ';
  9. STR = ',' + STR + ',';
  10. For (VAR I = 0; I <str1.length; I ++)
  11. {
  12. VaR c = str1.charat (I); // obtain char based on position
  13. If (C! = ',')
  14. {
  15. If (Str. indexof (',' + C + ',') <0) // if not found, insert C,
  16. {
  17. STR + = C + ',';
  18. }
  19. Else
  20. {
  21. Strstr = Str. Replace (',' + C + ','); // If yes, replace C,
  22. }
  23. }
  24. }
  25. Strstr = Str. substring (1, str. Length-1); // remove the last number.
  26. Alert (STR );
  27. }
  28. Document. onclick = function (){
  29. F ();
  30. }
  31. </SCRIPT>
  32. </Head>
  33. <Body>
  34. </Body>
  35. </Html>

End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.