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
| var sumPairs = function(integerArray, target) { | |
| var solution; | |
| var findMatch = function(nums) { | |
| var first = nums[0]; | |
| var second; | |
| for(var i = 1; i < nums.length; i++) { | |
| second = nums[i]; | |
| if(first + second == target) { | |
| solution = [first, second]; |
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
| var http = require('http'); | |
| var urls = process.argv.slice(2); | |
| var results = {}; | |
| var printResults = function() { | |
| urls.forEach(function(url) { | |
| console.log(results[url]); | |
| }); | |
| }; |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM manipulation with jQuery</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
| <script type="text/javascript" src="jquery_example.js"></script> | |
| </head> | |
| <body> | |
| <h1> Hello. Welcome to the jQuery DOM Manipulation Challenge! </h1> | |
| <div class="mascot"> |
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
| class BoggleBoard | |
| attr_reader :board | |
| def initialize board | |
| @board = board | |
| end | |
| def create_word(*coords) | |
| coords.map { |coord| @board[coord.first][coord.last]}.join("") |
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
| def times_table(rows) | |
| column = 0 | |
| rows.times do | |
| column += 1 | |
| rows.times do |i| | |
| print "#{((i+1)*column).to_s.center(5)}" | |
| end | |
| print "\n" | |
| end | |
| end |
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
| def factorial(n) | |
| n > 0 ? (1..n).inject(1) {|sum, x| sum * x} : 1 | |
| end |
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
| def count_between(array, lower_bound, upper_bound) | |
| incs = [] | |
| array.each do |x| | |
| incs << x if (lower_bound..upper_bound).include?(x) | |
| end | |
| incs.count | |
| end |
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
| def longest_string(array) | |
| longest = '' | |
| array.length.times do |i| | |
| longest = array[i] if array[i].length >= longest.length | |
| end | |
| array == [] ? nil : longest | |
| end |
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
| def mode(array) | |
| most = [] | |
| freq = 0 | |
| num = {} | |
| array.each do |x| | |
| num[x] = 0 if num[x].nil? | |
| num[x] += 1 | |
| end |