From the following function, how do I substitute blank spaces with hyphens?
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8" />
<title>Ej funciones</title>
</head>
<body>
<script type="text/javascript">
var texto=prompt ("Introduce el texto");
function espaciosEnBlanco() {
var sustituye=texto.split(" ");
var operacion=texto.replace(sustituye, "-");
alert(operacion);
}
espaciosEnBlanco();
</script>
</body>
</html>