You are on page 1of 2

M-15112019-1

Simple Pig Latin


Move the first letter of each word to the end of it, then add "ay" to the end of the
word. Leave punctuation marks untouched.
Examples
pigIt('Pig latin is cool'); // igPay atinlay siay oolcay
pigIt('Hello world !');     // elloHay orldway !
ALGORITHMS
Solution:
1
function pigIt(str){
2
 //Code here
3
}
Sample Tests:
1
pigIt('Pig latin is cool'),'igPay atinlay siay oolcay'
2
pigIt('This is my string'),'hisTay siay ymay tringsay'
----
M-15112019-2
First non-repeating character
Write a function named first_non_repeating_letter that takes a string input, and
returns the first character that is not repeated anywhere in the string.
For example, if given the input 'stress', the function should return 't', since the letter t
only occurs once in the string, and occurs first in the string.
As an added challenge, upper- and lowercase letters are considered the same character,
but the function should return the correct case for the initial letter. For example, the input
'sTreSS' should return 'T'.
If a string contains all repeating characters, it should return an empty string ("") or None --
see sample tests.
ALGORITHMS STRINGS DATA TYPES SEARCH LOGIC

1
Solution:

function firstNonRepeatingLetter(s) {
2
 // Add your code here
3
}

Sample Tests:
firstNonRepeatingLetter('a'), 'a');
4
firstNonRepeatingLetter('stress'), 't');
5
firstNonRepeatingLetter('moonmen'), 'e');
6
 
----
M-15112019-3
Where my anagrams at?
Instructions
What is an anagram? Well, two words are anagrams of each other if they both
contain the same letters. For example:
'abba' & 'baab' == true
 
'abba' & 'bbaa' == true
 
'abba' & 'abbba' == false
 
'abba' & 'abca' == false
Write a function that will find all the anagrams of a word from a list. You will be given
two inputs a word and an array with words. You should return an array of all the
anagrams or an empty array if there are none. For example:
anagrams('abba', ['aabb', 'abcd', 'bbaa', 'dada']) => ['aabb', 'bbaa']
 
anagrams('racer', ['crazer', 'carer', 'racar', 'caers', 'racer']) => ['carer',
'racer']
 
anagrams('laser', ['lazing', 'lazy',  'lacer']) => []

ALGORITHMS STRINGS
Solution:
1
function anagrams(word, words) {
2
}

You might also like