• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need help

Explorer ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

Hi, I'm trying to use code from @Thom Parker tutorial:

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/ 

But instead of 4 digit number I get only "d", what am I doing wrong?

Here is code I just copy/paste it, I didn't change anything:

var strDate = "3/20/2006"; // Starting Date
var strFirstPart = strDate.split("/").join("");
var nSecondPart = Math.random()*10000;
var strRegNum = util.printf("ID%s-d", strFirstPart, nSecondPart);

 

TOPICS
JavaScript

Views

382

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Mar 21, 2021 Mar 21, 2021

Try add % before d, like this:

"ID%s-%d"

Votes

Translate

Translate
Community Expert , Mar 21, 2021 Mar 21, 2021

Use this:

((Math.random()*9000)+999);

Votes

Translate

Translate
Community Expert ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

Try add % before d, like this:

"ID%s-%d"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

Thank you that fixed it.

In tutorial it says Il get 4 digit number but sometimes I get 3 digits, How to only get 4 digits every time?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

LATEST

Use this:

((Math.random()*9000)+999);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines