






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of pseudocode as a design strategy for solving complex problems in javascript. Pseudocode is an english-like description of the steps required to solve a problem, focusing on determining the necessary steps without worrying about programming language syntax issues. An example of pseudocode for finding the minimum value and explains the constructs used in pseudocode, including input, output, assignments, repetition structures, and conditionals.
Typology: Assignments
1 / 11
This page cannot be seen from the preview
Don't miss anything!







So far we have focused on the syntax and semantics of JavaScript As the complexity of problems increase you need a design strategy to solve such problems Several alternatives exist to come up with a solution to a problem. A popular one is Pseudocode
Pseudocode: English-like description of the set of steps required to solve a problem
When you write pseudocode you focus on determining the steps necessary to solve a problem without worrying about programming language syntax issues
When writing pseudocode you need the following constructs: Input Output Assignments Repetition Structures Conditionals To help you with the design of pseudocode you can use the following syntax to represent the above constructs
Input variable = read() e.g., x = read() Output print(variable) e.g., print(x) Assignment x = e.g., x = 20, s = “Bob” Repetition while (expression) { OR do { stmts stmts } } while (expression)
Notice the above constructs look like JavaScript code but they are not JavaScript code
How Good Is Your Pseudocode
Your code does not use language constructs that are particular to a programming language
Anyone receiving the pseudocode will not need to ask you questions in order to transform the pseudocode into code (no matter what the target programming language is)
do while Statement
do while statement – Allows repetition of a set of statements
Basic Form do { statement // executed as long as expression is true
Notice the semicolon after the expression in parenthesis Executes the statement at least once You don’t need the { } if you only need to execute one statement Example: DoWhileNumbers.html Example: DoWhile.html Any type of statements (including do whiles) in a do while When to use a do while? When to use a while?
Creating a Bookmark in a Document
Web Site Snapshot/Video
Online Example: http://www.cs.umd.edu/class/spring2009/cmsc122/projects/p2/p2Description.html#Sample_Output
Coding Example
Let’s write a program that reads a password and allows a maximum of two attempts
We can expand the program to have a menu of options once the appropriate password has been provided
Using “\n” to define menu entries