Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Andre Iskandar andreiskandar

🎯
Focusing
View GitHub Profile
View gist:43ed528aa564f949ed270036425156bf
/*
A game of chess is played on an 8 column by 8 row board.
In the game of chess, a queen can attack pieces which are on the same row, column, or diagonal.
*/
const generateBoard = (whiteQueen, blackQueen) =>{
let board = [];
let hzl = [];
for(let i = 0; i < 8; i++){
for(let j = 0; j < 8; j++){
View gist:1e191f545f172c38baf4c82a0a31f65c
/*
URL Encoded Strings
To safely send data in a URL, the data first has to be encoded to convert any
special characters to URL safe characters. For this assignment we will only focus on the following URL encoding rules:
%20 represents a space character.
Key-value pairs are represented using an = character: key=value
Multiple key-value pairs are separated using a & character
*/
const urlDecode = function(text) {
@andreiskandar
andreiskandar / gist:16d9f691761bf533365d4da06bf1ea3f
Created Jul 4, 2020
function named makeCase that will receive an input string and one or more casing options
View gist:16d9f691761bf533365d4da06bf1ea3f
/*
Create a function named makeCase that will receive an input string and one or more casing options.
Return a new string that is formatted based on casing options:
Precedence of each of the casing styles are as follows, values higher in the list should be processed first:
camel, pascal, snake, kebab, title
vowel, consonant
upper, lower
*/
@andreiskandar
andreiskandar / gist:b314ea8deb2792b39969aad958d7e5d2
Created Jul 4, 2020
Create a function named camelCase that will convert a string to camel case, and return the result.
View gist:b314ea8deb2792b39969aad958d7e5d2
/*
Create a function named camelCase that will convert
a string to camel case, and return the result.
*/
const camelCase = function(input) {
let string = input.split("");
string[0] = string[0].toLowerCase();
for(let i = 0; i < string.length; i++) {
if(string[i] === " "){
@andreiskandar
andreiskandar / gist:88b21fce511d722f6db84f895eeab571
Created Jul 3, 2020
Create a function named squareCode that will receive a message, and return the secret square code version of the message.
View gist:88b21fce511d722f6db84f895eeab571
/*
Create a function named squareCode that will receive a message,
and return the secret square code version of the message.
*/
const squareCode = function(message) {
let len = Math.ceil(Math.sqrt(message.split(' ').join("").length));
const messageWithoutSpace = message.split(' ').join('');
let encrypted = '';
for(let i = 0; i < len; i++){
@andreiskandar
andreiskandar / gist:4bf0a40c3911a1fb76474dff4b6343b3
Created Jul 3, 2020
Create a function named blocksAway that will receive an array of directions, and return an object that calculates how far north and east those directions will take someone.
View gist:4bf0a40c3911a1fb76474dff4b6343b3
/*
Create a function named blocksAway that will receive an array of directions,
and return an object that calculates how far north and east those directions will take someone.
*/
const blocksAway = function(directions) {
let origin = [0, 0];
let finalPos = {};
if(directions[0] === 'right'){
@andreiskandar
andreiskandar / gist:1805dbbf04f9d3f245317c9cffab4c1d
Created Jul 2, 2020
Number guesser using prompt sync dependencies
View gist:1805dbbf04f9d3f245317c9cffab4c1d
/*
In this kata you'll be responsible for setting up your JS file from scratch. Make sure it is well organized!
Write a guessing game where the user has to guess a secret number. After every guess the program
tells the user whether their number was too large or too small. At the end, the number of tries
needed should be printed.
Inputting the same number multiple times should only count as one try. If the user provides an answer
which isn't a number, print an error message and do not count this as a try.
*/
@andreiskandar
andreiskandar / gist:337f91e821f693ab7a55d4e26ec1051d
Created Jul 2, 2020
Array of instructor objects that will return a new object in organized way
View gist:337f91e821f693ab7a55d4e26ec1051d
/*
Create a function named organizeInstructors that will receive an array of instructor objects,
and will return a new object that has the following format:
*/
const organizeInstructors = function(instructors) {
let organize = {};
instructors.forEach(i => {
if(!organize[i.course]){
organize[i.course] = [];
@andreiskandar
andreiskandar / gist:e6ce92629d25e02c407b4d694b2f8508
Created Jul 2, 2020
Function to Calculate change and return an object of change denominations
View gist:e6ce92629d25e02c407b4d694b2f8508
/*
Create a function named calculateChange that takes in a total amount of a bill and the total cash given to pay that bill.
Return a new object that describes the total amount of change for the cashier to give back. Omit any types of change
that you shouldn't give back, i.e. if you don't give back a twenty dollar bill, don't include it in the results.
*/
const currencyDenominations = ['twenty', 'ten', 'five', 'two', 'one', 'quarter', 'dime', 'nickel', 'penny'];
const currencyValue = [2000, 1000, 500, 200, 100, 25, 10, 5, 1];
@andreiskandar
andreiskandar / gist:bd95c0db8e8606780c8db0634ac16688
Created Jul 2, 2020
Create a function named talkingCalendar format YYYY/MM/DD, and returns a new human readable date that looks like December 2nd, 2017.
View gist:bd95c0db8e8606780c8db0634ac16688
/*
Create a function named talkingCalendar that takes in a date string with the format YYYY/MM/DD,
and returns a new human readable date that looks like December 2nd, 2017.
*/
const getMonthName = (month) => {
const monthName ={
01: 'January', 02: 'February', 03: 'March',
04: 'April', 05: 'May', 06: 'June',
07: 'July', 08: 'August', 09: 'September',