JS - User Interaction - I/O #48
Replies: 59 comments
Codelet isOpted = confirm('Do you wish to enable advertisement?')
if (isOpted) {
let email = prompt('Enter your email')
let name = prompt('Enter your name')
let phoneNum = prompt('Enter your phone number')
alert(email + ' - ' + name + ' - ' + phoneNum)
}`` Screenshot |
Codelet adver = confirm("They want to opt-in for advertisement"); let input1=prompt("please fill name ");
let input2=prompt("please fill email");
let input3=prompt("phone number");
console.log("Name:"+input1,"email:"+input2, "phone number:"+input3);OutputName:Nikhil email:nikhilrajpoot129gmail.com phone number:8803117301 |
Codelet advertisementOptInstatus=confirm("Do you want to opt in for advertisement?")
prompt("Email")
prompt("Phone Number")ScreenshotsCodelet num1=parseInt(prompt("Enter your number-1"))
let num2=parseInt(prompt("Enter your number-2"))
if (Number.isInteger(num1) && Number.isInteger(num2)) {
let res=(num1+num2);
alert("Sum is = " +res);
}
else {
alert("Can not add incompatible types");
}Screenshot |
Codevar conf=confirm("Do you Want to enable advertisement");
if(conf)
{
var email=prompt("Enter email address");
var name=prompt("Enter your name");
var number=prompt("Enter phone number");
console.log("Name :"+name+ " email:"+email+" number:"+number);
alert("Name :"+name+ " \n email:"+email+"\n number:"+number);
}Screenshots |
Codelet isOpted = confirm('Do you wish to opt-in in this program?')
if (isOpted) {
let email = prompt('Enter your email')
let name = prompt('Enter your name')
let phoneNum = prompt('Enter your phone number')
console.log(email + ' - ' + name + ' - ' + phoneNum)
}Screenshot / Output |
Codelet num1 = parseInt(prompt('Enter your number 1'));
let num2 = parseInt(prompt('Enter your number 2'));
if(Number.isInteger(num1) && Number.isInteger(num2)){
let res = num1+num2;
alert("Sum is "+res);
}else{
alert("Can not add incompatible types");
}Screenshot |
Codelet advertisementOptInStatus=confirm("Do you want to opt for advertisement?");
let name=prompt("Enter ur Name:");
let email=prompt("Enter ur Email:");
let phone_no=prompt("Enter ur Phone_no:");
console.log("Name:"+name,"Email:"+email,"Phone number:"+phone_no);Screenshot |
2 Ques.let num1 = parseInt(prompt("Enter your number 1"));
let num2 = parseInt(prompt("Enter your number 2"));
if(Number.isInteger(num1) && Number.isInteger(num2))
{
let Sum = parseInt(num1)+parseInt(num2);
console.log("Sum is "+Sum);
}
else{
console.log("Can not add incompatible types");
}Screenshot /Output |
|
let isOpted = confirm('Do you wish to opt-in in this program?') |
codelet opt_in=confirm('want to opt-in for advertisement');
if(opt_in)
{
let name=prompt('Enter your name')
let email=prompt('Enter your Email id')
let phno=prompt('Enetr your phone no.')
console.log('Name:'+name + 'Email:'+email + 'No.'+phno)
}screenshotscodelet no1 = parseInt (prompt("Enter your first number"));
let no2= parseInt (prompt("Enter your second number"));
if(Number(no1) && Number(no2))
{
let sum=no1+no2;
console.log("the result is:"+sum);
}
else{
alert("Can not add incompatible types")
}screenshots |
Codelet isaccepted = confirm("Do you want this page to show you advertisement");
if (isaccepted) {
let Name = prompt("Please provide your name:");
let email = prompt("Please enter your E-mail:");
let Phonenumber = prompt("Provide your phone-number:");
console.log("Email:" +email+ "Name:" +Name+ "Phone-number:" +Phonenumber);
}Screen Shots |
Code 1let OptIn = confirm('Do you wish to enable advertisement?')
if (OptIn) {
let email = prompt('Please enter your email')
let name = prompt('Please enter your name')
let phoneNum = prompt('Please enter your phone number')
alert('Your Email: ' + email + ' Name: ' + name + ' Phone: ' + phoneNum)
} |
1let choice = confirm("Do you want to opt-in for advertisement?")
if(choice){
let email = prompt("Enter Email :");
let name = prompt("Enter Name :");
let phn = prompt("Enter your Phone Number: ");
alert(email + " " + name + " " + phn);
}2let num1 = prompt("Enter num1 :");
let num2 = prompt("Enter num2 :");
if(typeof(num1) == typeof(num2)){
console.log(+num1 + +num2);
}else {
console.log("Can not add incompatible types");
} |
|
//pgm1 <title>Document</title> <script> let advertise=confirm("Do you wish to enable advertisement?") if(advertise){ let email=prompt("enter your email"); let name=prompt("enter your name"); let phnno=prompt("enter phn no"); alert(email+"--"+name+"--"+phnno); } </script>//pgm2 <title>Document</title> <script>let num1=prompt("enter num 1"); if(Number.isInteger(n1)&& Number.isInteger(n2)) |
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button onclick="f1()">f1</button>
<button onclick="f2()">f2</button>
<script>
function f1() {
let choice=confirm("Press a button!");
if(choice)
{
let email=prompt("Enter your email address");
let name=prompt("Enter your name");
let phone=prompt("Enter your phone number");
alert(email+" " +name+" " +phone);
}
}
function f2(){
let n1=prompt("Enter number 1");
let n2=prompt("Enter number 2");
if(typeof parseInt(n1) == typeof parseInt(n2)){
console.log(parseInt(n1)+parseInt(n2));
}
else
{
console.log("Can not add incompatible types");
}
}
</script>
</body>
</html> |
1)
<script>
let isOpt = window.confirm("Do you want to enable advertisement?")
if (isOpt) {
let email = prompt('Enter your email')
let name = prompt('Enter your name')
let phoneNum = prompt('Enter your phone number')
alert('email: '+ email + ' - ' +'name: '+ name + ' - ' + 'phone: '+phoneNum)
}
</script>
2)
<script>
n1 = parseInt(prompt("number 1"));
n2 = parseInt(prompt("number 2"));
if(Number(n1)&& Number(n2))
{
sum=n1+n2;
console.log("Sum of two numbers: " +sum )
}
else{
console.log("Data types are different")
}
</script> |
let ans= confirm('want to enable advertisement?')
if (ans) {
let email = prompt('Enter your email')
let name = prompt('Enter your name')
let phoneNum = prompt('Enter your phone number')
alert(email + ' - ' + name + ' - ' + phoneNum)
} |
2let num1 = parseInt(prompt("Enter first num"))
let num2 = parseInt(prompt("Enter second num"))
if (Number.isInteger(num1) && Number.isInteger(num2)) {
let res=(num1 + num2);
alert("Sum is = " + res);
}
else {
alert("Can not add incompatible types");
} |
|
Task1 Code### let subscribe = confirm("Do you want to subscribe the advertisement?")
if(subscribe){
let email = prompt("Enter email")
let name = prompt("Enter name")
let phone = prompt("Enter phone number")
alert ("You are subscribed and the details are " + email + ' : ' + name + ' : ' + phone)
}
else{
alert("Try next time")
}Task2 Code### let num1 = parseInt(prompt("Please enter first number"))
let num2 = parseInt(prompt("Please enter second number"))
if (Number.isInteger(num1) && Number.isInteger(num2)){
alert("Sum is : " + num1 + num2)
}
else{
alert("Please enter valid integer numbers")
} |
<script type="text/javascript">
var a = confirm("Did u want to opt-in for advertisement please confirm by writing 'y' for yes and 'n' for no.")
if( a ){
var email = prompt("give your name")
var name = prompt("your good name ")
var phone = prompt("type your number to contact")
alert(`your mail is ${email},your name is ${name} and mobile number is ${phone}`)
}
</script> |
<script type="text/javascript">
var num1 = parseInt(prompt("Enter first numuber to sum"))
var num2 = parseInt(prompt("Enter second numuber to sum"))
console.log(typeof(num1))
console.log(typeof(num2))
if(typeof(num1)=="number" && typeof(num2)=="number" ){
var sum = num1 + num2
console.log("the sum of numbers is "+ sum)
}else{
console.log("Can not add incompatible types ")
}
</script> |
|
1)WAP to ask the user whether they want to opt-in for advertisement using confirm. If they opt-in for it, use an input modal method to take their email, name, and phone number as input and display them using an output modal method. let yes=Confirm("Opt in for confirmation") 2)WAP to take two inputs from the user via a prompt. Use console.log to display the data types of the inputs. Print the sum if and only if both the inputs are numbers, else print "Can not add incompatible types". let num1=parseInt(prompt("Enter first number")); if(isNaN(num1) || isNaN(num2)){ |




















































































Uh oh!
There was an error while loading. Please reload this page.
WAP to ask the user whether they want to opt-in for advertisement using
confirm. If they opt-in for it, use an input modal method to take their email, name, and phone number as input and display them using an output modal method.WAP to take two inputs from the user via a
prompt. Useconsole.logto display the data types of the inputs. Print the sum if and only if both the inputs are numbers, else print "Can not add incompatible types".All reactions