Created
July 13, 2019 08:16
-
-
Save rema7/4323051d079c57c45801930b9ff55cd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawRating(vote) { | |
let max = 5 | |
vote = vote > 100 ? 100 : vote <= 0 ? 1 : vote | |
const rest = Math.floor((100-vote)/20) | |
let start = [] | |
for (let i = 0; i < max - rest; i++) { | |
start.push('*') | |
} | |
for (let i = max - rest; i < 5; i++) { | |
start.push('-') | |
} | |
return start | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sequences(n) { | |
let result = []; | |
if (n < 1) { | |
return result | |
} | |
result.push('1') | |
for (let i = 1; i<n; i++) { | |
prev = result[i-1].split('-').reverse().join('-') | |
result.push(i%2 ? `${i+1}-${prev}` : `${prev}-${i+1}`) | |
} | |
result.forEach((r) => console.log(r)); | |
return result; | |
} | |
sequences(7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment