It looks like you're trying to use 's' before you define it.
var macroStart;
macroStart ="CODE:";
macroStart +="SET !ERRORIGNORE YES" + "\n";
macroStart +="SET !TIMEOUT_TAG 1" + "\n";
macroStart +="SET !TIMEOUT_STEP 1" + "\n";
macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
macroStart +=" SET !REPLAYSPEED FAST" + "\n";
macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
macroStart +="WAIT SECONDS=" +s+ "\n"; //<---'s' doesn't exist yet here
var i=0;
var n=prompt("Input the number",5)
var s=prompt("Input seconds",0) //<--- s only exists here, and later
You'll either need to declare and initialize 's' earlier, or build macroStart later.
JavaScript attempts to be helpful here and turns s into the string 'undefined'. If this were a compiled language like c or java, you would get a compiler error.