Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Fix for #100 - calculate random index for array #101

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/api/retweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ const retweet = () => {
if (err) {
console.log('ERRORDERP: Cannot Search Tweet!, Description here: ', err)
} else {
// grab tweet ID to retweet
const rando = Math.floor(Math.random() * param.searchCount) + 1
// grab random tweet ID to retweet - desired range for random number is [0..data.statuses.length-1]
const rando = Math.floor(Math.random() * data.statuses.length);
let retweetId

try {
retweetId = data.statuses[rando].id_str
} catch (e) {
console.log('ERRORDERP: Cannot assign retweeID')
console.log('ERRORDERP: Cannot assign retweeID; exception message: ' + e.message);
return
}

Expand Down