This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Write a function called longest which will take a string of space separated words and will return the longest one. | |
For example: | |
longest("This is Andela") | |
returns | |
"Andela" | |
and | |
longest("Brilliance is evenly distributed") | |
returns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Write a function called longest which will take a string of space separated words and will return the longest one. | |
For example: | |
longest("This is Andela") | |
returns | |
"Andela" | |
and | |
longest("Brilliance is evenly distributed") | |
returns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Write a function named power that accepts two arguments, a and b and calculates a raised to the power b. | |
Example | |
power(2, 3) => 8 | |
Note: Don't use | |
2 ** 3 | |
and don't use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JavaScript | |
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Write a function which will take one string argument containing characters between a-z, and should remove all repeated characters (duplicates) in the string. | |
Python | |
The function should be called remove_duplicates and should return a tuple with two values: | |
A new string with only unique, sorted characters. | |
The total number of duplicates dropped. | |
For example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Create a class called ShoppingCart. Create a constructor that has no arguments and sets the total attribute to zero, and initializes an empty dict attribute named items. Create a method addItem that requires itemName, quantity and price arguments. This method should add the cost of the added items to the current value of total. It should also add an entry to the items dict such that the key is the itemName and the value is the quantity of the item. Create a method removeItem that requires similar arguments as add_item. It should remove items that have been added to the shopping cart and are not required. This method should deduct the cost of these items from the current total and also update the items dict accordingly. If the quantity of items to be removed exceeds current quantity in cart, assume that all entries of that item are to be removed. Create a method checkout that takes in cashPaid and returns the value of balance from the payment. If cashPaid is not enough to cover the total, return Cash pa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isIsogram(word){ | |
if (word !== undefined){ | |
const wordArr = word; | |
if(word === ""){ | |
return false; | |
} | |
for (let i = 0; i < wordArr.length; i++) { | |
for (let j = 0; j < wordArr.length; j++) { | |
if(i!=j){ | |
if (wordArr[i] == wordArr[j]) { |