# JavaScript Essentials Hands-on Solution with MCQ | TCS Fresco Play

0

Course Path: Modern Web Development/WEB BASICS/JavaScript Essentials

Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.

Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).

All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!

1.Try-it-out - Function for Fibonacci Series
Welcome to To generate Fibonacci sequence new

process.stdin.resume();
process.stdin.setEncoding('utf-8');

var __input_stdin = "";
var __input_stdin_array = "";
var __input_currentline = 0;

process.stdin.on('data', function(data) {
__input_stdin += data;
});

/*
* Complete the function below.
*/
function fibonacciSequence(input) {
var n1=0;
var n2=1;
var out=[];
if(input==1)
out.push(n1);
else if(input==2)
out.push(n1,n2);
else{
out.push(n1,n2);
for(var i=0;i<=input-2;i++){
var n3=n2+n1;
n1=n2;
n2=n3;
out.push(n3);
}
}
return out;
}
var fs = require('fs');
var wstream = fs.createWriteStream(process.env.OUTPUT_PATH);

process.stdin.on('end', function() {
__input_stdin_array = __input_stdin.split("\n");
var input;
var input = parseInt(__input_stdin_array[__input_currentline].trim(), 10);
__input_currentline += 1;

res = fibonacciSequence(input);
for(var res_i = 0; res_i < res.length; res_i++) {
wstream.write(res[res_i]+"\n");
}

wstream.end();
});

2.Try-it-out - DOM - User Registration Details
Welcome to To read the user registration details

File Name - index.js

function myFunction() {
var name = document.getElementById("myname").value;
var phone = document.getElementById("myphone").value;
var country = document.getElementById("mycontry").value;
var email = document.getElementById("mymail").value;
var result = name + "," + phone + "," + country + "," + email;
return result;
}

3.Try-it-out - DOM - Create Drop Down Country Field
Welcome to To create a drop down Country field

File Name - index.js

function runList(){
var select = document.getElementById("list");
var newOption = document.createElement("option");

newOption.text = document.getElementById("txtbox").value;
}

4.Try-it-out - Generate random characters
Welcome to To generate Random Character id

File Name - index.js

function stringGen()
{
var text = "";
var val = document.querySelector("#num").value;
var possible = "ABCDEFGHIKLMNOPQRSTVXYZabcdefghijklmnopqrstuvwxyz01234546789"
for (var i=0;i< val; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}

5.Try-it-out - Simple Calculator
Welcome to To create a simple calculator

File Name - index.js

function update(value) {
//Type the code here.
document.getElementById('screen').value += value;
}

function result() {
//Type the code here.
document.getElementById('screen').value = eval(document.getElementById('screen').value);
}

function form_reset() {
//Type the code here.
document.getElementById('screen').value = "";
}

```If you have any queries, please feel free to ask on the comment section.