Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function saludar(opts) {
- opts.mensaje = opts.mensaje || 'Hola';
- opts.repeticiones = opts.repeticiones || 1;
- opts.nivel = opts.nivel || 'log';
- opts.mayusculas = opts.mayusculas || false;
- var output;
- if (opts.nombre == undefined) {
- output = opts.mensaje;
- } else {
- output = opts.nombre + ': ' + opts.mensaje;
- }
- if (opts.mayusculas == true) {
- output = output.toUpperCase();
- }
- for (var i=0; i < opts.repeticiones; i++) {
- console[opts.nivel](output);
- }
- }
- saludar({
- nombre : 'Alice',
- mensaje: 'ey ey ey!',
- repeticiones : 3,
- nivel : 'warn',
- mayusculas : true
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement