Skip to content

Instantly share code, notes, and snippets.

View Arieg419's full-sized avatar

Omer Goldberg Arieg419

View GitHub Profile
var groupCopy = _.cloneDeep($scope.group);
groupCopy.calendarDates = groupCopy.calendarDates.map(function(calendarDate) {
return _.omit(calendarDate,'source');
})
// $http.put('api/groupss/' + $scope.group._id, groupCopy).success(function(data){
// $scope.group = data;
// console.log(data);
// });
@Arieg419
Arieg419 / mergeMeetings.js
Last active December 17, 2016 10:11
Merge Meetings
// Our input. An array of objects containing all original meeting times.
[
{startTime: 0, endTime: 1},
{startTime: 3, endTime: 5},
{startTime: 4, endTime: 8},
{startTime: 10, endTime: 12},
{startTime: 9, endTime: 10},
]
// Our output. An array of objects containing all meeting times merged.
// We should consider these meetings as overlapping
[{startTime: 1, endTime: 2}, {startTime: 2, endTime: 3}];
// Overlapping meetings! How can we overlapping meeting programitically?
[{startTime: 4, endTime: 6}, {startTime: 5, endTime: 7}];
function mergeRanges(meetings) {
// sort by start times, slice will return a shallow copy of the array, not affecting original array
var sortedMeetings = meetings.slice().sort(function(a, b) {
return a.startTime > b.startTime ? 1 : -1;
});
// initialize mergedMeetings with the earliest meeting
var mergedMeetings = [sortedMeetings[0]];
var complexObjects = {
complexProp: "1", // access via complexObjects.complexProp
simpleProp: "2", // access via complexObjects.simpleProp
regularProp: 5 // access via complexObjects.regularProp
};
// create object with numbers as keys
var object = {
1: "First Name",
2: "Middle Name",
3: "Last Name"
};
console.log(object.1); // Uncaught SyntaxError: Unexpected Number
console.log(object."1"); // Uncaught SyntaxError: Unexpected String
console.log(object[1]); // "First Name"
var person = new Map();
person.set("Formal Name", "Kanye West");
person.set("Alias", "Yeezy");
person.set("Goal", "GOAT"); // don't stop reading here!
console.log(person.has("Formal Name")) // true
console.log(person.size); // 3
person.delete("Goal");
/*
The following is a "driver" file for your TempTracker.js class.
The TempTrackers class you are creating should support all of these methods,
and return the values commented out, at the end of every console.log function call.
*/
var tmp = new tempTracker();
tmp.insert(1);
var pokemon = {
firstname: 'Pika',
lastname: 'Chu ',
getPokeName: function() {
var fullname = this.firstname + ' ' + this.lastname;
return fullname;
}
};
var pokemonName = function() {
var pokemon = {
firstname: 'Pika',
lastname: 'Chu ',
getPokeName: function() {
var fullname = this.firstname + ' ' + this.lastname;
return fullname;
}
};
var pokemonName = function(snack, hobby) {