Skip to content

Periklis Kafchitsas#207

Open
PerikK wants to merge 4 commits intoboolean-uk:mainfrom
PerikK:main
Open

Periklis Kafchitsas#207
PerikK wants to merge 4 commits intoboolean-uk:mainfrom
PerikK:main

Conversation

@PerikK
Copy link

@PerikK PerikK commented Feb 29, 2024

No description provided.

Comment on lines +1 to +5
const onePoint = [
'A',
'a',
'E',
'e',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the upper or lower case characters and just one case, then run .toUpperCase or .toLowerCase on the input

const scrabble = (str) => {
if (str === null) {
return 0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const ucStr = str.toUpperCase()

let tmpStr = ''

for (let i = 0; i <= str.length - 1; i++) {
if (!['[', ']'].includes(str[i])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const doubleLetters = ['[', ']']

if (!doubleLetters.includes(str[i])) {

Comment on lines +80 to +83
tmpStr[0] === '{' &&
tmpStr[2] !== '}' &&
lastChar === '}' &&
charBeforeLast !== '{'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create one or more variables

let strToCheck = str
let newStr = ''

if (doubleWord.valid === true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (doubleWord.valid) {


for (let i = 0; i < strToCheck.length; i++) {
if (strToCheck[i] === '{') {
count1 += 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better name for count1 would be useful

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numOfBrackets

return doubleLettersObj
}

const tripleLettersChk = (str) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validateTripleLetters or checkTripleLetters

Comment on lines +201 to +210
if (
str === '' ||
str === null ||
str === ' \t\n' ||
typeof str !== 'string' ||
str === undefined ||
invalidChars ||
!doubleLetters.valid ||
!tripleLetters.valid
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const isEmpty = str === '' || str === null || str === ' \t\n' || str === undefined
const isValid = ...

if (isEmpty || !isValid)

} else if (tenPoints.includes(i)) {
points += 10
}
calcDoubledLetters.doubleLettersPoints = points * 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 is a magic number. Move to a variable that describes it, e.g. doubleMultiplier, tripleMultiplier

const fourPoints = ['F', 'H', 'V', 'W', 'Y', 'f', 'h', 'v', 'w', 'y']
const fivePoints = ['K', 'k']
const eightPoints = ['J', 'X', 'j', 'x']
const tenPoints = ['Q', 'Z', 'q', 'z']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const points = {
  'a': 1,
  'b': 3,
  ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments