Question

In: Computer Science

Please Use JavaScript and P5 1) Greeter Create an page with an input, and a button....

Please Use JavaScript and P5

1) Greeter

Create an page with an input, and a button. When the button is clicked, output the phrase "Hello {Name}" to the developer console, with {Name} being the value the user put into the input field.

Use a function that takes the name as an argument, and returns the full phrase as its output.

Solutions

Expert Solution

Code:

let input, button, greeting;

function setup() {
  // create canvas
  createCanvas(710, 400);

  input = createInput();
  input.position(20, 65);

  button = createButton('submit');
  button.position(input.x + input.width, 65);
  button.mousePressed(() => {greet(input.value())});

  greeting = createElement('h2', 'what is your name?');
  greeting.position(20, 5);

  textAlign(CENTER);
  textSize(50);
}

function greet(name) {
  greeting.html('Hello ' + name);
  input.value('');
  console.log("Hello " + name);
}

Code screenshot:

Output Preview before giving input:

Output Preview after giving input:

Developer console output:


Related Solutions

Please Use Javascript and P5 Pongish Create a one player pong game. This should have: 1....
Please Use Javascript and P5 Pongish Create a one player pong game. This should have: 1. A paddle/rectangle controlled by the player on the right of the screen (moves up/down) 2. A ball/circle that starts moving to the left of the screen. 3. This ball bounces off the TOP, BOTTOM, and LEFT of the screen. 4. This ball bounces off the paddle (use hitTestPoint) 5. If the ball goes beyond the right of the screen, place the ball back at...
Please take the code below and add some javascript to it. Please use javascript inline. Please...
Please take the code below and add some javascript to it. Please use javascript inline. Please be sure to specify within the webpage with something like 'Click here' too show what was done and how to activate it. Please post in a format that can be directly copied. Thank you in advance HINT: add some fun widgets to the page index-css.html: <!DOCTYPE html> <html lang="en"> <head> <!-- title for web page --> <title>Index-CSS Page</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1">...
The code to create a Search/Filter Data with Javascript or html from html page.
The code to create a Search/Filter Data with Javascript or html from html page.
Use external CSS and Javascript files. Use the HTML5 elements to layout the page. In a...
Use external CSS and Javascript files. Use the HTML5 elements to layout the page. In a sidebar include an advertisement that changes its image every three seconds. The can be created in paint and be very simple or more detailed.
Use Java GUI create following: Task 1: A basic UI with a button and a TextField,...
Use Java GUI create following: Task 1: A basic UI with a button and a TextField, when you press the button, set the button text to the current text field contents. Task 2: set the text field text to the mouse coordinates when that same button is pushed.
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
Create the Parser module in System Verilog to convert the 8-bit Button Board input into four...
Create the Parser module in System Verilog to convert the 8-bit Button Board input into four 4-bit Binary Coded Decimal numbers. The parser should read in an 8-bit Button Board input as an 8-bit number (0-255). Parse that 8-bit number into four 4-bit numbers (0-9) representing its ones, tens, hundreds, and thousands digit.
Using Javascript Create a page places an order for a Calzone: Using Text box to get...
Using Javascript Create a page places an order for a Calzone: Using Text box to get customers Name Radio Buttons for sizes: small, medium, large list for type of crust: crispy, soft, hard check boxes for toppings, with at least 3 to be selected Submit button that displays the order information.
JavaScript. Create a Web page with the following features: Three lines of text about anything. A...
JavaScript. Create a Web page with the following features: Three lines of text about anything. A link to OCC (http://www.orangecoastcollege.edu) that opens in a new browser window. An image link (graphical link). A link to the top of the page. A graphical link to your email. Formatted text throughout the page. Horizontal lines
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT