View removeDuplicateObjects.js
function removeDuplicateObjects(arrayOfObjects) {
let newObj = new Set();
arrayOfObjects.forEach(item => newObj.add(JSON.stringify(item)))
return Array.from(newObj).map(item => JSON.parse(item))
}
View getUniqueProps.js
function getUniqueProps(arrayOfObjects, propToCheck) {
let newObj = new Set();
arrayOfObjects.forEach(item => {
newObj.add(JSON.stringify(item[propToCheck]))
})
let result = Array.from(newObj).map(item => {
return { [propToCheck]: JSON.parse(item) }
View draftCtrl.js
//
// Declare function
//
$scope.getNotifcations = headerSvc.getNotifications().then(function(resp){
$scope.notifications = resp.data
for (var i = 0; i < $scope.notifications.length; i++) {
$scope.notifications[i].title = ''
View article.js
GetBookmarks : function(req, res) {
var results = []
//
// Get array of IDs for specific user
//
db.query("SELECT bookmarks_list FROM users WHERE id="+req.params.user_id, function(err, resp) {
if (err) {console.log(err)} else {
var bookmarks = resp[0].bookmarks_list.split(',')
View Room.js
import React, { Component } from 'react';
import Bed from './Bed';
import "../../styles/dndbed.scss";
import { removeStudentFromApt } from '../../actions/action_student'
import { connect } from "react-redux"
class Room extends Component {
render() {
View Container.js
import React, { Component } from 'react';
import Room from './Room';
import Bed from './Bed'
import Student from './Student';
import ApartmentListFilter from "../ApartmentListFilter";
import "../../styles/dndbed.scss";
import "../../styles/housingcontainer.scss";
import { connect } from "react-redux"
import { getStudents } from "../../actions/action_student"
import { getApartments, getRooms } from "../../actions/action_apartments"
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console