Good stuff! But why does name seem to be undefined?
name
undefined
Are you sure that document.write() is a great help at declaring a variable?
document.write()