Code highlighting


#1

Hey :wave:,

I noticed some fellow people here using code highlighting. Since I prefer the appearance of code which is highlighted I wanted to ask whether and how it’s achievable in this forum. I know the code tag but it doesn’t seem as if there is code highlighting applied to the code automatically.

Here is some JS for testing purposes:

function factorial(number, sum = 1) {
	sum *= number
	number--;
	if (number > 1) return factorial(number, sum);
	return sum
}

factorial(5)

// -> 120

Or in ES6 fashion:

const factorial = (number, sum = 1) => 
    number > 1 ? factorial(number - 1, sum * number) : sum;

factorial(5)

// -> 120

(I’m actually quite proud of this code :grin:)

Thanks!

Warm regards,
Oscar :+1:t2:


#2

@wyte You can get language syntax highlighting by wrapping the code block like so:

```js
function factorial(number, sum = 1) {
	sum *= number
	number--;
	if (number > 1) return factorial(number, sum);
	return sum
}

factorial(5)