This JavaScript tutorial explains how to use the string approach called fontcolor() with syntax and examples.
Description
In JavaScript, fontcolor() is a string technique that is used to create the HTML component and specify a font color. Because the fontcolor() technique is a method of the String object, it should be invoked via a particular occasion of the String class.
Syntax
In JavaScript, the syntax for the fontcolor() technique is:
string.fontcolor(color_value);
Parameters or Arguments
color_value It is a color title or shade price that will be used as the color attribute for the element.
Returns
The fontcolor() approach returns a string containing a element. The cost of the color_value parameter is used as the coloration attribute for the element.
Note
The fontcolor() approach does no longer change the fee of the original string.
Example
Let’s take a look at an instance of how to use the fontcolor() approach in JavaScript.
For example:
var totn_string = 'TechOnTheNet';
console.log(totn_string.fontcolor('blue'));
In this example, we have declared a variable referred to as totn_string that is assigned the string cost of ‘TechOnTheNet’. We have then invoked the fontcolor() method of the totn_string variable to return a string that carries the HTML aspect with a font color.
We have written the output of the fontcolor() approach to the net browser console log, for demonstration purposes, to show what the fontcolor() approach returns.
The following will be output to the net browser console log:
<font color="blue">TechOnTheNet</font>
As you can see, the fontcolor() approach created a string that carries a element. The fee of the totn_string variable (which is ‘TechOnTheNet’) is enclosed inside the and tags. The string cost of ‘blue’ that was handed into the fontcolor() approach as a parameter is used as the coloration attribute for the element.
Leave a Review