Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Getting values from array without repetition

 
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I have been learning JavaScript for under a week so forgive me if there is an easy solution for my problem as I can't find it.
I have made this roller to print a random DNA for a creatable character and it's otherwise done and ready, except for one problem: The part where it rolls MarkRoll() it should not give multiple same values but rather every value being unique. I want to keep the outcome sorted alphabetically for logging purposes.
I have tried multiple different solutions ie. combining the repeated values into showing only one with .splice, making a new list/array of the chosen random values from the original array and few other I don't even remember out of frustration. None of them worked, it just keeps showing multiple same values.

Thank you beforehand for helping out.

(Also sorry if it looks messy, it just makes sense to me to keep that in the current order with all the comments in between, helps me find what I need)

----------------------- EDIT ---------------------

I found the issue as well as the solution for my problem and below is my finished and cleaned up code for a roller that generates random character DNA that is creatable!

    Bookmark Topic Watch Topic
  • New Topic