The question is a bit ambiguos at start but if you look at the code carefully you will understand the each step.
It asks you to create a "doDisplay" variable, you can do that by creating a variable same as doPlot below the doPlot variable.
doPlot = randi([0 1]);
doDisplay = randi([0 1]);
It asks you to add an elseif block which can toggle whether it can display the densities or not.