#ASK How solve function code. STUCK

How to solve number 20?

Welcome to the forums!
Low effort question, so I will respond accordingly.

I don’t know.

Read guidelines on asking questions. : )

1 Like

HI @doohan_as !

Welcome to the forum!

We are going to need a little bit more information from you in order to better assist you and see the problem.

If you feel more comfortable responding in your native language that is fine.

If you could provide the following information:

  • provide a link to the challenge you are working on so we can see the test cases better

  • write your code directly into the forum instead of providing screenshots. That will make it easier to assist you.

Here is how you write code into the forum.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thanks!

1 Like
function getFormData(){
   let firstName = document.getElementById("first-name").value;
   let lastName = document.getElementById("last-name").value;
   let city = document.getElementById("city").value;
   let zipCode = document.getElementById("zip-code").value;
   let check = document.getElementById("check").checked;

   return {
    firstName,
    lastName,
    city,
    zipCode,
    check
   }
}

// number18
function isNumber(x) {
  if (isNaN(x)) { return false;
} else { return true;
}
}

// number17
function isLength(string, integer) {
  return string.length === integer;
}

//number19
function checkboxIsChecked() {
  if (getFormData().check){
    return true;
  } else {
    return false;
  }
}

//number21 --what's wrong--

function validateFormData(objek) {
objek = [getFormData().firstName, getFormData().lastName, getFormData().city, getFormData().zipCode];

 if (isLength(1,9) === false && !isNumber(objek[3]) === false && checkboxIsChecked() === false) {
 return false;
 } else {
   return true;
 }
 }

//number21
function resetForm() {
document.getElementById("first-name").value = "",
document.getElementById("last-name").value = "",
document.getElementById("city").value = "",
document.getElementById("zip-code").value = "",
document.getElementById("check").checked = ""
}

//number22
function submit() {
  if (validateFormData() === false) {
    document.getElementById("warning").innerHTML = "Periksa form anda sekali lagi";
  } else {
    document.getElementById("warning").innerHTML = "";
  }
}

We will still need some more information. What is your code doing that it shouldn’t? What isn’t your code doing that it should?

Thank you for providing your code.

We are not able to read the error message from the screenshot.

Is there way you can send us a link to the challenge?
Or copy and paste that error message into your reply here so we can translate that into english?

Thanks!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.