about | help | code help+videos | done | prefs |
Given an input String, first decide if the String contains "I (something) you", like "I will find you". If it does not contain "I (something) you", return "I don't understand". Note that "I (something) you" could occur anywhere in the input. If it does contain "I (something) you", return a response that includes part of the input in the form "Why do you (something) me?" If you are still confused, see the input/output test cases. Note that "I " must be BEFORE " you" in the input in order to work correctly. Also note that specific space characters are integral parts of what to look for in the input, not just the letters. HINT: use indexOf to find the desired two patterns, and remember their locations. Use substring to capture a portion of the input, which becomes part of the output. CHALLENGE: solve in one statement, which can pretty easily be done with a ternary operator.apcsaChatbotsRearrangeContainsIYou("I like you") → "Why do you like me?" apcsaChatbotsRearrangeContainsIYou("Help") → "I don't understand" apcsaChatbotsRearrangeContainsIYou("I am Groot") → "I don't understand" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy