|
| 1 | +/** |
| 2 | + * Takes two strings including only letters from a to z. |
| 3 | + * Returns a new sorted string containing distinct letters. |
| 4 | + * |
| 5 | + * @param {string} value1 |
| 6 | + * @param {string} value2 |
| 7 | + * @return {string} |
| 8 | + * |
| 9 | + * @example |
| 10 | + * 'azy', 'bk' => 'abkyz' |
| 11 | + * 'zxxlal','laxk' => 'aklxz' |
| 12 | + * 'abcdefghijklmnop', 'lmnopqrstuvwxyz' => 'abcdefghijklmnopqrstuvwxyz' |
| 13 | + */ |
| 14 | +export function distinctLettersString(value1, value2) { |
| 15 | + /* implement your code here */ |
| 16 | + throw new Error('Not implemented'); |
| 17 | +} |
| 18 | + |
| 19 | + |
| 20 | +/** |
| 21 | + * Takes a string with any characters. |
| 22 | + * Returns an object containing appearence of every distinct letters in lower case. |
| 23 | + * |
| 24 | + * @param {string} value |
| 25 | + * @return {Object} |
| 26 | + * |
| 27 | + * @example |
| 28 | + * 'Who you are, Buddy?' => { a:1, d:2, e:1, h:1, o:2, r:1, u:2, y:2 } |
| 29 | + * |
| 30 | + */ |
| 31 | + |
| 32 | +export function lowerLetters(value) { |
| 33 | + /* implement your code here */ |
| 34 | + throw new Error('Not implemented'); |
| 35 | +} |
| 36 | + |
| 37 | +/** |
| 38 | + * Write a function that will convert a string into title case, given an optional |
| 39 | + * list of exception (minor words). The list of minor words will be given as a |
| 40 | + * string with each word separated by a space. Your function should ignore the |
| 41 | + * case of the minor words string - it should behave in the same way even if the |
| 42 | + * case of the minor word is changed |
| 43 | + * |
| 44 | + * @param {string} the original string to be converted |
| 45 | + * @param {string} list of minor words that must always be lowercase except for |
| 46 | + * the first word in the string |
| 47 | + * @return {string} |
| 48 | + * |
| 49 | + * @example |
| 50 | + * 'a clash if KINGS', 'a an the of' => 'A Clash of Kings' |
| 51 | + * 'THE WIND IN THE WILLOWS', 'The In' => 'The Wind in the Willows' |
| 52 | + * 'the quick brown fox' => 'The Quick Brown Fox' |
| 53 | + */ |
| 54 | + |
| 55 | +export function titleCaseConvert(title, minorWords) { |
| 56 | + /* implement your code here */ |
| 57 | + throw new Error('Not implemented'); |
| 58 | +} |
| 59 | + |
| 60 | +/** |
| 61 | + * Your job is to create a calculator which evaluates expressions in Reverse Polish |
| 62 | + * notation (https://en.wikipedia.org/wiki/Reverse_Polish_notation). Empty expression |
| 63 | + * should evaluate to 0. Expression without operation returns the last number. |
| 64 | + * |
| 65 | + * @param {string} RPN string, each number and operation separated by a space |
| 66 | + * |
| 67 | + * @return {Number} |
| 68 | + * |
| 69 | + * @example |
| 70 | + * '' => 0 // empty expression returns 0 |
| 71 | + * '1 2 3' => 3 // expression without operation returns the last number |
| 72 | + * '4 2 +' => 6 // 4 + 2 |
| 73 | + * '2 5 * 2 + 3 /' => 4 // ((5 * 2) + 2) / 3 |
| 74 | + * '5 1 2 + 4 * + 3 -' => 14 // 5 + ((1 + 2) * 4) -3 |
| 75 | + */ |
| 76 | + |
| 77 | +export function calcRPN(expr) { |
| 78 | + /* implement your code here */ |
| 79 | + throw new Error('Not implemented'); |
| 80 | +} |
0 commit comments