This file contains hidden or 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
| // This works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
| var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
| // Open (or create) the database | |
| var open = indexedDB.open("MyDatabase", 1); | |
| // Create the schema | |
| open.onupgradeneeded = function() { | |
| var db = open.result; | |
| var store = db.createObjectStore("MyObjectStore", {keyPath: "id"}); |
This file contains hidden or 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
| // http://stackoverflow.com/a/16484266/754377 | |
| function DataBind(element, data) { | |
| this.data = data; | |
| this.element = element; | |
| element.value = data; | |
| element.addEventListener("change", this, false); | |
| } | |
| DataBind.prototype.handleEvent = function(event) { |
This file contains hidden or 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
| //Given an array, "findShortestWordAmongMixedElements" returns the shortest string within the given array. | |
| // | |
| // Notes: | |
| // * If there are ties, it should return the first element to appear in the given array. | |
| // * Expect the given array to have values other than strings. | |
| // * If the given array is empty, it should return an empty string. | |
| // * If the given array contains no strings, it should return an empty string. | |
| function findShortestWordAmongMixedElements(arr) { | |
| ret = ''; | |
| arr.forEach(x => { |
This file contains hidden or 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
| // Given a string, "countAllCharacters" returns an object where each key is a character in the given string. The value of each key should be how many times each character appeared in the given string. | |
| // Notes: | |
| // * If given an empty string, countAllCharacters should return an empty object. | |
| function countAllCharacters(str) { | |
| var newArr = str.split(""); | |
| var newObj = {}; | |
| for (var idx in newArr) { |
This file contains hidden or 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
| // Given an object and a key, "getElementsGreaterThan10AtProperty" returns an array containing the elements within the array, located at the given key, that are greater than 10. | |
| // Notes: | |
| // * If the array is empty, it should return an empty array. | |
| // * If the array contains no elements greater than 10, it should return an empty array. | |
| // * If the property at the given key is not an array, it should return an empty array. | |
| // * If there is no property at the key, it should return an empty array. | |
| function getElementsGreaterThan10AtProperty(obj, key) { | |
| var newArr = []; |