Jelajahi Sumber

Fixes to hometask 06 are added

pocu46 4 tahun lalu
induk
melakukan
5cbf035233
1 mengubah file dengan 25 tambahan dan 11 penghapusan
  1. 25 11
      06/script.js

+ 25 - 11
06/script.js

@@ -49,7 +49,7 @@
 // --------------------------------------------intRandom--------------------------------------------------------------
 
 // function intRandom(min, max) {
-//     let num = Math.round(Math.random() * 10);
+//     let num = Math.round(Math.random() * 10);            // Need to fix 
 //     if(num < min) {
 //         num = num + min;
 //     }
@@ -65,18 +65,32 @@
 
 // --------------------------------------------greetAll--------------------------------------------------------------
 
-function greetingsAll(name) {
-    alert(`Hello ${name}`);
-}
+// function greetingsAll(name) {                         // It was my very first try
+//     alert(`Hello ${name}`);
+// }
+
+// greetingsAll(prompt("Enter the name to say hi to this person"));
+
+//_____________________________________________This one is done as in requirements___________________________________________________________________
+
+// function greetingsAll() {  
+//     let names = [];
+//     for(let param of arguments) {
+//         names.push(param);
+//     }
+//     alert(`Hello ${names}`);
+// }
 
-greetingsAll(prompt("Enter the name to say hi to this person"));
+// greetingsAll("Sam", "Dean", "Jonathan");
 
 // --------------------------------------------sum--------------------------------------------------------------
 
-function sum(arg) {
-    let arguments = [];
-    arguments.push(arg);
-    return arguments;
-}
+// function sum() {
+//     let total = 0;
+//     for(let key of arguments) {
+//         total += key;
+//     }
+//     return total;
+// }
 
-console.log(sum(+prompt()));
+// console.log(sum(10, 25, 33, 46, 56));