Chapter Two: Code and Technical Writing

Writing About Code

Sometimes we need to show code examples. Here's a simple JavaScript function:

function greetReader(name) {
  return `Hello, ${name}! Welcome to the book.`;
}

const message = greetReader("Reader");
console.log(message);

We can also write inline code like const x = 42 within our paragraphs.

Python Examples

Here's a Python example for calculating reading time:

def calculate_reading_time(text, words_per_minute=200):
    word_count = len(text.split())
    minutes = word_count / words_per_minute
    return round(minutes, 1)

book_text = "Your book content here..."
print(f"Reading time: {calculate_reading_time(book_text)} minutes")