Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Programming Fundamentals Final Exam - 04 April 2020 Group 1/02. Emoji Detector.js
- emojiDetector = inputArray => {
- 'use strict'
- const isColl = emojiStr => {
- let sumAscii = 0
- for (let i = 2; i < emojiStr.length - 2; i++) {
- sumAscii += emojiStr[i].charCodeAt(0)
- }
- if (sumAscii > coolThresholdProduct)
- return true
- }
- let coolThresholdProduct = 1
- let digitPattern = /\d/g
- let digit = inputArray[0].match(digitPattern)
- for (const i of digit)
- coolThresholdProduct *= i
- console.log(`Cool threshold: ${coolThresholdProduct}`)
- let emojiPattern = /(::|\*\*)[A-Z][a-z]{2,}\1/g
- let emojis = inputArray[0].match(emojiPattern)
- console.log(`${emojis.length} emojis found in the text. The cool ones are:`)
- for (const i of emojis) {
- if (isColl(i))
- console.log(i)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement