Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Variable text in sketchpad with numbers - issue with 0

Hi,


I am designing an experiment that people can participate in with their phones. For compensation, I would like to offer participants to join a raffle with their phone number for a certain prize (like an amazon voucher). However, with the sketchpad I am using right now, I run into the issue that Dutch phone numbers start with '06', and with my current code, once I put in the 6, the 0 gets deleted. I'm not sure where the error stems from, i.e. whether I did something wrong when declaring the variables, whether I'm using the wrong type of variable (I'm not sure if it automatically assigns it a string variable when you use the apostrophes), or whether there is another issue at hand.

I tried to fix this myself by making sure the '06' part is fixed, but now phone numbers that have '060...' run into the issue again. Does anyone know how I can fix this?

I have attached the relevant experiment to the post.

Thanks!

Jelle


Comments

  • Hi @JelleStudentRug ,


    I think the following should work. Give the variable phone a starting value that is clearly a string, for example:

    vars.phone = " 06-" // Note the space before the zero
    


    (Make sure to do the same in the "phone_c" item, for the if-block that is executed if participants clicked reset.)


    Does that solve the issue?

    Did you like my answer? Feel free to Buy Me A Coffee :)

  • I just tested it, and it works. Thanks a lot!

  • Great to hear @JelleStudentRug

    Did you like my answer? Feel free to Buy Me A Coffee :)

Sign In or Register to comment.