Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 10 #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Exercise-10/js/Section1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
console.log(1+2);
console.log("apple"+"orange");
console.log(1+2+"orange");
console.log("apple"+1+2);
console.log(1+true);
console.log(0==false);
console.log(1===true);
console.log(2=="2");
24 changes: 24 additions & 0 deletions Exercise-10/js/Section2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const players = ["Sachin", "Dhoni", "Shehwag", "Ganguly", "Yuvraj", "Hardik", "Ashwin", "Jadeja", "Raina", "Kohli", "Rohit"];
console.log(players);
const injuredPlayer = players.indexOf("Jadeja");
players.shift();
console.log(players);
console.log(players.length);
players.unshift("Ishan");
console.log(players);
players.sort();
console.log(players);
var uniqueNumbers = [];
const nums = new Set();
while(nums.size !== 11)
{
nums.add(Math.floor(Math.random() * 100) + 1);
}
for(let i=0; i<11; i++)
{
players[i]=players[i]+"-"+ Array.from(nums)[i];
}
console.log(players);
const jerseys = players.map(player => player.toUpperCase());
console.log(jerseys);
console.log(players);
29 changes: 29 additions & 0 deletions Exercise-10/js/Section3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function displayNumbers()
{
for(let num=1; num<=100; num++)
{
console.log(num);
}
}
function displayDate()
{
const formatted_date = new Date().toLocaleDateString('en-GB');
console.log("Today's date: "+formatted_date);
}

displayNumbers();
displayDate();
let Celsius=45;
displayTemp = celsius => (celsius * 1.8) + 32;
let fahrenheit = displayTemp(Celsius);
console.log(`${Celsius} degree celsius is equal to ${fahrenheit} degree fahrenheit.`);
const numbers = [3,5,6,7,8,1,10,34,9,2];
function Average(numbers)
{
var result = numbers.reduce((prevVal, currVal) => prevVal+currVal, 0);
result/=numbers.length;
console.log(`Average of the given numbers: ${result}`);
}
Average(numbers);
reverseString = (str) => str.split('').reverse().join('');
console.log(reverseString("VARSHINI"));
1 change: 0 additions & 1 deletion README.md

This file was deleted.