Editing Switch vs. If + else This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script type="text/javascript"> var n = 100, c = 'a', s = 'string test'; </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code switch (n) { case 10: break; case 20: break; case 30: break; case 40: break; case 50: break; case 60: break; case 70: break; case 80: break; case 90: break; case 100: break; }; Test 2 Title Async (check if this is an asynchronous test) Code if (n === 10) { } else if (n === 20) { } else if (n === 30) { } else if (n === 40) { } else if (n === 50) { } else if (n === 60) { } else if (n === 70) { } else if (n === 80) { } else if (n === 90) { } else if (n === 100) { }; Test 3 Title Async (check if this is an asynchronous test) Code switch (c) { case 'j': break; case 'i': break; case 'h': break; case 'g': break; case 'f': break; case 'e': break; case 'd': break; case 'c': break; case 'b': break; case 'a': break; }; Test 4 Title Async (check if this is an asynchronous test) Code if (c === 'j') { } else if (c === 'i') { } else if (c === 'h') { } else if (c === 'g') { } else if (c === 'f') { } else if (c === 'e') { } else if (c === 'd') { } else if (c === 'c') { } else if (c === 'b') { } else if (c === 'a') { }; Test 5 Title Async (check if this is an asynchronous test) Code switch (s) { case 'gntsiretts': break; case 'stteristng': break; case 'strteingst': break; case 'testrsting': break; case 'testringst': break; case 'strtesting': break; case 'teststring': break; case 'stringtest': break; case 'test string': break; case 'string test': break; }; Test 6 Title Async (check if this is an asynchronous test) Code if (s === 'gntsiretts') { } else if (s === 'stteristng') { } else if (s === 'strteingst') { } else if (s === 'testrsting') { } else if (s === 'testringst') { } else if (s === 'strtesting') { } else if (s === 'teststring') { } else if (s === 'stringtest') { } else if (s === 'test string') { } else if (s === 'string test') { };