Thursday, March 25, 2021

What is Git Markdown?

Git Markdown is a markup language that creates HTML-like documents for web-based Git repos like GitHub, GitLab, and Bitbucket.

The documents are documentation for your repo. They describe topics such as installation, configuration, and deployment. They document development and contribution procedures. The topics are up to you.

Markdown files render like HTML in web-based Git repos. They are popular in repos and expected by developers.

A Markdown file is nothing more than a text document with the file extension .md. The file contains Markdown syntax. Here is an example of a Level 1 header:

# My Repo

The single # indicates a Level 1 header. Two ## indicate a Level 2 header:

## Installation

Here is a sample list:

* lions
* tigers
* bears
...and a sample numbered list:
1. Wash
1. Rinse
1. Repeat
Note that the numbers are all 1s, but they will appear as 1, 2, and 3 when they render in the browser.

There are many other ways to format text in a Markdown file. Some organizations extend Markdown syntax for their platforms. But the core Markdown syntax is complete enough to get started.

Learn Markdown syntax and start creating Markdown files. At the very least, create a README.md file at the top level of your repos. Then see how the browser automatically renders that file as HTML in your web- based repo. All serious repos have a README.md file.

Wednesday, March 24, 2021

How to use JavaScript template strings

JavaScript Template Strings are another way to create and combine strings. The technique is simple once you know the syntax.

Here is a code snippet with three string variables:

const str1 = 'Coffee ';
const str2 = 'and ';
const str3 = 'code';

One way to combine the strings is the concat() function:

const combinedStr = str1.concat(str2, str3);
console.log(combinedStr); // outputs: Coffee and code

Another way to combine them is the + operator:

const combinedStr = str1 + str2 + str3;
console.log(combinedStr); // outputs: Coffee and code

And here is how to combine the strings with a JavaScript Template String:

const combinedStr = `${str1}${str2}${str3}`;
console.log(combinedStr); // outputs: Coffee and code

To create a Template String:

  1. Start and end the Template String with a backtick (`).
  2. Put your variable, expression, or data between ${ and }. JavaScript evaluates this value.
  3. Other characters in the Template String are just literal characters.
Here is another Template String example that combines literal characters with a random number:

const num = Math.random();
const combinedStr = `Here is a random number: ${num}.`;
console.log(combinedStr); // sample output: Here is a random number: 0.07571510037185902.

JavaScript Template Strings are another way to combine and create strings. The technique is convenient and simple. Some JavaScript lint tools prefer Template Strings over string concatenation. So that is another reason to learn them.









What is Git Markdown?

Git Markdown is a markup language that creates HTML-like documents for web-based Git repos like GitHub, GitLab, and Bitbucket. The documents...