diff --git a/core/templates/dev/head/services/IdGenerationService.js b/core/templates/dev/head/services/IdGenerationService.js index 4a7a802264fa..e6544b171906 100644 --- a/core/templates/dev/head/services/IdGenerationService.js +++ b/core/templates/dev/head/services/IdGenerationService.js @@ -21,7 +21,11 @@ oppia.factory('IdGenerationService', [function() { generateNewId: function() { // Generates random string using the last 10 digits of // the string for better entropy. - return Math.random().toString(36).slice(2).slice(-10); + var randomString = Math.random().toString(36).slice(2); + while (randomString.length < 10) { + randomString = randomString + '0'; + } + return randomString.slice(-10); } }; }]);