Win a copy of Transfer Learning for Natural Language Processing (MEAP) 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
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • 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!

 
Remember to always leap before you look. But always take the time to smell the tiny ads:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic