Loc Dang
Loc Dang

Reputation: 73

Use of # in HEX color format

What does # mean in the following code?

function rndm_colour(){
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
      color += letters[Math.floor(Math.random() * 16)];
  }
  return color
}

Upvotes: 0

Views: 113

Answers (2)

Adryan Almeida
Adryan Almeida

Reputation: 36

The code creates a random color in the HEX format. All HEX colors always start with a "#".

Upvotes: 2

user13914236
user13914236

Reputation:

It looks like this function generates a random HTML Color code, which begins with a #.

Upvotes: 2

Related Questions