Simply replace the embedded "s with \".
Alternatively you can alternate single and double quotes. It looks a bit more elegant, though it can be a little harder to remember.
document.writeln("<tr><td style=\"background-color:#FFFF00;\">" + "test" + "</td></tr>");
document.writeln('<tr><td style="background-color:#FFFF00;">' + 'test' + '</td></tr>');