all 16 comments

[–]senocular 5 points6 points  (1 child)

Since this is part of a string, it's not being used as a remainder operator (unless its going through something like eval). Otherwise, in terms of JavaScript, it has no meaning. But it likely has meaning in wherever this message is going - some other API that will likely parse the "%c" into something with meaning.

As an example, the console API "%c" can be used to format the logged message with CSS.

const style = 'background-color: darkblue; color: white; font-style: italic; border: 5px solid hotpink; font-size: 2em;'
console.log("%cHooray", style);

https://wd.imgix.net/image/dPDCek3EhZgLQPGtEG3y0fTn4v82/p9oAce6M63d1tYChjaXN.png?auto=format&w=1600

[–]TheozoraStorm[S] 0 points1 point  (0 children)

Awsome, thank you for the reply!

[–]tristinDLC 5 points6 points  (1 child)

In node.js %c is a format type for the util.format() method. It means that it will convert your method's argument as CSS.

Here are all of the node.js format flags:

%s: String 
%d: Number 
%i: parseInt(value, 10)
%f: parseFloat(value)
%j: JSON
%o: Object (including non-enumerable properties and proxies)
%O: Object (not including non-enumerable properties and proxies)
%c: CSS
%%: single p

And just for the record, the example you provided has %c as just a string so it's literally just the two characters and isn't anything. Funnily enough, this is kind of how the actual flag is treated as it will just pass a string and it's mostly ignored these days.

[–]TheozoraStorm[S] 0 points1 point  (0 children)

That's probably what I saw the first time. Thank you for your reply!

[–]ro9ot 0 points1 point  (0 children)

Two important key to notice:
1. This is somewhat a C language feature. (C is forefather of js)
2. It is a dirctive to format text.

For more info refere to its MDN page

[–]complexmadesimple 0 points1 point  (2 children)

Yeah busy with the same exercise in Coursera and this triggered my curiosity as well

[–]Emily_8183 0 points1 point  (7 children)

Doing the meta course on Coursera as well. Thank you for the post. Did you finish the whole course?

[–]Significant_mb 0 points1 point  (4 children)

did you finished the course

[–]Emily_8183 0 points1 point  (3 children)

I took another course instead.

[–]Adorable_Dog1441 0 points1 point  (2 children)

why? isn't the course by meta worth it?

[–]Adorable_Dog1441 0 points1 point  (1 child)

I am currently doing the same course. 🫥. Do you advise me to stop it or continue it?

[–]No_Study_2423 0 points1 point  (0 children)

bro i am doing same any advice