Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

94
Views
Cree una función que acepte un argumento del cuadro de texto de entrada y devuelva el tipo de valor en javascript

No puedo determinar el tipo exacto de valor en el cuadro de texto de entrada.

Argumento

Código JS

 function typeOfArgument() { let argument = document.getElementById("argument").value; let typeOfArgument = typeof(argument) document.getElementById("mypara").innerHTML = "type of "+argument+" is "+typeOfArgument; }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 function typeOfArgument() { let argument = document.getElementById("argument").value; let typeOfArgument = "string"; try{ if (argument === "undefined") { typeOfArgument = "undefined" } else if(argument === "null" || JSON.parse(argument).constructor === Object || JSON.parse(argument).constructor === Array) { typeOfArgument = "object"; } else if (!isNaN(parseInt(argument))) { typeOfArgument = "number"; } else if(argument === "true" || argument === "false") { typeOfArgument = "boolean" } document.getElementById("mypara").innerHTML = "type of " + argument + " is " + typeOfArgument; } catch(e) { console.log("exception") document.getElementById("mypara").innerHTML = "type of " + argument + " is " + typeOfArgument; } }
 <p>Enter argument</p> <label>Argument</label> <input type="text" id="argument"/> <br/> <button onclick="typeOfArgument();">Submit</button> <p id="mypara">The output will be displayed here</p>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!