Skip to content

Instantly share code, notes, and snippets.

View tbold5's full-sized avatar

Trae Tuguldur Bold tbold5

  • BCIT
View GitHub Profile
@tbold5
tbold5 / password.js
Last active September 25, 2018 17:02
Password Obfuscation
var string = "password"
function obfuscate(string) {
var newString = "";
for (var i = 0; i < string.length; i++) {
var char = string.charAt(i);
if (char === "a") {
newString += "4";
} else if (char === "e") {
newString += "3";
@tbold5
tbold5 / concepts.js
Last active September 25, 2018 02:59 — forked from kvirani/concepts.js
W1D1 - Concepts
var conceptList = ["gists", "types", "operators", "iteration", "problem solving"];
function joinList(array) {
var conceptListString = "";
for (var i = 0; i < array.length; i++) {
conceptListString += array[i];
if (i < conceptList.length - 1) {
conceptListString += ", ";
}
}
console.log("Today I learned about " + conceptListString + ".")
@tbold5
tbold5 / min.js
Last active September 25, 2018 17:17
Adding Numbers
var args = process.argv;
console.log(Number(process.argv[2]) + (Number(process.argv[3])));
// First we give variable equal to process.argv (that will make any output into strings)
// We use [2] and [3] because process.agrv itself comes with [0] , [1] array.
// Oher option would be use process.argv.splice(2) and start the console.log(Number(process.argv[0])).
@tbold5
tbold5 / lunch.js
Created September 24, 2018 17:58 — forked from kvirani/lunch.js
W1D1 - What to do for Lunch?
function whatToDoForLunch(hungry, availableTime) {
if (hungry === false) {
console.log("Get back to work");
} else if (hungry === true && availableTime < 20) {
console.log("Pick something up and eat it in the lab");
} else if (hungry === true && availableTime > 20 && availableTime < 30) {
console.log("Try a place nearby");
} else if (hungry === true && availableTime > 30) {
console.log("Do you have that much time?");
}
var conditionalSum = function(values, condition) {
var temp = 0;
if (condition === "even") {
for (var x = 0; x <= values.length; x++) {
if (values[x] % 2 === 0) {
temp += values[x];
}
}
} else if (condition === "odd") {
for (var i = 0; i < values.length; i++) {
@tbold5
tbold5 / kata1
Created September 19, 2018 00:15
var repeatNumbers = function(data) {
return data.map(([number, count]) => number.toString().repeat(count)).join(', ')
}
console.log(repeatNumbers([[1, 10]]));
console.log(repeatNumbers([[1, 2], [2, 3]]));
console.log(repeatNumbers([[10, 4], [34, 6], [92, 2]]));
// using map function to create new array and including other functions like "toString" to make into string and "join" to combine the other arrays together witha a comma.