-
Notifications
You must be signed in to change notification settings - Fork 6
Task 4 Submission #28
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Document</title> | ||
| <style> | ||
| .butn{ | ||
| /* background-color: blueviolet; */ | ||
| } | ||
| </style> | ||
| <script> | ||
| function clicked(){ | ||
| button.textContent="Clicked"; | ||
| button.style.backgroundcolor | ||
| } | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <button class="butn" onclick="clicked()"> Click Me</button> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <button class="btn">Change Background</button> | ||
| </body> | ||
| <script> | ||
| const colors = ["red","green","blue","yellow","orange"]; | ||
| const btn = document.querySelector(".btn"); | ||
| let lastindex = 0; | ||
| btn.addEventListener("click",()=>{ | ||
|
|
||
| let random = Math.floor(Math.random()*colors.length);//range 0 ,0, 0 | ||
| console.log(random) | ||
|
|
||
| // for(let i=0;i<colors.length;i++){// 0,0 | ||
| // if(random === lastindex){ | ||
| // random = Math.floor(Math.random()*colors.length); | ||
| // i=-1; | ||
| // } | ||
| // } | ||
| //easy infinite loop | ||
|
|
||
|
|
||
|
|
||
| // 0===1 | ||
|
|
||
| for (let index = 0; index < colors.length; index--) { | ||
| if(random === lastindex){ | ||
| random = Math.floor(Math.random()*colors.length); | ||
| } | ||
| else{ | ||
| break; | ||
| } | ||
|
|
||
| } | ||
|
Comment on lines
+32
to
+40
|
||
|
|
||
|
|
||
| console.log(random) | ||
| document.body.style.backgroundColor = colors[random]; | ||
| lastindex = random; | ||
|
|
||
| }) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| </script> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Document</title> | ||
| <style> | ||
| .btn{ | ||
| padding: 10px 20px; | ||
| font-size: 1.1em; | ||
| color:white; | ||
| background-color: #007BFF; | ||
| border: none; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <button class="btn" >Click Me</button> | ||
| <div> | ||
| Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, repellendus quasi! | ||
| </div> | ||
| <div class="second"> | ||
| Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, repellendus quasi! | ||
| </div> | ||
| <div> | ||
| Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, repellendus quasi! | ||
| </div> | ||
| <div> | ||
| Lorem ipsum dolor sit amet consectetur adipisicing elit. Sint, repellendus quasi! | ||
| </div> | ||
|
|
||
| </body> | ||
| <script> | ||
| //dom (Documnet object model ) ever element is an object in js | ||
| //we can manipulate the element using js | ||
| const btn = document.querySelector(".btn"); | ||
| // btn.addEventListener("work",function) | ||
| btn.addEventListener("click",handelClick); | ||
| function handelClick(){ | ||
| if(btn.textContent === "Click Me"){ | ||
| btn.style.backgroundColor = "green"; | ||
| btn.textContent = "Clicked"; | ||
| } | ||
| else{ | ||
| btn.style.backgroundColor = "#007BFF"; | ||
| btn.textContent = "Click Me"; | ||
| } | ||
|
|
||
| } | ||
| btn.addEventListener("mouseover",function(){ | ||
| if(btn.textContent === "Clicked"){ | ||
| } | ||
| else{ | ||
| btn.style.backgroundColor = "red"; | ||
| } | ||
| }) | ||
| btn.addEventListener("mouseout",function(){ | ||
| if(btn.textContent === "Click me"){ | ||
|
|
||
| btn.style.backgroundColor = "#007BFF"; | ||
| } | ||
| }) | ||
|
Comment on lines
+57
to
+62
|
||
|
|
||
|
|
||
| //click ,hover ,mouseout ,keydown , | ||
|
|
||
|
|
||
| const colors = ["red","green","blue","yellow","orange"]; | ||
|
|
||
| // document.body bg green | ||
| // document.getElementsByTagName("button) bg green text white | ||
|
|
||
|
|
||
|
|
||
|
|
||
| </script> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,7 +84,7 @@ for (let i=0; i<students.length;i++){ | |
| console.log(students[i].name)//with meassage | ||
| } | ||
| } | ||
| //top performer | ||
| //top performer//to use students updated array | ||
| let topPerformer=avgmarks[0] | ||
| for (let i=0; i<avgmarks.length;i++){ | ||
| if(avgmarks[i]>topPerformer){ | ||
|
|
@@ -106,40 +106,41 @@ for(let i=0; i<avgmarks.length;i++){ | |
| console.log(`The loe Scorer is : ${lowScorer}`) | ||
|
|
||
| // Check eligibility (average > 40 AND attendance > 75%) | ||
| let eligibility=[] | ||
|
|
||
| for(let i=0; i<avgmarks.length;i++){ | ||
| if(students[i].Average_Marks>40 && students[i].attendance >75){ | ||
| eligibility.push("PASS") | ||
| students[i].eligibility="PASS" | ||
| } | ||
| else{ | ||
| eligibility.push("FAIL") | ||
| students[i].eligibility="FAIL" | ||
| } | ||
| } | ||
| console.log("The pass/fail eligibilty of each student; ",eligibility) | ||
| console.log(students) | ||
|
|
||
|
|
||
| //again updating with results | ||
| for(let i=0; i<students.length;i++){ | ||
| students[i].Result=eligibility[i] | ||
| // for(let i=0; i<students.length;i++){ | ||
| // students[i].Result=eligibility[i] | ||
|
|
||
| } | ||
| console.log("Updated Students Profile with grade and avgmarks:",students) | ||
| // } | ||
| // console.log("Updated Students Profile with grade and avgmarks:",students) | ||
|
|
||
|
|
||
| //pass count | ||
| let pcount=0; | ||
| for(let i=0;i<eligibility.length;i++){ | ||
| for(let i=0;i<students[i].length;i++){ | ||
|
|
||
| if(eligibility[i]==="PASS"){ | ||
| if(students.eligibility[i]==="PASS"){ | ||
| pcount+=1 | ||
| } | ||
| } | ||
| console.log("The pass count in letslearn is: ",pcount) | ||
|
|
||
| //fail count | ||
| let fcount=0; | ||
| for(let i=0;i<eligibility.length;i++){ | ||
| for(let i=0;i<students[i].length;i++){ | ||
|
|
||
| if(eligibility[i]==="PASS"){ | ||
| if(students.eligibility[i]==="PASS"){ | ||
| continue; | ||
| } | ||
|
Comment on lines
+131
to
145
|
||
| else{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| <!-- Project idea: Quote + Color Generator | ||
|
|
||
| Build a tiny page with one button: every click changes background color and shows a random motivational quote. | ||
|
|
||
| How you can do it: | ||
|
|
||
| Keep 2 arrays: one for colors, one for short quotes. | ||
| On button click, generate random index for both. | ||
| Update page background and the text content. | ||
| Add one small rule: don’t repeat the same color twice in a row (you already know this concept). | ||
| Why this boosts confidence: | ||
|
|
||
| Super short build time (15-25 min). | ||
| Uses DOM + arrays + random + condition in one clean mini-project. | ||
| Looks fun and “real”, so students feel progress fast. | ||
| If you want, I can give you 5 more “15-minute confidence projects” in the same style. | ||
|
|
||
| const quotes = [ | ||
| "Believe in yourself and all that you are.", | ||
| "Small progress is still progress.", | ||
| "Discipline beats motivation.", | ||
| "Success is the sum of daily efforts.", | ||
| "Stay focused and never give up.", | ||
| "Your only limit is your mindset.", | ||
| "Dream big, start small, act now.", | ||
| "Consistency creates confidence." | ||
| ]; | ||
|
|
||
| const colors = [ | ||
| "#FF6B6B", | ||
| "#4ECDC4", | ||
| "#45B7D1", | ||
| "#F7B267", | ||
| "#6A4C93", | ||
| "#2EC4B6", | ||
| "#FF9F1C", | ||
| "#1B9AAA" | ||
| ]; --> | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Task4</title> | ||
| <style> | ||
| button{ | ||
| background-color: rgb(108, 172, 228); | ||
| } | ||
| .quote{ | ||
| color:white; | ||
| font-weight:bold; | ||
| z-index:-1; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <button> Change BG with Quotes</button> | ||
| <div class="quote"></div> | ||
| </body> | ||
| <script> | ||
| const colors = ["red","blue","green","yellow","purple","black","orange","grey"]; | ||
| const quotes = [ | ||
| "Believe in yourself and all that you are.", | ||
| "Small progress is still progress.", | ||
| "Discipline beats motivation.", | ||
| "Success is the sum of daily efforts.", | ||
| "Stay focused and never give up.", | ||
| "Your only limit is your mindset.", | ||
| "Dream big, start small, act now.", | ||
| "Consistency creates confidence." | ||
| ]; | ||
|
|
||
| const button = document.querySelector('button'); | ||
| button.addEventListener("click",function(){ | ||
| button.textContent="clicked"; | ||
| let lastindex=0; | ||
| let randomColor=Math.floor(Math.random()*colors.length); | ||
| for(let i=0; i<colors.length;i--){ | ||
| if(randomColor===lastindex){ | ||
|
Comment on lines
+75
to
+80
|
||
| randomColor=Math.floor(Math.random()*colors.length); | ||
| } | ||
| else{ | ||
| break | ||
| } | ||
| } | ||
|
Comment on lines
+79
to
+86
|
||
| document.body.style.backgroundColor = colors[randomColor]; | ||
|
|
||
| // let randomQuotes=Math.floor(Math.random()*quotes.length) | ||
| lastindex=randomColor; | ||
| const div=document.querySelector('div') | ||
| div.textContent=quotes[lastindex]; | ||
|
|
||
|
Comment on lines
+87
to
+93
|
||
|
|
||
| }) | ||
|
|
||
| </script> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <p id="p1"> | ||
| This is a text. | ||
| This is a text. | ||
| This is a text. | ||
| This is a text. | ||
| </p> | ||
|
|
||
| <input type="button" value="Hide text" onclick="document.getElementById('p1').style.visibility='hidden'"> | ||
| <input type="button" value="Show text" onclick="document.getElementById('p1').style.visibility='visible'"> | ||
|
|
||
| <input type="button" value="aakriti" onclick="document.getElementById('p1').style.visibility='hidden'"> | ||
| <input type="button" value="richa" onclick="document.getElementById('p1').style.visibility='visible'"> | ||
| </body> | ||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clicked()referencesbutton, but no variable namedbuttonis defined, so clicking will throw a ReferenceError. Select the element (e.g., viadocument.querySelector) or pass the element into the handler (e.g.,onclick="clicked(this)") and then update its properties; alsobackgroundcolorshould bebackgroundColorand the assignment is currently incomplete.