Skip to content

Instantly share code, notes, and snippets.

View kevmor11's full-sized avatar

Kevin Morissette kevmor11

View GitHub Profile
@kevmor11
kevmor11 / instance.rb
Created May 9, 2017 02:09
Accessor practise
class Person
attr_accessor :name
def initialize(name)
@name = name
end
end
@kevmor11
kevmor11 / settings.json
Created May 5, 2017 18:35
VS Code Settings
// Controls the font size in pixels.
"editor.fontSize": 12,
// Controls auto save of dirty files. Accepted values: 'off', 'afterDelay', 'onFocusChange' (editor loses focus), 'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.
"files.autoSave": "off",
// Controls the font family.
"editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace",
function rollDice (rolls) {
var result = "Rolled " + rolls + " dice: "
for (var i = 0; i < rolls; i++) {
var rollNum = Math.floor((Math.random(rolls)*6)+1);
if (i < rolls - 1) {
result += (rollNum + ", ");
} else {
result += rollNum;
}
}
@kevmor11
kevmor11 / dice-roller.js
Created April 4, 2017 19:13
Rolls a variable number of dice based on a given integer argument
function rollDice (rolls) {
var result = "Rolled " + rolls + " dice: "
for (var i = 0; i < rolls; i++) {
var rollNum = Math.floor((Math.random(rolls)*6)+1);
if (i < rolls - 1)
result += (rollNum + ", ");
else
result += rollNum + ".";
}
return result;
@kevmor11
kevmor11 / password.js
Created April 4, 2017 03:03
Password Obfuscator Function
function changeWord (string) {
var result = "";
for (var i = 0; i < string.length; i++) {
if (string[i] === "a") {
result += "4";
} else if (string[i] === "e") {
result += "3";
} else if (string[i] === "o") {
result += "0";
} else if (string[i] === "l") {
@kevmor11
kevmor11 / loopylighthouse.js
Created April 4, 2017 02:58
LoopyLighthouse function
function loopyLighthouse (start, end, number1, number2, replace1, replace2) {
for (var i = start; i <= end; i++) {
if (i % number1 === 0 && i % number2 === 0) {
console.log(replace1 + replace2);
}
else if (i % number1 === 0) {
console.log(replace1);
}
else if (i % number2 === 0) {
console.log(replace2);
@kevmor11
kevmor11 / pig-latin.js
Created April 4, 2017 02:48
a program that converts given strings into pig latin
function pigLatin (string) {
var result = "";
for (var i = 1; i < string.length; i++) {
result += string[i];
}
result += string[0];
result += "ay";
return result;
};
@kevmor11
kevmor11 / reverse.js
Created April 4, 2017 02:11
reverses strings passed as arguments
function reverse (string) {
var result = "";
for (var i = string.length-1; i >= 0; i--) {
result += string[i];
}
return result;
};
for (var i = 2; i < process.argv.length; i++) {
var string = process.argv[i];