Created
September 22, 2015 20:04
-
-
Save anonymous/195ed7fe4812036d7c96 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/junovimumo
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> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | |
var diff = '🇦'.codePointAt(0) - 'A'.codePointAt(0); // === 127397 | |
function flag(code) { | |
return String.fromCodePoint.apply(String, _toConsumableArray([0, 1].map(function (i) { | |
return code.codePointAt(i) + diff; | |
}))); | |
} | |
console.log(flag('US')); | |
console.log(flag('GB')); | |
console.log(flag('UA')); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">const diff = '🇦'.codePointAt(0) - 'A'.codePointAt(0); // === 127397 | |
function flag(code) { | |
return String.fromCodePoint(...[0, 1].map(i => code.codePointAt(i) + diff)); | |
} | |
console.log(flag('US')); | |
console.log(flag('GB')); | |
console.log(flag('UA'));</script></body> | |
</html> |
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
'use strict'; | |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | |
var diff = '🇦'.codePointAt(0) - 'A'.codePointAt(0); // === 127397 | |
function flag(code) { | |
return String.fromCodePoint.apply(String, _toConsumableArray([0, 1].map(function (i) { | |
return code.codePointAt(i) + diff; | |
}))); | |
} | |
console.log(flag('US')); | |
console.log(flag('GB')); | |
console.log(flag('UA')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment