Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
answered question 2
I have just answered question 2(Alarm Clock)
  • Loading branch information
Ade0211 committed Jul 29, 2020
commit 3e86c59eb4e5cc5c3bb68b2b851c0ef30eb13b06
4 changes: 3 additions & 1 deletion Week-3/.old/InClass/B-callbacks/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ function exercise2(result) {
*/

function exercise3(callback) {
callback("Hello from the callback");
// Write your implementation here

// Write your explanation here
// This callback is already a defined function and it is now used as a parameter
// in exercise3 function and also called in it
}

//
// -------------------------------------
//
Expand Down
10 changes: 8 additions & 2 deletions Week-3/.old/InClass/C-fetch/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@ Open index.html in your browser. Every time you refresh the page,
a different greeting should be displayed in the box.
*/

fetch('*** Write the API address here ***')
fetch('https://codeyourfuture.herokuapp.com/api/greetings')
.then(function(response) {
return response.text();
})
.then(function(greeting) {
let greet = document.getElementById("greeting-text")
console.log(greeting);
greet.innerHTML = greeting;
return;

// Write the code to display the greeting text here
});
});

13 changes: 9 additions & 4 deletions Week-3/.old/InClass/D-remote-clipboard/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Also, for GET request, you can use the url directly in your browser address bar
var clipboardTitle = "CHANGE ME";
var clipboardText = "CHANGE ME";
var requestBody = { title: clipboardTitle, text: clipboardText };

var url = `https://codeyourfuture.herokuapp.com/api/clipboard?title=myClipboardId`;
var postRequestParameters = {
body: JSON.stringify(requestBody),
method: 'POST',
Expand All @@ -32,12 +32,17 @@ var postRequestParameters = {
}
};

fetch(/* Write the API address here */, postRequestParameters);
fetch(url, postRequestParameters);


// Task 2: Load an existing clipboard
// Add your code below

fetch(/* ... */).then(function(response) {
fetch(url).then(function(response) {
return response.text();
}).then(/* ... */);
}).then(function(data){
let myData = document.getElementById("greeting-text");
console.log(data);
myData.innerText = data;
return;
});
11 changes: 10 additions & 1 deletion Week-3/.old/InClass/E-webchat/exercise-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ When you open index.html in your browser, it should display the existing message
*/


// Write your code here
// Write your code here
let url = `https://codeyourfuture.herokuapp.com/api/messages`;
fetch(url).then(function(response) {
return response.text();
}).then(function(message){
let myMessage = document.getElementById("message-list");
console.log(message);
myMessage.innerText = message;
return;
})
21 changes: 21 additions & 0 deletions Week-3/.old/InClass/E-webchat/exercise-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ on the submit button. Then check the following:


// Write your code here
// document.getElementById("submit").addEventListener("click", submit);
// function submit(){
// let url = `https://codeyourfuture.herokuapp.com/api/messages`;
// fetch(url).then(function(response) {
// return response.text();
// }).then(function(message){
// let myMessage = document.getElementById("message-list").value;
// console.log(message);
// myMessage.innerText = message.;
// console.log(myMessage);
// return;

// })
// }

let myObj ={
name: "Ade",
Age: 37
}
localStorage.setItem("myObj", myObj);
console.log(localStorage);
29 changes: 24 additions & 5 deletions Week-3/Homework/mandatory/1-alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
function setAlarm() {
let Date = new Date();
let myClock = document.getElementById("set");
let alarmSet = document.getElementById("alarmSet").innerHTML = Date.getSeconds ;
let remainingTime = document.getElementById("timeRemaining");

// let Date = new Date();
// let myClock = document.getElementById("set");
let alarmSet = document.getElementById("alarmSet");
remainingTime = document.getElementById("timeRemaining");
let time = parseInt(alarmSet.value);


// 125seconds= 02:05

let timeIn = setInterval(function(){
let min = Math.floor(time/60);
let sec = time-min * 60;

remainingTime.textContent = ("Time Remaining: ") + (min>9?min:"0" +min) + ":" + (sec>9?sec:"0" + sec);

if(time === 0){
playAlarm();

return clearInterval(timeIn);

}
time--;
}, 1000);

}

// DO NOT EDIT BELOW HERE
Expand Down
1 change: 0 additions & 1 deletion Week-3/Homework/mandatory/1-alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
/>
<link rel="stylesheet" href="style.css" />
</head>

<body>
<div class="centre">
<h1 id="timeRemaining">Time Remaining: 00:00</h1>
Expand Down