curriculum/challenges/english/blocks/lab-reverse-a-string/a202eed8fc186c8434cb6d61.md
In this lab, you will build a simple string inverter that reverses the characters of a given string.
For example, "hello" should become "olleh".
Objective: Fulfill the user stories below and get all the tests to pass to complete the lab.
User Stories:
reverseString that takes a string as an argument.You should have a function named reverseString.
assert.isFunction(reverseString);
reverseString should take a string as an argument.
assert.match(reverseString.toString(), /\s*function\s+reverseString\s*\(\s*\w+\s*\)/);
reverseString("hello") should return a string.
assert.isString(reverseString('hello'));
reverseString("hello") should return the string olleh.
assert.strictEqual(reverseString('hello'), 'olleh');
reverseString("Howdy") should return the string ydwoH.
assert.strictEqual(reverseString('Howdy'), 'ydwoH');
reverseString("Greetings from Earth") should return the string htraE morf sgniteerG.
assert.strictEqual(
reverseString('Greetings from Earth'),
'htraE morf sgniteerG'
);
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString('hello');