- 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:
| #!/bin/bash | |
| # | |
| # DESCRIPTION: | |
| # | |
| # Set the bash prompt according to: | |
| # * the branch/status of the current git repository | |
| # * the branch of the current subversion repository | |
| # * the return value of the previous command | |
| # | |
| # USAGE: |
| Buffer.prototype.pprint = function() { | |
| var line = ""; | |
| if(this.length > 0) { | |
| for(var i=0; i<this.length; i++) { | |
| if(i%8==0) { | |
| sys.print(" "); | |
| } | |
| if(i%16==0) { | |
| sys.print(line); | |
| line = ""; |
| // 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 = []; |
| node_modules/ |
| /* | |
| author: jbenet | |
| os x, compile with: gcc -o testo test.c | |
| linux, compile with: gcc -o testo test.c -lrt | |
| */ | |
| #include <time.h> | |
| #include <sys/time.h> | |
| #include <stdio.h> |
| /** | |
| * __proto__ and prototype | |
| * - the __proto__ property the instance's 'parent' up the prototype chain | |
| * - the prototype property refers what new instances of the type will have their __proto__ set to, i.e. what will be the new instance's 'parent' up the prototype chain | |
| */ | |
| /* Given */ | |
| function Object () {} | |
| Object.prototype = { | |
| __proto__: null |
| /* | |
| A simple newline delimited JSON protocol. | |
| Receiving Usage: | |
| protocol = require('./json-protocol'); | |
| // parsing data | |
| parser = protocol.StreamParser(); |
| // Named constants with unique integer values | |
| var C = {}; | |
| // Tokenizer States | |
| var START = C.START = 0x11; | |
| var TRUE1 = C.TRUE1 = 0x21; | |
| var TRUE2 = C.TRUE2 = 0x22; | |
| var TRUE3 = C.TRUE3 = 0x23; | |
| var FALSE1 = C.FALSE1 = 0x31; | |
| var FALSE2 = C.FALSE2 = 0x32; | |
| var FALSE3 = C.FALSE3 = 0x33; |