Write a JavaScript program that asks a user for their name, then, uses a function to do the following:

1. reverses the name;
2. replaces all the vowels with asterisks (*);
3. takes the first two letters and then adds a random number between 100 and 300 to it. The results should be written to the browser window using "document.write". Post the code to your solution below.

Respuesta :

tonb

Answer:

       function DoStuff(name) {

           document.write('Reversed: ', name.split("").reverse().join(""), '<br/>');

           document.write('Masked vowels: ', name.replace(/[aeiouy]/ig, '*'), '<br/>');

           document.write('First two with number: ', name.slice(0, 2) + Math.floor(Math.random() * (300 - 100 + 1) + 100), '<br/>');

       }

       const name = prompt("Please enter your name", "Brainly exercise");

       DoStuff(name);

Explanation:

Brainly won't let me paste html here, so I'm just showing you the javascript. Let me know if you don't know how to embed this in a page. I'm a bit unsure about subassignment number 3. Does 'add' mean 'append' here?