diff --git a/src/composables/useRandomNumber.ts b/src/composables/useRandomNumber.ts new file mode 100644 index 0000000..1149ed9 --- /dev/null +++ b/src/composables/useRandomNumber.ts @@ -0,0 +1,12 @@ +// Why not a standalone randomNumber function? +// I just couldn't be bothered creating a separate utils folder or installing a new package. + +export function useRandomNumber() { + // Shamelessly stolen from: + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#getting_a_random_integer_between_two_values_inclusive + return (min: number, max: number) => { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1) + min); + }; +} diff --git a/src/views/Vote.vue b/src/views/Vote.vue index 703ea54..3bb5d82 100644 --- a/src/views/Vote.vue +++ b/src/views/Vote.vue @@ -1,32 +1,129 @@