This file contains 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
// Using stricter env | |
'use strict'; | |
// our object; does only one thing. | |
var obj = { | |
getMe: function() { | |
return this; | |
} |
This file contains 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
/* Reading https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch1.html | |
* I have a differing opinion. Please help in sorting it out. | |
*/ | |
// Original code : or I think wrong way to to Object Oriented code. | |
var Flock = function(n) { | |
this.seagulls = n; | |
}; |
This file contains 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 str = "the quick brown fox jumped over the lazy dog"; | |
var arr = str.split(' '); | |
var titleArr = arr.map(function(x){ | |
return x.charAt(0).toUpperCase() + x.slice(1); | |
}); | |
var titleStr = titleArr.join(' '); | |
console.log(titleStr); |
This file contains 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
// ES 2015 | |
var DefaultPerson = { | |
name : { first: "John", last: "Smith"}, | |
age: 25, | |
city: { hometown: "NY", current: "PA" } | |
}; | |
var Person = { | |
name : { first: "EcmaScript", last: "Hacker"}, | |
age: 17, |
This file contains 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 arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
console.log("arr: ", arr); | |
let even = arr.filter(x => x%2 === 0); | |
console.log("evens: ", even); | |
let odd = arr.filter(x => x%2 === 1); | |
console.log("odds: ", odd); | |
let gt5 = arr.filter(x => x > 5); |
This file contains 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
"use strict"; | |
var Person = function Person(name, age, sex, friends) { | |
var self = this !== undefined ? this : Object.create(Person.prototype); | |
self.Name = name; | |
self.Age = age; | |
self.Sex = sex; | |
self.Friends = friends; | |
self.SayHelloToMyFriends = function () { | |
var _this = this; |
This file contains 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
"use strict"; | |
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | |
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } |
This file contains 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
function convertPM(time){ | |
if(time.startsWith('12')){ | |
return time.replace('PM',''); | |
} | |
return (parseInt(time.split(':'))+12) + time.substring(2, time.length-2); | |
} | |
function convertAM(time){ | |
if(time.startsWith('12')){ | |
return '00'+time.substring(2, time.length-2); |
This file contains 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
console.log("1,2,3,4".split('')) | |
["1", ",", "2", ",", "3", ",", "4"] | |
console.log("1,2,3,4".split(',')) | |
["1", "2", "3", "4"] | |
console.log("1,2,3,4".split()) | |
["1,2,3,4"] | |
console.log("1 2 3 4".split()) |
This file contains 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
using System; | |
class Solution { | |
static void Main(String[] args) { | |
var numbers = Console.ReadLine().Split(' '); | |
var x = int.Parse(numbers[0]); | |
var y = int.Parse(numbers[1]); | |
Console.WriteLine(gcd(x, y)); | |
} | |
static int gcd(int x, int y){ |
OlderNewer