Jelajahi Sumber

HW_11 (functions) done

Graf15 2 tahun lalu
induk
melakukan
dfcfe70e92
1 mengubah file dengan 8 tambahan dan 5 penghapusan
  1. 8 5
      js/js_11_function/index.js

+ 8 - 5
js/js_11_function/index.js

@@ -473,7 +473,8 @@ b.setFullName("Петрова Анна Николаевна")
                 return volume
             },
             setVolume(newVolume){
-                if (newVolume && typeof newVolume === 'number' && newVolume > 0 && newVolume < 20){
+                newVolume = +newVolume
+                if (newVolume && newVolume > 0 && newVolume < 20){
                     volume = newVolume
                 }
                 return volume
@@ -512,14 +513,16 @@ b.setFullName("Петрова Анна Николаевна")
             if (!(setKey in getSet)) {
                 inputs[fieldName].disabled = true
             }
-            const typeValue = typeof getSet[getSetName]()
+            inputs[fieldName].placeholder = fieldName
+            if (getSet[getKey]() !== undefined) {inputs[fieldName].value = getSet[getKey]()}
+            //const typeValue = typeof getSet[getSetName]()
+            const typeValue = typeof getSet[getKey]()
             let typeHtml
             if (typeValue === "number") typeHtml = "number";
             if (typeValue === "string") typeHtml = "text";
             if (typeValue === "boolean") typeHtml = "checkbox";
             inputs[fieldName].type = typeHtml
-            inputs[fieldName].placeholder = fieldName
-            inputs[fieldName].value = getSet[getKey]()
+            
             const element = inputs[fieldName] 
             element.oninput = () => {
                 
@@ -542,7 +545,7 @@ b.setFullName("Петрова Анна Николаевна")
 
     let b = createPersonClosure('Анон', "Анонов")
     getSetForm(document.body, car)
-    //getSetForm(document.body, b)
+    getSetForm(document.body, b)
     console.log(b)
     console.log(car)
 }