Psuedo code basics

Psuedo code is the act of writing out code in plain english. It should be something even non-coders can read. The implementation should follow the same logic as the pseudo code.
 avatar
c0dezer019
javascript
2 months ago
708 B
12
Indexable
Never
// psuedo code basics
/**
 * if what
 *     action #1
 *         data
 *     action #2
 *         data
 * else-if what
 *     action
 *         data
 * else
 *     action
 *         data
 *     ...more actions
 */
 
// example
/**
 * case "east"
 *     if allowed and "east" is direction
 *         print movement action
 *             "Jake goes east to Fakeville."
 *         change Actor.location
 *             "Fakeville"
 * no case
 *     print warning statement
 *         "Can't go there."
 */

// code implementation
const move = dir => {
    switch (dir) {
        case "east":
            // movement logic...
            break;
        default:
            console.log("Can't go there.");
    }
}
Leave a Comment