Chapter 8 Studio (8.6.1) - JS


I’m having a lot of trouble with this and I can’t seem to figure out exactly how to do what is being asked, any help at all would be great:

8.6.1. String Modification

Use string methods to convert a word into pseudo-pig latin.

1. Remove the first three characters from a string and add them to the end. Ex: 'LaunchCode' becomes 'nchCodeLau'. Use a template literal to print the original and modified string in a descriptive phrase.
2. Modify your code to accept user input. Query the user to enter the number of letters that will be relocated.
3. Add validation to your code to deal with user inputs that are longer than the word. In such cases, default to moving 3 characters. Also, the template literal should note the error.

#1. is what I’m not sure how to do. Is it asking us to do this in 1 line since strings are immutable? If so what method to use? Are we method chaining to make it work?

#2 & # 3 I know I will run into trouble. Just hoping someone here has done this before or recognizes what they mean and can help me out…thanks

Greetings Will.

#1 So, in my opinion, it doesn’t really matter which way you do it, because unless you copy and paste and answer that you find from somewhere, the goal is to use methods that modify the string. So, whether you do it in one line or two, isn’t super important right now! The goal is to understand these methods and the difference between them.

The methods that you should use are here: 8.6. Studio: Strings and Arrays — Introduction to Professional Web Development in JavaScript documentation