Skip to content

Instantly share code, notes, and snippets.

View dtstanley's full-sized avatar
🏠
Working from home

DT Stanley dtstanley

🏠
Working from home
  • Wilmington, DE
View GitHub Profile
@dtstanley
dtstanley / validateOKeyJS.js
Created June 15, 2017 07:21 — forked from anonymous/validateOKeyJS.js
validateOKeyJS created by dtstanley - https://repl.it/G9OV/267
// running the function with `objectA` and `expectedKeys`
// should return `true`
var objectA = {
id: 2,
name: 'Jane Doe',
age: 34,
city: 'Chicago'
}
// running the function with `objectB` and `expectedKeys`
@dtstanley
dtstanley / findIDJS.js
Created June 15, 2017 06:55 — forked from anonymous/findIDJS.js
findIDJS created by dtstanley - https://repl.it/G9OF/126
// you can pass in `scratchData` to test out `findByid`
// your function
var scratchData = [
{id: 22, foo: 'bar'},
{id: 28, foo: 'bizz'},
{id: 19, foo: 'bazz'}
];
function findById(items, idNum) {
var myArray=[];
@dtstanley
dtstanley / enrollJS.js
Created June 15, 2017 06:33 — forked from anonymous/enrollJS.js
enrollJS created by dtstanley - https://repl.it/G9N6/210
var studentData = [
{
name: 'Tim',
status: 'Current student',
course: 'Biology'
},
{
name: 'Sue',
status: 'Withdrawn',
course: 'Mathematics'
@dtstanley
dtstanley / enrollJS.js
Created June 15, 2017 06:30 — forked from anonymous/enrollJS.js
enrollJS created by dtstanley - https://repl.it/G9N6/209
var studentData = [
{
name: 'Tim',
status: 'Current student',
course: 'Biology'
},
{
name: 'Sue',
status: 'Withdrawn',
course: 'Mathematics'
@dtstanley
dtstanley / studentReportsJS.js
Created June 15, 2017 06:11 — forked from anonymous/studentReportsJS.js
studentReportsJS created by dtstanley - https://repl.it/G9NG/249
function makeStudentsReport(data) {
var myArray =[];
for (var i=0; i<data.length; i++){
var paramtr = data[i];
myArray.push(paramtr.name + ': ' + paramtr.grade);
}
return myArray;
}
@dtstanley
dtstanley / mostFrequentJS.js
Created June 15, 2017 05:43 — forked from anonymous/mostFrequentJS.js
mostFrequentJS created by dtstanley - https://repl.it/FfGw/113
function getTokens(rawString) {
// NB: `.filter(Boolean)` removes any falsy items from an array
return rawString.toLowerCase().split(/[ ,!.";:-]+/).filter(Boolean).sort();
}
//This function counts the number of times each word appears in the text (colletion)
function mostFrequentWord(text) {
//the getTokens function is invoked and the results are saved as the variable words
var words = getTokens(text);
//the wordFrequencies array is created
@dtstanley
dtstanley / deletingKeysDrillJS.js
Created June 14, 2017 05:41 — forked from anonymous/deletingKeysDrillJS.js
deletingKeysDrillJS created by dtstanley - https://repl.it/G9Lo/87
function keyDeleter(obj) {
delete obj.foo;
delete obj.bar;
return obj;
}
var sampleObj = {
foo: 'foo',
bar: 'bar',
@dtstanley
dtstanley / personMakerJS.js
Created June 14, 2017 05:37 — forked from anonymous/personMakerJS.js
personMakerJS created by dtstanley - https://repl.it/G9Lj/122
function personMaker() {
var person = {
firstName: 'Paul',
lastName: 'Jones',
// replace `null` with a function that uses self reference to return
// full name
fullName: function(){
return (this.firstName + " " + this.lastName);
}
};
@dtstanley
dtstanley / objectUpdaterdrillJS.js
Created June 14, 2017 05:19 — forked from anonymous/objectUpdaterdrillJS.js
objectUpdaterdrillJS created by dtstanley - https://repl.it/G9Lf/123
function updateObject(obj) {
obj.foo ='foo';
obj.bar ='bar';
obj.bizz ='bizz';
obj.bang ='bang';
return obj;
}
@dtstanley
dtstanley / objectCreatordrillJS.js
Created June 14, 2017 05:01 — forked from anonymous/objectCreatordrillJS.js
objectCreatordrillJS created by dtstanley - https://repl.it/G9Lb/168
function createMyObject() {
return {
foo:'bar',
answerToUniverse:42,
'olly olly':'oxen free',
sayHello:function(){
return 'hello';
}
}
}