Search code examples
arraysnode.jsconsole.logchalk

how to add array to operators?


i just need a yes or a no and possibly a point in the right direction :)

i would like to know how would i be able even do this, chalk is just the same as colors.red, or colors.blue, its just chalk.red or chalk.blue but i would like to make an array that has the different colors that randomize for example, it would be console.log(chalk.arraycolor("this is a test"));

sorry for any problems i will cause, i just need a yes or a no and possibly a point in the right direction :)

this is the code, sorry i could not upload the raw code as its on my raspberry pi


Solution

  • I think want you want is chalk[rand].

    Note that foo["bar"] is the equivalent of foo.bar.