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 Person | |
| attr_accessor :name | |
| # attr_reader :name | |
| # attr_writer :name | |
| # def name | |
| # @name | |
| # 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
| <!DOCTYPE HTML> | |
| <html> | |
| <head> | |
| <style> | |
| body { | |
| margin: 0px; | |
| padding: 0px; | |
| } | |
| </style> | |
| </head> |
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
| const urlDecode = function(text) { | |
| // Put your solution here | |
| result = {}; | |
| let splitText = text.replace(/%20/g, ' ') | |
| .split('&') | |
| .map(x => x.split("=")); | |
| splitText.forEach( function(elm) { | |
| // statements | |
| result[elm[0]] = elm[1] |
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
| const organizeInstructors = function(instructors) { | |
| let result = {}; | |
| instructors.forEach( function(elem) { | |
| if(!result[elem.course]) { | |
| result[elem.course] = []; | |
| result[elem.course].push(elem.name); | |
| } else { | |
| result[elem.course].push(elem.name); | |
| } |
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
| const instructorWithLongestName = function(instructors) { | |
| let sorted = instructors.sort(function(a, b) { | |
| return b.name.length - a.name.length; | |
| }); | |
| return sorted[0]; | |
| }; | |
| console.log(instructorWithLongestName([ | |
| {name: "Samuel", course: "iOS"}, |
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
| let numberOfVowels = function(data) { | |
| let count = 0; | |
| for (var i = 0; i < data.length; i++) { | |
| if(data[i] === 'a' || data[i] === 'e' || data[i] === 'i' || data[i] === 'o' || data[i] === 'u') { | |
| count++; | |
| } | |
| } | |
| return count; | |
| }; |
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
| let sumLargestNumbers = function(data) { | |
| let sorted = data.sort(function(a,b){ | |
| return b - a; | |
| }) | |
| return sorted[0] + sorted[1]; | |
| }; | |
| console.log(sumLargestNumbers([1, 10])); | |
| console.log(sumLargestNumbers([1, 2, 3])); | |
| console.log(sumLargestNumbers([10, 4, 34, 6, 92, 2])); |
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
| let conditionalSum = function(values, condition) { | |
| var sum = 0; | |
| values.forEach( function(value) { | |
| if(condition == "even" && value % 2 === 0) { | |
| sum += value; | |
| } else if (condition == 'odd' && value % 2 !== 0) { | |
| sum +=value; | |
| } | |
| }); | |
| return sum; |
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 words = ["ground", "control", "to", "major", "tom"]; | |
| const wordLen = map(words, function(word) { | |
| return word.length; | |
| }); | |
| const wordUpper = map(words, function(word) { | |
| return word.toUpperCase(); | |
| }); |
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 students = [ | |
| { id: 1, name: "bruce", age: 40 }, | |
| { id: 2, name: "zoidberg", age: 22 }, | |
| { id: 3, name: "alex", age: 22 }, | |
| { id: 4, name: "alex", age: 30 } | |
| ]; | |
| const toSortArray = students | |
| .map(x => [x.name, x.age, x.id]) |
NewerOlder