1
I am creating a visualization in D3.js, in which I am importing the date through a dynamic string that requires a variable, which I named honeystring.
Variable
var honeyyear = document.getElementById("vardatayear");
Import
d3.json( `data/HoneyProduction-${honeyyear}.json`, function( honey_data ){...
Taking into account that Id element vardatayear
does not exist before the display exists, as I guarantee that the variable has a value, such as 2013, if the element does not exist or is null?
That is, what you should do to assign a variable value, by default?
You want your var
honeyyear
comes with value 2013 if the element does not exist or isnull
?– OtavioCapel
Yes @Otaviocapel
– Gonçalo Peres 龚燿禄