Skip to content

simple bonus function is added #6

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

Open
wants to merge 3 commits into
base: master
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
15 changes: 15 additions & 0 deletions Day-1/Day-1_Solutions/10th/tenth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

<!DOCTYPE>
<html>
<head>
<script src="tenth.js"></script>
</head>
<body>
<h2>Javascript Palindrome in an Array</h2>
The array is
<button onClick=palindrome()>Palindrome</button>
<p id="abc"></p>

</body>

</html>
27 changes: 27 additions & 0 deletions Day-1/Day-1_Solutions/10th/tenth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@


var array= ["Malayalam", "tree", "boat", "civic", "melt", "level"];
var temp;

function palindrome(){
console.log(array[0]);
for(var i=0;i<=array.length;i++){

console.log(array[i]);
/* remove special characters, spaces and make lowercase*/
//var removeChar = array[i].replace(/[^A-Z0-9]/ig, "").toLowerCase();

/* reverse removeChar for comparison*/
//var checkPalindrome = removeChar.split('').reverse().join('');

/* Check to see if myString is a Palindrome*/
//if(removeChar === checkPalindrome){

document.getElementById("abc").innerHTML="<div>"+ array[i] + " is a Palindrome <div>";
//}else{

//document.getElementById("abc").innerHTML="<div>" + array[i] + " is not a Palindrome </div>";
}
}
}

13 changes: 13 additions & 0 deletions Day-1/Day-1_Solutions/1factorial/factorial.html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<title>factorial</title>
<script src="factorial.js"></script>
</head>
<body>
Enter a positive Input: <input type=text id="num"><br>
<button style="height: 25px;width:100px; color:red" onClick=factorial()>factorial</button><br><br>
Output: <input type=text id="final">
</body>

</html>
10 changes: 10 additions & 0 deletions Day-1/Day-1_Solutions/1factorial/factorial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function factorial(){
var fact=1, num=1,i;
num = document.getElementById("num").value;
for(i=1;i<=num;i++){
fact = fact*i;

}
document.getElementById("final").value = fact;

}
17 changes: 17 additions & 0 deletions Day-1/Day-1_Solutions/2sum of n nums/second.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html5>
<html>
<head>
<script src="second.js"></script>
</head>
<body>
<h3>Sum of first n natural numbers</h3>
Enter num<input type=text id=num>
Value: <input type=text id=val>
<button onClick=total()> calculate </button>



</body>


</html>
11 changes: 11 additions & 0 deletions Day-1/Day-1_Solutions/2sum of n nums/second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function total(){
var num = 1, total=0;
num = document.getElementById("num").value;
//total = (num*(num+1))/2;
for(var i=1;i<=num;i++){
total = total+i;
}
document.getElementById("val").value = total;


}
14 changes: 14 additions & 0 deletions Day-1/Day-1_Solutions/3rd/third.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script src="third.js"></script>
</head>
<body>

<p>To find the sum of all the multiples of 3 or 5 below 1000</p>

<button onClick=PrintStr()>Calculate</button>


</body>
</html>
20 changes: 20 additions & 0 deletions Day-1/Day-1_Solutions/3rd/third.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function PrintStr(){
var temp1=0,temp2=0,temp3=0,tot;
for(var i=1;i<=1000;i++){
if(i%3==0 && i%5!=0){
temp1= temp1+i;
}
else if(i%3!=0 && i%5==0){
temp2= temp2+i;
}
else if(i%3==0 && i%5==0){
temp3= temp3+i;
}
else{
continue;
}
}
tot = temp1+temp2+temp3;
document.write("the sum of all the multiples of 3 or 5 below 1000 is"+ tot);

}
14 changes: 14 additions & 0 deletions Day-1/Day-1_Solutions/4th/fourth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script src="fourth.js"></script>
</head>
<body>

Enter a number:<input type="text" id="num" name="num">

<button onClick=findPower()>Calculate</button>


</body>
</html>
13 changes: 13 additions & 0 deletions Day-1/Day-1_Solutions/4th/fourth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

function findPower(){

var N = document.getElementById("num").value;
var v = 1;

while (v <= N)
v *= 2
v = v/2

console.log(v);
console.log(Math.log(v));
}
14 changes: 14 additions & 0 deletions Day-1/Day-1_Solutions/5th/five.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<script src="C:\\Users\\sowmyat\\Desktop\\js assignment\\5th\\five.js"></script>
</head>
<body>

Enter a number:<input type="text" id="last" name="last">

<button onClick=PrintStr()>Calculate</button>


</body>
</html>
21 changes: 21 additions & 0 deletions Day-1/Day-1_Solutions/5th/five.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function PrintStr(){

var num =1;
num = document.getElementById("last").value;
console.log(num);
for(i=1;i<=num;i++){
if(i%3==0&&i%5!=0){
document.write("Fizz,");
}
else if(i%5==0&&i%3!=0){
document.write("Buzz,");
}
else if(i%5==0&&i%3!=0){
document.write("FizzBuzz,");
}
else{
document.write(i+",");
}

}
}
15 changes: 15 additions & 0 deletions Day-1/Day-1_Solutions/6array of integers/sixth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html5>
<html>
<head>
<script src="sixth.js"></script>
</head>
<body>
Enter a sum:<input type=text id="sum">
<p>The array is: [1, 4, 3, 5, 4, 6, 7, 8, 3]</p>

<button onClick=findPairs()>calculate</button>

</body>


</html>
20 changes: 20 additions & 0 deletions Day-1/Day-1_Solutions/6array of integers/sixth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function findPairs(){
var array = [1, 4, 3, 5, 4, 6, 7, 8, 3];
var sum=0,i,temp=0;
sum= document.getElementById("sum").value;
for(i=0;i<array.length;i++){
for(y=i+1;y<array.length;y++){
if(array[i]+array[y]== sum){
document.write(array[i]+" "+array[y]+"<br>");
temp++;

}


}

}
if(temp==0)
document.write("no such value as"+ sum);

}
9 changes: 9 additions & 0 deletions Day-1/Day-1_Solutions/7th/seven.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE>
<html>
<head>
<script src="seven.js"></script>
</head>
<body>
<p>The array is [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1]</p>
</body>
</html>
32 changes: 32 additions & 0 deletions Day-1/Day-1_Solutions/7th/seven.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*function getRepeatedVal(){
var array = [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1];
var repeatedVal =[];
for(var i=0;i<array.length;i++){

console.log(array.lastIndexOf(array[i]));
console.log(repeatedVal.indexOf(array[i]));
if((array.lastIndexOf(array[i]!=i))&& (repeatedVal.indexOf(array[i]=== -1))){
repeatedVal.push(array[i]);

}
}


//console.log(repeatedVal);
}*/

var numbers = [1, 2, 3, 5, 8, 4, 7, 9, 1, 4, 12, 5, 6, 5, 2, 1, 0, 8, 1];
var duplicates = [];

function goThroughArray(arr) {
for(var i = 0;i < arr.length; i++) {
if((arr.lastIndexOf(arr[i]) != i) &&
(duplicates.indexOf(arr[i]) == -1)) {
duplicates += arr[i];
}
}
return duplicates;
}

alert(goThroughArray(numbers));

9 changes: 9 additions & 0 deletions Day-1/Day-1_Solutions/8th/eigth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html5>
<html>
<head>
<script src="eigth.js"></script>
</head>
<body>
<p>to print sum of all values in an object</p>
</body>
</html>
6 changes: 6 additions & 0 deletions Day-1/Day-1_Solutions/8th/eigth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var obj = {"Rick": 85, "Amit": 42, "George": 53, "Tanya": 60, "Linda": 35};
var sum = 0;
for(var key in obj){
sum += parseInt(obj[key]);
}
alert("the sum of all values in object:"+ sum);
16 changes: 16 additions & 0 deletions Day-1/Day-1_Solutions/9th/nine.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

<!DOCTYPE>
<html>
<head>
<script src="nine.js"></script>
</head>
<body>
<h2>Javascript Palindrome Checking Function</h2>
Enter a string to check:<input type="text" id="check">
<button onClick=palindrome(document.getElementById('check').value)>Palindrome</button>
<p id="abc"></p>

</body>


</html>
18 changes: 18 additions & 0 deletions Day-1/Day-1_Solutions/9th/nine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function palindrome(myString){

/* remove special characters, spaces and make lowercase*/
var removeChar = myString.replace(/[^A-Z0-9]/ig, "").toLowerCase();

/* reverse removeChar for comparison*/
var checkPalindrome = removeChar.split('').reverse().join('');

/* Check to see if myString is a Palindrome*/
if(removeChar === checkPalindrome){

document.getElementById("abc").innerHTML="<div>"+ myString + " is a Palindrome <div>";
}else{

document.getElementById("abc").innerHTML="<div>" + myString + " is not a Palindrome </div>";
}
}

Loading