Ask coding questions

← Back to all posts
KhShahid (9)

Hey, i am making a among us.
I need help from pro coders i am a noob so help me,
if you helped me than i complete making this among us you can enjoy it, so help me,
How to color text in js like that

And how to clear console

19wintersp (1120)

In a terminal, you can do colours by printing the control character 0x1b, followed by a colour code. Here are some examples:

  • "\u001b[30m" - Black
  • "\u001b[31m" - Red
  • "\u001b[32m" - Green
  • "\u001b[33m" - Yellow
  • "\u001b[34m" - Blue
  • "\u001b[35m" - Magenta
  • "\u001b[36m" - Cyan
  • "\u001b[37m" - White

You can also set the background colour:

  • "\u001b[40m" - Black
  • "\u001b[41m" - Red
  • "\u001b[42m" - Green
  • etc

If you log one of these, the text after it will be the corresponding colour. To reset the colour, use "\u001b[0m".

To clear the console in JavaScript, use the console.clear() function.