also known as
There are several steps that should be thought through during the problem solving process.
Gather requirements
Break down problem
Write pseudocode
Code a solution
Test the solution
Consider possible changes
The goal is to clarify the problem to the point that there are no more questions.
Examine the question and determine if it can be broken down into small parts, such as “Write a function” or “If this then do that”
Once you have broken down the question, establish the priority of each part then work on each part in the appropriate order
Pseudocode is a step-by-step description of an algorithm written in simple English using a code-like structure.
Use plain old English, like explaining your code to your Grandma.
Example:
Enter Value
If Value greater than 10
Log "Your number is greater than 10"
If Value less than 10
Log "Your number is less than 10"
Write a function that takes in two integers and returns their sum, unless the two integers are equal. If the two integers are equal, then return three times their sum.
Examples:
sum2Integers(10, 20) // --> 30
sum2Integers(10, 10) // --> 60
Write a function that takes in integers and returns the integer with the highest value.
(Do NOT use Math.max()!!!)
Example:
findHighest(5, 8, 1) // --> 8
findHighest([4, 1, -3]) // --> 4
Take note of the argument data type options.
Write a function that generates a random number between 0-10.
If the number is greater than 5, log “{number} is greater than five!”.
If it is less than 5, log “{number} is less than five!”
Examples:
isFive()
Write a function that counts the number of vowels in a string.
The vowels are "a", "e", "i", "o" & "u"
Examples:
countVowels('hello') // --> 2
countVowels('why') // --> 0
Write a function that determines if a string is a palindrome.
A palindrome is a string that is the same forward and backwards.
Examples:
isPalindrome('racecar') // --> true
isPalindrome('table') // --> false
Write a function that determines if a number is prime.
Examples:
isPrime(11) # --> True
isPrime(6) # --> False
Write a function that accepts 2 arguments:
student name and indeterminate number of
test scores
The function should output the name, scores and the average of the scores.
The output should be grammatically correct.
Example:
avgTestScores('John', 95, 70, 87, 82)
# --> John took 4 tests, earning these score(s): 95, 70, 87 and 82.
# --> That's an average score of 83.5.
Write a code block that takes in a list of dictionaries and draws buildings with the character provided.
Each building dictionary shall have two required keys: width and height and one optional key: char.
If the char key is not provided then it should default to: "#".
Example:
drawBuildings([
{'width': 2, 'height': 2, 'char': '%'},
{'width': 3, 'height': 5, 'char': '@'},
{'width': 1, 'height': 3}
])