Skip to content

Instantly share code, notes, and snippets.

View StrykerKent's full-sized avatar

Stryker S StrykerKent

View GitHub Profile
@StrykerKent
StrykerKent / LongestWord.cs
Last active August 13, 2018 03:11
Question was "Find the largest word in a sentence." I used C# for this.
using System;
using System.Linq;
using System.Text.RegularExpressions;
class MainClass {
public static string LongestWord(string sen) {
// remove unwanted characters (everything except a-z 0-9 or spaces)
sen = Regex.Replace(sen, @"[^a-zA-Z0-9 ]+", "", RegexOptions.Compiled);
// split words into array
string[] words = sen.Split(' ');
@StrykerKent
StrykerKent / arrowFunction.js
Last active December 14, 2018 16:16
Example of an arrow function with a conditional ternary if statement in JavaScript.
var arrowFunction = x => x % 2 == 0 ? "even" : "odd";
for(var i = 0; i < 100; i++) {
console.log([i] + " " + arrowFunction([i]));
}
@StrykerKent
StrykerKent / getWednesdaysOfThisYear.js
Created October 18, 2018 17:52
I was asked to iterate through each day from today to the first of this year and only print out date information for each Wednesday. I used pure JavaScript to do this.
var now = new Date();
for (var d = now; d >= new Date(new Date().getFullYear(), 0, 1); d.setDate(d.getDate() - 1)) {
if (d.getDay() == 3) {
console.log(new Date(d));
}
}
@StrykerKent
StrykerKent / bigOPerformance.js
Last active March 29, 2019 18:25
Reviewing / Measuring / Timing O(n) performance using JavaScript, NFL Players, functions, for loops, and performance.now(). For use in browser, not node.js.
const players = [
'Tom Brady',
'Aaron Rodgers',
'Drew Brees',
'Ben Roethlisberger',
'Philip Rivers',
'Aqib Talib',
'Alex Smith',
'Larry Fitzgerald'
];