From the course: Learning Go
Use code challenges on CoderPad - Go Tutorial
From the course: Learning Go
Use code challenges on CoderPad
- [Instructor] This course includes automated code challenges that appear when you click on the challenge links in the course's table of contents. Each challenge includes instructions and a couple of code editors that you can use to create and test your own solution to the challenge. These challenges are hosted by CoderPad and they appear in the same area of the course page where you watch the course's videos. We recommend using a desktop browser for the best experience with code challenges, but you can use the LinkedIn Learning mobile app if you prefer. A code challenge has four areas. Instructions in the top left, a code editor for your answer in the top right, another code editor where you'll see the code that will be calling your code in the bottom right, and the console output in the bottom left. You can use these drag handles to reallocate space as needed, and you may see, the first time you run code, that the console output expands vertically. Each challenge has instructions that include a description of the challenge and the challenge's parameters and desired result. Parameters are values that will be passed into your code and they have to be of a particular data type. The return value also has to be of a particular data type, and you'll see that noted in the instructions. If there's a constraints section, it will have useful information about the parameters that will be passed in. The examples show different parameter values and what result will be returned for each of those test cases. Create your answer in the top right code editor. You'll start with an answer that compiles but is incorrect, and when you click Test my code, you'll run that code and see an error message. Notice these two variables, showExpectedResult and showHints. These are Boolean values that you can change to see more information in the console output. I'll change these to true and test the code again, and this time I see that the expected result is 19 and I get a hint. You can also change the values in the test code. For example, right now the largest number is 19. I'll change this to 56 and run the code, and this time I see that the expected result is 56. Now, your job is to add code that's correct, and I'm going to add some code that I've already created in the clipboard. I'll comment out this return statement, and notice that the sort package hasn't been imported. I'll place the cursor after the package name and press control and space, and I'll choose the sort package and that imports it at the top of the code. Now I'm ready to run the code again, and this time I see a message indicated that I got it right. Regardless of whether your answer is successful, you'll see messages in the console output in that lower left corner. If any messages are too long to fit in that area, you can scroll sideways to see all of the text, and when you've finished each code challenge, return to the course's table of contents, and click on the next item to see my solution.