← Other topics

Coding Psych Experiments
Markdown

Video Notes

Markdown is a popular and simple code syntax used to indicate the style of text for display. We’re learning Markdown for two reasons:

Reason 1) It’s a good way to “dip our toes” into programming and get familiar with the process of writing code and having it produce some result.

Reason 2) Markdown is widely used across many different programming contexts. Here are some of the places you’ll encounter it:

Markdown basics

The following is a quick reference sheet of the basic Markdown syntax you’ll need to know for this course. Paste this code into the online markdown editor StackEdit to see how it’s rendered.


## Basic text formatting

**This text is bold - it must be important**

_This text is italicized; you should probably pay attention to it..._

[Click this link to learn about jsPsych...](https://www.jspsych.org)

Lists are created using asterisks or plus signs:
+ Item 1
+ Item 2
  + Items can be nested via indentation

## Code
Inline code can be styled using backticks like this: `alert('hi!');`

Blocks of code can be formatted by surrounding them in “code fences”, indicated by three backticks (```)

The starting code fence should include the language extension for the code being used. In the following example that's `js` for JavaScript code.

Example code block:

```js
document.write('Hello World!');

for (let i of [1, 2, 3]) {
    document.write(i);
}
```

Learn more

For more on working in Markdown, check out the following resources from MarkdownGuide.org:

Practice

Using the reference sheet above, write some Markdown code in StackEdit that produces the following styled content:

function generateRandomLetters(length) {
    const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    let result = '';
    for (let i = 0; i < length; i++) {
        const randomIndex = Math.floor(Math.random() * alphabet.length);
        result += alphabet[randomIndex];
    }
    return result;
}

document.write(generateRandomLetters(5));

Here’s an example of what the rendered results should look like:

Unlock all the notes for $4

No subscriptions, no auto-renewals.

Just a simple one-time payment that helps support my free, to-the-point videos without sponsered ads.

Unlocking gets you access to the notes for this video plus all 200+ guides on this site.

Your support is appreciated. Thank you!

Payment Info

/
$4 6 months
$25 forever
Please check the form for errors
Questions? help@codewithsusan.com
← Other topics