Girl Develop It Buffalo

JS101 Class 1 Homework: Strings

Home

These exercises will test your knowledge of string functions. For many of them, you will want to consult the JavaScript strings reference to find useful string methods to call.

Dr. Evil

Create a function called DrEvil. It should take a single argument, an amount, and return '<amount> dollars', and it will add '(pinky)' at the end.

For example:

DrEvil(1000000);

Prints: 1000000 dollars (pinky)

mixUp

Create a function called mixUp. It should take in two strings, and return the concatenation of the two strings (separated by a space) slicing out and swapping the first 2 characters of each. You can assume that the strings are at least 2 characters long. For example:

mixUp('mix', pod');

Returns:'pox mid'

Look up the JavaScript string reference to find methods which may be useful!

fixStart

Create a function called fixStart. It should take a single argument, a string, and return a version where all occurences of its first character have been replaced with '*', except for the first character itself. You can assume that the string is at least one character long.

fixStart('babble');

Returns: 'ba**ble'