This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortedTemps = temps.sort((a, b) => Math.abs(a) - Math.abs(b) || b - a); | |
const result = sortedTemps[0] || 0; | |
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart | |
console.log('10'.padStart(2, '0')); // expected output: "10" | |
console.log('9'.padStart(2, '0')); // expected output: "09" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flattenArray = (arr) => { | |
return arr.reduce((a, v) => { | |
return a.concat(Array.isArray(v) ? flattenArray(v) : v) | |
}, []); | |
} | |
// ESLint.com | |
// https://eslint.org/demo#eyJ0ZXh0IjoiY29uc3QgZmxhdHRlbkFycmF5ID0gKGFycikgPT4ge1xuICByZXR1cm4gYXJyLnJlZHVjZSgoYWNjdSwgY3VycikgPT4ge1xuICAgIHJldHVybiBhLmNvbmNhdChBcnJheS5pc0FycmF5KGN1cnIpID8gZmxhdHRlbkFycmF5KGN1cnIpIDogY3VycilcbiAgfSwgW10pO1xufSIsIm9wdGlvbnMiOnsicGFyc2VyT3B0aW9ucyI6eyJlY21hVmVyc2lvbiI6Nywic291cmNlVHlwZSI6InNjcmlwdCIsImVjbWFGZWF0dXJlcyI6e319LCJydWxlcyI6e30sImVudiI6eyJicm93c2VyIjp0cnVlLCJub2RlIjp0cnVlLCJjb21tb25qcyI6dHJ1ZSwic2hhcmVkLW5vZGUtYnJvd3NlciI6dHJ1ZSwid29ya2VyIjp0cnVlLCJhbWQiOnRydWUsIm1vY2hhIjp0cnVlLCJqYXNtaW5lIjp0cnVlLCJqZXN0Ijp0cnVlLCJwaGFudG9tanMiOnRydWUsImpxdWVyeSI6dHJ1ZSwicXVuaXQiOnRydWUsInByb3RvdHlwZWpzIjp0cnVlLCJzaGVsbGpzIjp0cnVlLCJtZXRlb3IiOnRydWUsIm1vbmdvIjp0cnVlLCJwcm90cmFjdG9yIjp0cnVlLCJhcHBsZXNjcmlwdCI6dHJ1ZSwibmFzaG9ybiI6dHJ1ZSwic2VydmljZXdvcmtlciI6dHJ1ZSwiYXRvbXRlc3QiOnRydWUsImVtYmVydGVzdCI6dHJ1ZSwid2ViZXh0ZW5zaW9ucyI6dHJ1ZS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//uitls.js : CREATE NAMESPACING functions also use ‘define()’ to declare it as requirjs module | |
(function (requirejs) { | |
define('utils', function () { | |
// Allow creation of methods for SHOP modules | |
window.UTILS = window.UTILS || {}; | |
var u = window.UTILS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> | |
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> | |
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> | |
<!--[if gt IE 8]><!--> | |
<html class="no-js" lang="en"> | |
<!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> | |
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> | |
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> | |
<!--[if gt IE 8]><!--> | |
<html class="no-js" lang="en"> | |
<!--<![endif]--> | |
<head> | |
<meta charset="utf-8"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iPad | |
1024 × 690 In landscape on iOS 4.3 | |
1024 × 672 In landscape on iOS 5 | |
768 × 946 In portrait on iOS 4.3 | |
768 × 928 In portrait on iOS 5 | |
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3 | |
1024 × 644 Always showing bookmarks bar in landscape on iOS 5 | |
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Function declaration | |
function foo() { | |
console.log(arguments); | |
} | |
foo(['a', 'b', 'c'], [1, 2, 3, 4, 5]); | |
//IIFE | |
(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* USAGE: | |
* markdown, gist, github, json, embed | |
* Reference the script in index.html (or main md html file e.g. mdwiki.html) | |
* Then in any .md document include like below. Ensure empty lines before <div> and after </div> | |
* | |
* <div class="gistEmbed" data-gist-id="12265cd979f0dee75acd"></div> | |
* | |
* | |
*/ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void enhancedForLoop(){ | |
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
System.out.println("\nEXAMPLE: Enhanced For Statement"); | |
for (int temp: arr){ // Create a temporary variable, same type as array values. For | |
// loop assign array value to the temporary variable | |
System.out.println("Enhanced = " + temp); | |
} |
NewerOlder