Skip to content

Instantly share code, notes, and snippets.

View ugochukwu95's full-sized avatar

Ugochukwu Oguejiofor ugochukwu95

View GitHub Profile
@ugochukwu95
ugochukwu95 / index.php
Created January 17, 2020 18:03
Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
<?php
for ($i=1; $i <= 100; $i++) {
if ((($i % 3) == 0) && (($i % 5) == 0)) {
echo "FizzBuzz\n";
continue;
}
elseif (($i % 3) == 0) {
echo "Fizz\n";
continue;
}
@ugochukwu95
ugochukwu95 / LocationChecker.js
Created January 15, 2020 16:42
A NodeJS/JavaScript program that reads our list of partners and outputs the company names and addresses of matching partners (with offices within 100km) sorted by company name (ascending).
/**
* is One Point within Another
* @param point {Object} {latitude: Number, longitude: Number}
* @param interest {Object} {latitude: Number, longitude: Number}
* @param kms {Number}
* @returns {boolean}
*/
const LocationChecker = (point, interest, kms) => {
let R = 6371; // Earth radius
let deg2rad = (n) => { return Math.tan(n * (Math.PI/180)) }; // function that converts degrees to radians
@ugochukwu95
ugochukwu95 / DeepClone.js
Created January 15, 2020 16:30
A function called DeepClone.js which takes an object and creates a copy of it. Tested using jest (see DeepClone.test.js)
const DeepClone = (obj) => {
let copy;
// Handle the 3 simple types, and null or undefined
if (null === obj || "object" !== typeof obj) return obj;
// Handle Date
if (obj instanceof Date) {
copy = new Date();
// A way to make one Date the same as another is by calling the setTime method