Javascript has function scoping, which means that any variables declared in a function can't be accessed outside of that function. return added returns the value of added, not the variable added itself. If you want to use that value, you need to put it in a variable that was declared outside the function:
function first(){
    var now = new Date();
    var first=Math.round(now.getMilliseconds()/20);
    var second=Math.round(now.getMilliseconds()/30);
    var added=first+second;
    return added;
}
var firstResult = first();
document.write(firstResult);
More advanced, but related: Types of Javascript Variable Scope