Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
I have a function that receive 2 parameters: a number and a string.
Because I'm dumb when I code (happens to everybody!), I sometime send the parameter inverted: the number instead of the string and the string in place of the number.
I want to make this function stupid proof by checking if the parameter received are indeed of the right type. Something like:
If type of function.param(0) == "number" --> browser.log("Incorrect parameter") If type of function.param(1) == "text" --> browser.log("incorrect parameter")[/code:3akx0gtu] How can I do that? How can I check the type of a variable?
Develop games in your browser. Powerful, performant & highly capable.
One solution could be to write a function that would check, character by character, if they are all digits or all letters. But I'm trying to know if there's already a function built it. Something like function isNumber() or isNaN(). Is there anything like that?
Oh my god! I'm so blind!!
It was right there all along! In the list of System conditions!
For the reference, here's where it is:
Add condition > System > Is value type