Skip to content
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
12 changes: 12 additions & 0 deletions Lect4ArraEx.1/ex7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*Write a JavaScript program which iterates the integers from 1 to 100.
But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".
For numbers which are multiples of both three and five print "FizzBuzz*/

function fizzyBuzzy(){
for(i=0;i<101;i++){
if(i%15 === 0)console.log("fizzbuzz");
else if(i%3 === 0)console.log("fizz");
else if(i%5 === 0)console.log("buzz");
else console.log(i);
}}
console.log(fizzyBuzzy());
6 changes: 6 additions & 0 deletions Lect4ArraEx.1/ex8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*8. According to Wikipedia a happy number is defined by the following process:
"Starting with any positive integer, replace the number by the sum of the squares of its digits,
and repeat the process until the number equals 1 (where it will stay),
or it loops endlessly in a cycle which does not include 1. Those
numbers for which this process ends in 1 are happy numbers,
while those that do not end in 1 are unhappy numbers (or sad numbers)".*/
13 changes: 13 additions & 0 deletions Lect4ArraEx/ex4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function largestOfFive(arr){
var greatestNumber=arr[0];

for(i=1;i<arr.length;i++){
if(arr[i] > arr[0]){
greatestNumber= arr[i]

}

}
return greatestNumber;
}
console.log(largestOfFive([15,24,-7,9]))
11 changes: 11 additions & 0 deletions Lect4ArraEx/ex5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function isOdd(numbers){
for(i=0; i< numbers.length;i++){
if(numbers[i]%2 === 0){
console.log(numbers[i]+ " is even"); ;
}
else{
console.log(numbers[i]+ " is odd");
}
}
}
console.log(isOdd([20,56,7,8,9]));
35 changes: 35 additions & 0 deletions Lect4ArraEx/ex6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade.
Student Name Marks
David 80
Vinoth 77
Divya 88
Ishitha 95
Thomas 68
The grades are computed as follows:
Range Grade
<60 F
<70 D
<80 C
<90 B
<100 A*/

function getGrade(name, points) {
var total = 0;
for (i = 0; i < points.length; i++) {
total += points[i];
var average = total / points.length;
}
if (average < 60) {
return name + " has failed";
} else if (average < 70) {
return name + " has scored D";
} else if (average >= 70 && average < 80) {
return name + " has scored C";
} else if (average >= 80 && average < 90) {
return name + " has scored B"
} else if (average >= 90) {
return name + " has scored A"
}

}
console.log(getGrade('Stanley', [67, 76, 67, 79]));
Empty file.
51 changes: 51 additions & 0 deletions Lect4ArraEx/toDolist/todolist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>

<style>h1{
background-color: #565656;
color: transparent;
text-shadow: 0px 2px 3px rgba(255,255,255,0.5);
-webkit-background-clip: text;
-moz-background-clip: text;
background-clip: text;
}

</style>
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>To do list application</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="js/scripts.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

<link rel="stylesheet" href="css/styles.css">
</head>

<body>
<h1>THE TODO LIST</h1>
<div class="input-group mb-3">
<input id="inputField" type="text" class="form-control" placeholder="Enter Task Name" aria-label="Enter Task Name" aria-describedby="basic-addon1">
</div>

<button class="addTask" type="button">Add task</button>

<div class="toDo"><p> Tasks to do</p></div>
<div class="addedTasks">
<ul class="taskList">
<!-- <li>Sample task <button class="markAsDone btn btn-success">Done</button></li> -->
</ul>
</div>

<div>Completed tasks</div>
<div class="doneTasks">
<ul class="taskList">
<!-- <li>Sample task <button class="removeTask btn btn-danger">Remove task</button></li> -->
</ul>
</div>

</body>

</html>
24 changes: 24 additions & 0 deletions Lect4ArraEx/toDolist/todolist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$(document).ready(function () {


$('.addTask').click(function () {
if ($.trim($('#inputField').val()) == '') {
alert('Please enter a task');
} else {
var inputText = $('#inputField').val();
$('.addedTasks .taskList').append('<li>' + inputText + '<button class="markAsDone btn btn-success">Done</button></li>');
$('#inputField').val('');
}
});


});
$(document).on('click', '.markAsDone', function () {
var inputText = this.parentNode.firstChild.nodeValue;
$('.doneTasks .taskList').append('<li>' + inputText + '<button class="removeTask btn btn-danger">Remove task</button></li>');
this.parentNode.remove();
});

$(document).on('click', '.removeTask', function () {
this.parentNode.remove();
});