Skip to content

Instantly share code, notes, and snippets.

View tamunoibi's full-sized avatar

Ib Aprekuma tamunoibi

View GitHub Profile
function isIsogram(word){
if (word === "") {
return false;
} else {
return !/(\w).*\1/i.test(word);
}
}
class ShoppingCart:
def __init__(self):
self.total = 0
self.items = {}
def add_item(self, item_name, quantity, price):
self.items[item_name] = self.items.get(item_name, 0) + quantity
self.total += (price*quantity)
@tamunoibi
tamunoibi / incomleteIsograms.js
Last active April 16, 2018 11:34
test if it works
function isIsogram(word) {
if (word == "" || word <= 0) {
return false;
}
word.toLowerCase();
var i, j;
def remove_duplicates(word):
new_word = "".join(sorted(dict.fromkeys(word)))
return (new_word, len(word)-len(new_word))
def my_sort(list_numbers):
e_list = []
o_list = []
for x in list_numbers:
if x % 2 == 0:
e_list.append(x)
else:
o_list.append(x)
o_list.sort()
e_list.sort()
function removeDuplicates(str) {
//remove all non alphabets
var expression = /[^a-zA-Z]/g;
var unique = [];
var repeated = [];
var obj = {
uniques: [unique],
duplicates: [],
};
@tamunoibi
tamunoibi / sortStates.js
Created April 11, 2018 18:42
Andela mcq
function sort(arr) {
arr.sort( function(a, b) {
return b.length - a.length;// || //sort by length, if equal then
// a.localeCompare(b); //sort by dictionary order
});
return arr;
}
sort(["Abia", "Adamawa", "Anambra", "Akwa Ibom", "Bauchi", "Bayelsa", "Benue", "Borno", "Cross River", "Delta", "Ebonyi", "Enugu", "Edo", "Ekiti", "Gombe", "Imo", "Jigawa", "Kaduna", "Kano", "Katsina", "Kebbi", "Kogi", "Kwara", "Lagos", "Nasarawa", "Niger", "Ogun", "Ondo", "Osun", "Oyo", "Plateau", "Rivers", "Sokoto", "Taraba", "Yobe", "Zamfara"]);
@tamunoibi
tamunoibi / longest.js
Last active April 30, 2019 19:41
Andela challanges
function longest(sentence) {
var str = sentence.split(" ");
var longest = 0;
var word = null;
str.forEach(function(str) {
if (longest < str.length) {
longest = str.length;
word = str;
}
});
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;
@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;