Enclosing function's argument withing single quotes

Hi all.

In the javascript module, the variables passed as function arguments were not enclosed in single quotes '. This is while coding in a text editor or sublime text

But in the data visualisation module, the variables for setChartLibrary, setChartType and plotChart function are being enclosed in single quotes '. This is while coding in the code editor in the cloud. Without enclosing the variables in single quotes, there is an error message shown.

Why is this different for the bolt cloud’s code editor?

Thanks in advance

Hi @b.utkarsh,

setChartTitle('Your Graph Title');
setAxisName('X-Axis Name','Y-axis Name');

We are not passing variables in those functions, we are directly passing the values to the function.
So “lineGraph” is not a variable, it is a value in string format. If you open the inspect element on your control page and if you look into the boltGraph.js file, you will find there is one function plotChart is defined. We are just calling those functions and passing the argument as a string.

Do let me know in case you need further assistance.


I think I miscommunicated the issue here.

Actually I want to know that the arguments in plotChart() function are variables here, but still they are enclosed in single quotes, unlike how it was done inside HTML script. Why is it different in the cloud’s editor?

Hi @b.utkarsh,

Lets understand this example:

Suppose we have a plotChart function defined in some JS library that Bolt Cloud is using and plotChart function takes the graph_type as parameters and it print the graphtype in console. This is called function definition.

function plotChart(graph_type){

Now we want to use this function, we can call this function using the below method.

graph_name  = 'LineGraph'

In the above code, we have assigned the value ‘LineGraph’ to the variable graph_name and then we are passing variable graph_name while calling the plotChart function and plotChart function will print the’ LineGraph’ in the console.

Now suppose we don’t want to use the graph_name variable, in that case you can directly pass the value LineGraph to the plotChart function using the single and double quotes.


Now suppose, you use LineGraph without single and double quotes, then it will behave like a variable. You will get the LineGraph is undefined error.

Do let me know in case you need further assistance.

Hi @rahul.singh1.

Let me elaborate on the doubt I have.

Let’s consider the example of the plant monitoring system’s code


I don’t know about time_stamp, but as far as I know, light is a variable we are collecting. Shouldn’t the variable, in this case, light, be enclosed without single/double quotes? Or is it that the argument 'variable' being passed implies that the value of the variable is being fed to the function?

Hi @b.utkarsh,

The variable that you have created while configuring the product is not a javascript variable. It is actually a database field name. Now when you do plotChart('time_stamp', 'light'); you are telling the javascript code to fetch the values from the ‘light’ fields of Bolt Cloud database and it is handled by plotChart function internally.


Thank you very much for the explanation @rahul.singh1.

1 Like