-
Make variables called:
- “total number of dots” and set its value to 0.
- “number of dots” and set its value to 1.
- “cards” and set its value to the string entered as the input. Check each letter of the input string “cards” (use a loop to iterate the number of letters in the input) starting from the last letter. If it’s ‘W’ add the corresponding number of dots (1 for the last letter, 2 for the second to last letter and so on) to the “total number of dots”. Display the “total number of dots” as the output.
- “index” and set its value to the number of letters in the input. Use this variable to access a letter at the “index” position in the string.
-
You can access a letter at the specified position in a string by using the 'Letter of' block under “Operators”.
-
In this challenge you need to access all the letters in user’s input and check to see if each of them is equal to B (black) or W (white).
-
You can find how many letters a string has by using the 'Length of' block under “Operators”.
-
The 'If' block checks if the condition is true and then runs the blocks inside of the IF block. In this challenge you need to check if each letter of the input is equal to ‘W’ or “B’.