original-preview logo
hero background

Hi there, do you need help?

We have 55 Answers and 7 Categories

Found 0 Answers

How to add Code blocks

author picture

Anthony Wilcox

Contect Creator


In the answer editor you can include Code blocks in your answers.


Code blocks will help you write some technical specification or part of your product where your users will need to work with code. You can provide step by step instructions to your users which readable and highlighted code blocks.


To add a Code block, follow the steps below:

STEP 1

  • Go to the Answer editor and open the answer you want to edit.
  • On the menu on the right grab the 'Code' block.
  • Drag it in the answer editor with the cursor.
  • Drop it anywhere in the answer where you want the code block to appear.
Codeblock

STEP 2

In the modal:

  • Paste the code that you want to add.
  • Select the language in the dropdown selector.
  • Click 'Add'
Add codeblock


Once you click on 'Add' your code block will be added to your answer.


To move, edit or delete the code block, you can hover over the it and click on the action buttons in the top left corner, as shown in the picture below:


Move edit or delete


Here is a live example of a code block:


// taking kilometers input from the user
const kilometers = prompt("Enter value in kilometers: ")

// conversion factor
const factor = 0.621371

// calculate miles
const miles = kilometers * factor

console.log('${kilometers} kilometers is equal to ${miles} miles.');


That's it!


Did we answer your question?

😃 🤔 ☹️

How can we improve this answer?

Knowledge Base Software by answerly.io