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

Javascript 02 #51

Open
wants to merge 27 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
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<meta charset="UTF-8">
</head>
<body>
<script src="step_1.js"></script>
</body>
</html>
3 changes: 2 additions & 1 deletion 03_Exercises/03_JavaScript/javascript-basics-01/Step_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Step 2</title>
<meta charset="UTF-8">
</head>
<body>
<body >
<script src="step_2.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<meta charset="UTF-8">
</head>
<body>
<script src="step_3.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<label for="city">city : </label><input type="text" name="city" id="city"/>
<button name="validate" id="validate">Validate</button>
</form>
<script src="step_4.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<label for="second_number">second number : </label><input type="text" id="second_number" name="second_number"/><br/>
<button id="validate" name ="validate">validate</button>
</form>
<script src="step_5.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<label for="second_number">second number : </label><input type="text" id="second_number" name="second_number"/><br/>
<button id="validate" name ="validate">validate</button>
</form>
<script src="step_6.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<label for="year">Birth year : </label><input type="text" id="year" name="year"/><br/>
<button id="validate" name="validate">validate</button>
</form>
<script src="step_7.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<label for="age">your age : </label><input type="text" id="age" name="age"/><br/>
<button id="validate" name="validate">validate</button>
</form>
<script src="step-8.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step-8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
function ageFunction() {
var age = prompt("What is your age");
document.getElementById("age").value = age;
if (age > 18) {
alert("you are over 18");
}
else {
alert("You are under 18");
}

}
ageFunction();
4 changes: 4 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

var name= "Maya";

alert('I am ' + name);
6 changes: 6 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

var name="Maya";
var surname="Atiah" ;
var city="Aramoun" ;
alert("Name: "+name+"\nSurname:"+surname+"\ncity:"+city);

7 changes: 7 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function getconfirmation(){
let person = prompt("Please enter your name");
alert("Hello "+person);


}
getconfirmation();
9 changes: 9 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
var username=prompt("Please enter your name");
document.getElementById("name").value = username;
var lastName=prompt("please enter your surname");
document.getElementById("surname").value = lastName;
var cityn=prompt("Please enter your city");
document.getElementById("city").value = cityn;


alert("Name: "+username+"\nSurname:"+lastName+"\ncity:"+cityn);
5 changes: 5 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var numberOne=prompt("type the first number");
document.getElementById("first_number").value=numberOne;
var numberTwo=prompt("type the second number");
document.getElementById("second_number").value=numberTwo;
alert(numberOne*numberTwo);
6 changes: 6 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var numberOne=prompt("Type the first number");
document.getElementById("first_number").value=numberOne;
var numberTwo=prompt("Type the second number");
document.getElementById("second_number").value=numberTwo;
alert("the remainder of "+numberOne+" and "+numberTwo+" is "+numberOne/numberTwo);

21 changes: 21 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-01/step_7.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@



function someCalculations(){
var shoeNumber=prompt("Write your shoe number");
document.getElementById("shoe_size").value=shoeNumber;
var birthYear=prompt("Write your birth year");
document.getElementById("year").value=birthYear;
alert(shoeNumber*2+5-birthYear+1766);

}
someCalculations();


// Multiplies the shoe size by 2
// Adds 5
// Multiplies by 50
// Subtracts the birth year
// Adds 1766
// Shows the result to the user
// Commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
</head>
<body>
<img src="images/image1.jpg" id="image1" />
<script src="step_1.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var image;
image=document.querySelector("#image1");
image.addEventListener("mouseover",function(){
image.src="images/image1_2.jpg";
});

Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<form>
<label for="name">Your name : </label><input type="text" name="name" value="" id="name"/>
</form>
<script src="step_2.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
text=document.querySelector("#name");

text.addEventListener("focusout", myFunction);


function myFunction() {
alert("thank you for participating!");
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<body>
<form>
<label for="name">Your name : </label><input type="text" name="name" value="" id="name"/>

</form>

<div id="value"></div>
<script src="step_3.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-02/step 3/step_3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const text=document.querySelector('input');
const value=document.getElementById('value');

text.addEventListener('input', updateValue);


function updateValue(a){
value.textContent=a.target.value;

}





Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<title>Step 4</title>
</head>
<body>
<form>
<form id="myform">
<label for="name">Your name : </label><input type="text" name="name" value="Doe" id="name" />
<label for="surname">Your surname : </label><input type="text" name="surname" value="John" id="surname" />
<label for="city">Your city : </label><input type="text" name="city" value="New York" id="city" />
<button type="button" name="button">Reset</button>
<button type="button" name="button" id="buttn">Reset</button>
</form>
<script src="step_4.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
document.querySelector("#buttn").addEventListener("click", function () {
if (confirm("Are you sure u want to reset?")) {
document.querySelector("#name").value = "";
document.querySelector("#city").value = "";
document.querySelector("#surname").value = "";
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
<img src="images/image4.jpg" id="image4" />
<img src="images/image5.jpg" id="image5" />
</div>
<script src="step_5.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
document.addEventListener("mouseover",function(){
document.getElementById("image1").src = "images/image1_2.jpg";
document.getElementById("image2").src = "images/image2_2.jpg";
document.getElementById("image3").src = "images/image3_2.jbg";
document.getElementById("image4").src = "images/image4_2.jpg";
document.getElementById("image5").src = "images/image5_2.jpg";
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
<img src="images/image3.jpg" id="image3" />
<img src="images/image4.jpg" id="image4" />
<img src="images/image5.jpg" id="image5" />
<script src="step_6.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions 03_Exercises/03_JavaScript/javascript-basics-02/step 6/step_6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

document.addEventListener("mouseover",function(){
document.getElementById("image1").src = "images/image1_2.jpg";
document.getElementById("image2").src = "images/image2_2.jpg";
document.getElementById("image3").src = "images/image3_2.jbg";
document.getElementById("image4").src = "images/image4_2.jpg";
document.getElementById("image5").src = "images/image5_2.jpg";
})

document.addEventListener("mouseout",function(){
document.getElementById("image1").src = "images/image1.jpg";
document.getElementById("image2").src = "images/image2.jpg";
document.getElementById("image3").src = "images/image3.jbg";
document.getElementById("image4").src = "images/image4.jpg";
document.getElementById("image5").src = "images/image5.jpg";
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading