1
Student
100%
Completion rate
invertCase.js
Implement and export as default a function that changes the case of each letter in the string to the opposite.
Examples:
invertCase('Hello, World!'); // hELLO, wORLD!
invertCase('I loVe JS'); // i LOvE js
Tips
- To find out the length of a string, use the
length
property:
'welcome'.length; // 7
- To convert a string (or a single character) to uppercase, use the
toUpperCase()
method:
'foo'.toUpperCase(); // 'FOO';
'f'.toUpperCase(); // 'F';
- To convert a string (or a single character) to lowercase, use the
toLowerCase()
method
'BAR'.toLowerCase(); // 'bar';
'b'.toLowerCase(); // 'b';
For full access to the challenge you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.