-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanakirja_swe.js
54 lines (46 loc) · 1.8 KB
/
sanakirja_swe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Function that retrieves all the words in the dictionary.
function getAll() {
let text = "<table><tr><th>🇸🇪 svenska</th><th>🇫🇮 finska</th><th>🇬🇧 engelska</th></tr>"; // creates a table.
for (var i = 0; i < words.length; i++) {
text += "<tr><td>" + words[i].svenska + "</td><td> " + words[i].suomi + "</td><td> " + words[i].english + "</td></tr>";
}
text += "</table>"
document.getElementById("outputAreaGetAll").innerHTML = text;
}
/*
// Find a specific word (here: Finnish-English)
function search2() {
let keyWord = document.getElementById("searchInput").value;
let foundObject = words.find(o => o.suomi === keyWord);
//testitulostus
document.getElementById("outputArea").innerHTML = "Suomi: " + foundObject.suomi + " Englanti: " + foundObject.english;
console.log(foundObject);
}
*/
let lang1 = [];
let lang2 = [];
let header1 = "";
let header2 = "";
let suomi = [];
let english = [];
let svenska = [];
let suomiheader = "🇫🇮 finska";
let englishheader = "🇬🇧 engelska";
let svenskaheader = "🇸🇪 svenska";
for (var i = 0; i < words.length; i++) {
suomi += words[i].suomi + "<br>";
english += words[i].english + "<br>";
svenska += words[i].svenska + "<br>";
}
suomi = suomi.split("<br>");
english = english.split("<br>");
svenska = svenska.split("<br>");
// Final language selection function.
function selectLanguages(lang1, lang2, header1, header2) {
let text = "<table><tr><th>" + header1 + "</th><th>" + header2 + "</th></tr>";
for (var i = 0; i < words.length; i++) {
text += "<tr><td>" + lang1[i] + "</td><td> " + lang2[i] + "</td></tr>";
}
text += "</table>"
document.getElementById("outputAreaGetAll").innerHTML = text;
}