Q:

Function that adds equal amount of whitespace to both ends of string

function space(str,numSpace){
     str = "";
     numSpace = (" " + " ");
     document.write(numSpace + str + numSpace);
}
console.log(space("hi", " "));

This is not working out, I'm not too sure how I can add whitespace to both ends of a string.

A:

This is not working out, i'm not too sure how I can add whitespace to
  both ends of a string.

you're always resetting the parameter str to empty string hence the unexpected behaviour.
there are two ways you could solve the issue at hand.
1) you could use console.log() inside the method, example:
function space(str, numSpace) {
    var result = numSpace + str + numSpace;
    console.log(result);
}
space("hi", " ");

2) you could return the value then use console.log():
function space(str, numSpace) {
    return numSpace + str + numSpace;
}
var result = space("hi", " ");
console.log(result);

