Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Test</title>
- </head>
- <body>
- <script type="text/javascript">
- function zad_1() {
- Array.prototype.longest_string = function() {
- return this.sort(
- function(a, b) {
- if(a.length > b.length) return -1;
- if(a.length < b.length) return 1;
- return 0;
- }
- )[0];
- }
- let string = prompt("Enter sentence: ")
- string = string.split(" ");
- document.write("<font color=\"blue\">" + string.longest_string() + "</font>")
- }
- function zad_2() {
- let currTime = new Date(Date.now())
- if(currTime.getHours() % 2)
- document.write("<font size=\"36px\" color=\"blue\"><b>" + currTime.getHours() + "</b></font>")
- }
- function zad_3() {
- document.write("<table border=\"1\"><tr>")
- for(i = 1; i < 21; i++) {
- document.write("<td>" + Math.pow(i, 3) + "</td>")
- }
- document.write("</tr></table>")
- }
- function explode_word(element) {
- if(event.key === 'Enter') {
- document.write("<ol>")
- let string = element.value;
- string.split('').forEach( function(character) {
- document.write("<li>" + character + "</li>")
- });
- document.write("</ol>")
- }
- }
- function zad_4() {
- document.write("<input type=\"text\" onkeydown=\"explode_word(this)\"")
- }
- zad_1();
- zad_2();
- zad_3();
- zad_4();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement