Web Developer Tools
  • Home
  • Web Developer Tools
    • BreadCrumbs
    • Cheat Sheets >
      • HTML5 Cheat Sheets
      • CSS Cheat Sheets
      • jQuery Cheat Sheets
    • Cloud Storage
    • Domaining >
      • Domain Name Finders
      • Domain Name Valuators
      • Expired Domain Names
    • Drag-and-Drop Site Builders >
      • Weebly vs Wix
    • Image Tools
    • Internet Tools
    • Web Developer Courses >
      • HTML5
      • Programming >
        • JavaScript
      • Top 5 Sites To Learn HTML and CSS
      • Top 5 Sites As Resources To Learn JavaScript
    • Online Generators >
      • Google URL Shortner
      • CSS Generators
      • CSS3 Generators
      • Favicon Generators
      • QR Code Generators
      • Sitemap Generators
      • Thumbnail Generators
    • Poll & Survey Creators
    • Real-time Code Editors >
      • CSS Editor
    • Sites Like DeveloperNotes
    • Web Development Under 599 $
  • SEO
    • Free SERP Position Checker
    • Check Google PageRank
    • Search Engine Optimization Videos
    • Keyword Research for SEO
    • How to Use Social Bookmarking Sites To Increase SEO
    • Social Bookmarking Sites for SEO
    • Website SEO Evaluations
    • SEO Evaluators >
      • Site Compression Tools
    • Social Sharing Toolbars
    • SEO Infographics
    • Google's Algorithm Change History
  • SEM
  • Directory
    • Submit Your URL
    • Business Listings >
      • Arts and Entertainment
      • Automotive
      • Business
      • Business Services
      • Finance
      • Food and Related Products
      • Internet
      • Publishing and Printing
      • Real Estate
      • Search Engine Optimization
      • Small Business
      • Web Development
      • Web Site Design
    • Best Free Websites to Submit URLs For SEO >
      • Quick Submit to Top Search Engines
      • Bulk Directory Submitters
      • URL Submissions for SEO
    • The 9 Best Paid URL Submission Directories
    • D4go Search Engine >
      • Index Your Website
  • Extras
    • Fun Google Search Results >
      • Experimental SEO Project >
        • Experimental SEO Page
    • Fun Statistics
    • Infographics >
      • How to Create Infographics
    • Share Your Knowledge
    • Technology
    • 70+ Free iPhone Style Icons
    • Google Play Services
    • Weebly Login Issues
    • Web Developer Twitter Feeds
  • About DeveloperNotes
    • Privacy Policy
    • Sitemap
    • Contact
  • Sites I Recommend
 

JavaScript - Syntax Examples

 

JavaScript - Switch Statement


Switch Statement Syntax Example:
switch(expression) {
    case n:
        code block
        break;
    case n:
        code block
        break;
    default:
        default code block
}
Switch Statement Full Example:
// User enters their favorite color in the following prompt...
var color = prompt("What's your favorite primary color?","Type your favorite color here");

// The switch statement...
switch(color) {
  case 'red':
    console.log("Red's a good color!");
    break;
  case 'blue':
    console.log("That's my favorite color, too!");
    break;
  case 'yellow':
      console.log("Yellow's a good color!");
      break;
 
  default:
    console.log("I don't think that's a primary color!");
}

JavaScript - Loops

For Loop Syntax Example:
for ([var i = startValue];[i < endValue]; [i+=stepValue]) {
 // Your code here 
}
For Loop Full Example:
var i;
for (i = 10; i >= 1; i--) {
   console.log(i); 
// Prints the numbers from 10 to 1 
}

Powered by Create your own unique website with customizable templates.
ra-4fdfee6e1f853526