- Solve all problems using JavaScript
-
Write a function that returns an array with the first
npowers of 2. Call ittwoPow. -
Use
twoPowandArray.prototype.reduceto the sum of the first 10 powers of 2. -
Describe this call signature:
| alternativeart | |
| announcements | |
| askscience | |
| BarCraft | |
| bestof | |
| blockbattlenet | |
| BuildingEsports | |
| business | |
| codeprojects | |
| coding |
| var fs = require("fs"); | |
| var TwoStep = require("two-step"); | |
| var jsdom = require("jsdom"); | |
| TwoStep( | |
| function() { fs.readFile("./cities.json", this.val()); }, | |
| function(err, cities) { | |
| if(err) { throw err; } | |
| cities = JSON.parse(cities); |
| var http = require("http"); | |
| var bee = require("beeline"); | |
| var route = bee.route({ | |
| "`preprocess`": [ | |
| (function() { | |
| function sendHtml(data) { | |
| this.writeHead(200, { "Content-Length": data.length, | |
| "Content-Type": "text/html; charset=utf-8" }); | |
| this.end(data); |
| { scopeName = 'source.js'; | |
| comment = 'JavaScript Syntax: version 2.0'; | |
| fileTypes = ( 'js', 'htc', 'jsx' ); | |
| foldingStartMarker = '^.*\bfunction\s*(\w+\s*)?\([^\)]*\)(\s*\{[^\}]*)?\s*$'; | |
| foldingStopMarker = '^\s*\}'; | |
| patterns = ( | |
| { name = 'meta.class.js'; | |
| comment = 'match stuff like: Sound.prototype = { … } when extending an object'; | |
| match = '([a-zA-Z_?.$][\w?.$]*)\.(prototype)\s*(=)\s*'; | |
| captures = { |
| // Create scrollLeft and scrollTop methods | |
| jQuery.each( ["Left", "Top"], function( isScrollTop, name ) { | |
| var method = "scroll" + name; | |
| jQuery.fn[ method ] = function( val ) { | |
| var elem, win; | |
| if( val === undefined ) { | |
| elem = this[ 0 ]; | |
| if( !elem ) { |
| // For each of the following code fragments: | |
| // a. what does the code do? | |
| // b. what did the author intend for it to do? | |
| // c. how would you fix it? | |
| // NOTE: all code samples work exactly the same in all browsers | |
| // 1. object literals | |
| var data = [ { high: 100, low: 81 }, { high: 93, low: 73 }, { high: 60, low: 32 } ]; | |
| function getAverages(data) { | |
| var avgs = []; |
| val foo: Option[Set[Option[Char]]] = blah | |
| val results = foo.map(_.map(_.map(bar).getOrElse(defVal))).getOrElse(Nil) |
| (function() { // Make numbers look like strings | |
| var oldToString = Number.prototype.toString; | |
| Number.prototype.toString = function() { | |
| if(this == 4) { return "four"; } | |
| else { return oldToString.call(this); } | |
| }; | |
| })(); | |
| var four = new Number(4); | |
| alert(1 + four); // shows 5 |