Added correction for last homework.
This commit is contained in:
1 parent
e37c3d2f7b
commit
2034b2f56b
3 files changed
+94
-56
No files matched your search
@@ -127,31 +127,31 @@ describe("question 4", function(){
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("question 6", function(){
|
describe("question 5", function(){
|
||||||
async function testQuestion6(userInput, expt){
|
async function testQuestion5(userInput, expt){
|
||||||
document.getElementById("input-1").value = userInput;
|
document.getElementById("input-4").value = userInput;
|
||||||
document.getElementById("button-5").click();
|
document.getElementById("button-4").click();
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
assert.equal(expt, document.getElementById("result-box-1").innerText)
|
assert.equal(expt, document.getElementById("result-box-4").innerText)
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should find the proper number of existing country is input by user", async function(){
|
it("should find the proper number of existing country is input by user", async function(){
|
||||||
await testQuestion6("Canada", 3);
|
await testQuestion5("Canada", 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show zero when non existing country is input by user", async function(){
|
it("should show zero when non existing country is input by user", async function(){
|
||||||
await testQuestion6("France", 0);
|
await testQuestion5("France", 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe("question 7", function(){
|
describe("question 6", function(){
|
||||||
async function testQuestion7(userInput, expt){
|
async function testQuestion7(userInput, expt){
|
||||||
document.getElementById("input-2").value = userInput;
|
document.getElementById("input-1").value = userInput;
|
||||||
document.getElementById("button-6").click();
|
document.getElementById("button-5").click();
|
||||||
await sleep(100);
|
await sleep(100);
|
||||||
assert.equal(expt, document.getElementById("result-box-2").innerText)
|
assert.equal(expt, document.getElementById("result-box-1").innerText)
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should find the proper population of existing country is input by user", async function(){
|
it("should find the proper population of existing country is input by user", async function(){
|
||||||
@@ -164,6 +164,23 @@ describe("question 7", function(){
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
describe("question 7", function(){
|
||||||
|
async function testQuestion7(userInput, expt){
|
||||||
|
document.getElementById("input-2").value = userInput;
|
||||||
|
document.getElementById("button-6").click();
|
||||||
|
await sleep(100);
|
||||||
|
assert.equal(expt, document.getElementById("result-box-2").innerText)
|
||||||
|
}
|
||||||
|
|
||||||
|
it("should find the proper city of existing country is input by user", async function(){
|
||||||
|
await testQuestion7("Canada", "Toronto");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show zero when non existing country is input by user", async function(){
|
||||||
|
await testQuestion7("France", "aucune ville trouvée");
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
describe("question 8", function(){
|
describe("question 8", function(){
|
||||||
async function testQuestion8(userInput, expt){
|
async function testQuestion8(userInput, expt){
|
||||||
document.getElementById("input-3").value = userInput;
|
document.getElementById("input-3").value = userInput;
|
||||||
@@ -172,23 +189,6 @@ describe("question 8", function(){
|
|||||||
assert.equal(expt, document.getElementById("result-box-3").innerText)
|
assert.equal(expt, document.getElementById("result-box-3").innerText)
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should find the proper city of existing country is input by user", async function(){
|
|
||||||
await testQuestion8("Canada", "Toronto");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show zero when non existing country is input by user", async function(){
|
|
||||||
await testQuestion8("France", "aucune ville trouvée");
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
describe("question 9", function(){
|
|
||||||
async function testQuestion8(userInput, expt){
|
|
||||||
document.getElementById("input-4").value = userInput;
|
|
||||||
document.getElementById("button-8").click();
|
|
||||||
await sleep(100);
|
|
||||||
assert.equal(expt, document.getElementById("result-box-4").innerText)
|
|
||||||
}
|
|
||||||
|
|
||||||
it("should find the proper country of existing person entered by input by user", async function(){
|
it("should find the proper country of existing person entered by input by user", async function(){
|
||||||
await testQuestion8("Djaffar Bensetti", "Algerie");
|
await testQuestion8("Djaffar Bensetti", "Algerie");
|
||||||
});
|
});
|
||||||
@@ -198,5 +198,27 @@ describe("question 9", function(){
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("question 9", function(){
|
||||||
|
async function testQuestion9(userInput, expt){
|
||||||
|
document.getElementById("input-4").value = userInput;
|
||||||
|
document.getElementById("button-8").click();
|
||||||
|
await sleep(100);
|
||||||
|
assert.equal(expt, document.getElementById("result-box-4").innerText)
|
||||||
|
}
|
||||||
|
|
||||||
|
it("Canada", async function(){
|
||||||
|
await testQuestion9("Canada", 3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Mexique", async function(){
|
||||||
|
await testQuestion9("Mexique", 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("France", async function(){
|
||||||
|
await testQuestion9("France", 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
mocha.run();
|
mocha.run();
|
||||||
@@ -110,20 +110,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns">
|
|
||||||
<div class="column">
|
|
||||||
<button type="button" class="button is-primary" id="button-9">#button-9</button>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<button type="button" class="button is-warning" id="button-10">#button-10</button>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<button type="button" class="button is-primary is-light" id="button-11">#button-11</button>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<button type="button" class="button is-warning is-light" id="button-12">#button-12</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -132,4 +118,4 @@
|
|||||||
<script src="evaluation.mjs" type="module"></script>
|
<script src="evaluation.mjs" type="module"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -116,13 +116,13 @@ function findNumberOfCitiesInCountry(countryName) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exo6(){
|
function exo5(){
|
||||||
const userInput = document.getElementById("input-1").value;
|
const userInput = document.getElementById("input-4").value;
|
||||||
document.getElementById("result-box-1").innerText = findNumberOfCitiesInCountry(userInput);
|
document.getElementById("result-box-4").innerText = findNumberOfCitiesInCountry(userInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("button-5").onclick = exo6;
|
document.getElementById("button-4").onclick = exo5;
|
||||||
|
|
||||||
|
|
||||||
function findPopulationOfCitiesInCountry(countryName) {
|
function findPopulationOfCitiesInCountry(countryName) {
|
||||||
@@ -135,13 +135,13 @@ function findPopulationOfCitiesInCountry(countryName) {
|
|||||||
return population;
|
return population;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exo7(){
|
function exo6(){
|
||||||
const userInput = document.getElementById("input-2").value;
|
const userInput = document.getElementById("input-1").value;
|
||||||
document.getElementById("result-box-2").innerText = findPopulationOfCitiesInCountry(userInput);
|
document.getElementById("result-box-1").innerText = findPopulationOfCitiesInCountry(userInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("button-6").onclick = exo7;
|
document.getElementById("button-5").onclick = exo6;
|
||||||
|
|
||||||
function getCitiesInCountry(country) {
|
function getCitiesInCountry(country) {
|
||||||
const ret = [];
|
const ret = [];
|
||||||
@@ -177,13 +177,13 @@ function findLargestCitiesInCountry(country){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exo8(){
|
function exo7(){
|
||||||
const userInput = document.getElementById("input-3").value;
|
const userInput = document.getElementById("input-2").value;
|
||||||
document.getElementById("result-box-3").innerText = findLargestCitiesInCountry(userInput);
|
document.getElementById("result-box-2").innerText = findLargestCitiesInCountry(userInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById("button-7").onclick = exo8;
|
document.getElementById("button-6").onclick = exo7;
|
||||||
|
|
||||||
|
|
||||||
function getPersonByName(personName) {
|
function getPersonByName(personName) {
|
||||||
@@ -212,9 +212,39 @@ function findCountryOfOrigin(personName){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function exo8(){
|
||||||
|
const userInput = document.getElementById("input-3").value;
|
||||||
|
document.getElementById("result-box-3").innerText = findCountryOfOrigin(userInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById("button-7").onclick = exo8;
|
||||||
|
|
||||||
|
|
||||||
|
function getPersonsByCityName(cityName) {
|
||||||
|
const ret = [];
|
||||||
|
for(const person of persons){
|
||||||
|
if(person.city === cityName){
|
||||||
|
ret.push(person);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findAllPeopleInCountryByName(countryName) {
|
||||||
|
let ret = [];
|
||||||
|
for(const city of cities){
|
||||||
|
if(city.country === countryName){
|
||||||
|
ret = ret.concat(getPersonsByCityName(city.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function exo9(){
|
function exo9(){
|
||||||
const userInput = document.getElementById("input-4").value;
|
const userInput = document.getElementById("input-4").value;
|
||||||
document.getElementById("result-box-4").innerText = findCountryOfOrigin(userInput);
|
document.getElementById("result-box-4").innerText = findAllPeopleInCountryByName(userInput).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user