Skip to content

Instantly share code, notes, and snippets.

View tamunoibi's full-sized avatar

Ib Aprekuma tamunoibi

View GitHub Profile
function countChange (money,coins) {
const arr = [];
let sum;
for(let i = 0; i < coins.length; i++) {
for(let j = 0; j < coins.length; j++) {
let value = coins[i] + coins[j];
//console.log(value, value, value);
if(value === money) {
arr.push(value);
}
/**
Write a function that counts how many different ways you can make change for an amount of money, given an array of coin denominations. For example, there are 3 ways to give change for 4 if you have coins with denomination 1 and 2:
1+1+1+1, 1+1+2, 2+2.
The order of coins does not matter:
1+1+2 == 2+1+1
Also, assume that you have an infinite ammount of coins.
Your function should take an amount to change and an array of unique denominations for the coins:
//This returns true if the number is repeated
function isRepeated(num) {
let unique = [];
let numArr = num.toString()
.split('');
for (var i = 0; i < numArr.length; i++) {
//There are a total of 6 challanges(3, 5, 7, 9, 11, 16)
//challange 3
/*
JavaScript
Create a funtion called isIsogram that takes one argument, a word to test if it's an isogram. This function should return a boolean indicating whether it is an isogram (true) or not (false).
Example:
function power(a, b) {
var result = 1;
for (var i = 0; i < b; i++) {
result = result * a;
}
return result;
}
@tamunoibi
tamunoibi / mySortShor.js
Created April 16, 2018 10:46
andela challanges
let mySort = (nums) => {
let sortNums = nums.sort( (a, b) => a - b );
let wholeNums = sortNums.map(num => Math.floor(num, -1));
let oddNums = wholeNums.filter(num => num % 2 == 1);
let evenNums = wholeNums.filter(num => num % 2 == 0);
let newNums = oddNums.concat(evenNums);
return newNums;
}
mySort([90, 45, 66, 'bye', 100.5]);
@tamunoibi
tamunoibi / removeDupliMain.js
Created April 16, 2018 09:18
Andela challanges
let removeDuplicates = (str) => {
let regEx = /[^a-zA-Z]/g;
str = str.replace(regEx, "");
let result = '';
let obj = {
uniques: '',
duplicates: 0
};
let count = 0;
@tamunoibi
tamunoibi / mySortLongVersionjs
Last active April 16, 2018 10:44
Andela challanges
/* Write a mySort function which takes in an array integers, and should return an array of the inputed integers sorted such that the odd numbers come first and even numbers come last.
For exampl1e:
mySort( [90, 45, 66, 'bye', 100.5] )
should return
[45, 66, 90, 100] */let mySort = (nums) => {
let sortNums = nums.sort( (a, b) => a - b );
let filterNums = sortNums.map(num => Math.floor(num));
let oddNums = [];
let evenNums = [];
@tamunoibi
tamunoibi / mainShopCart.js
Last active April 30, 2019 19:40
Andela challanges
class ShoppingCart {
constructor(){
this.total = 0;
this.items = { };
}
addItem(itemName, quantity, price) {
let cost = quantity * price;
this.total = this.total + cost;
this.items[itemName] = quantity;
class ShoppingCart {
constructor () {
this._total = 0;
this._item = {};
}
addItem(itemName, quantity, price) {
this._total += price;
//confirm if you should use dot notation or bracket notation to access itemName.
item.[itemName] = quantity;