Add delay to javascript?

Hello, Let me make this quick.
I’m using this script for a flashlight.

Now under the section " batteryLife = Mathf.Clamp(batteryLife+batteryPower, 350, 99)"
the script is “replacing the battery”.
Now my question is:
How to add and where to add that the flashlight turns off for an amount of time and then turn on again?
I mean like to set like: When the battery starts to reload, set spotlight intensity to 0.
After the set amount of time (6 seconds for example) then the intensity should be set to “1.35”.
Please help!
Thanks!

function ReplaceBattery ()
{
flashlightLightSource.intensity = 0;
yield WaitForSeconds (6);
flashlightLightSource.intensity = 1.35f;
}

This is the simplest example of delaying commands. Call this function there where you want to replace that battery.