This is my solution to the longest palindrome
kata on Code Wars.
function reverseString(st) {
return st.split('').reverse().join('')
}
This is my solution to the longest palindrome
kata on Code Wars.
function reverseString(st) {
return st.split('').reverse().join('')
}
Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces. Rules for a smiling face:
:
or ;
-
or ~
)
or D
:)
:D
;-D
:~)
;(
:>
:}
:]
// ./src/handlers/healthcheck.js | |
'use strict' | |
function ping(_, res) { | |
res.status(200).json({ message: 'OK' }); | |
} | |
module.exports = { | |
ping, |
'use strict'; | |
const express = require('express'); | |
const cors = require('cors'); | |
const path = require('path'); | |
const { OpenApiValidator } = require('express-openapi-validator'); | |
const config = require('./config'); | |
const app = express(); | |
const apiSpec = path.join(__dirname, `../definitions/${config.name}.yml`); |
paths: | |
/healthcheck/ping: | |
get: | |
description: Returns the readiness of the service | |
operationId: ping | |
x-eov-operation-id: ping | |
x-eov-operation-handler: healthcheck | |
parameters: | |
- $ref: '#/components/parameters/x-correlation-id' | |
responses: |
{ | |
"window.zoomLevel": 0, | |
"terminal.integrated.shell.osx": "zsh", | |
"editor.fontFamily": "Fira Code", | |
"editor.fontLigatures": true, | |
"editor.minimap.enabled": false, | |
"workbench.iconTheme": "material-icon-theme", | |
"workbench.editor.enablePreview": false, | |
"editor.tabSize": 2, | |
"editor.rulers": [100], |
const property = obj[key]; | |
// obj[key] here will be '1991'. | |
acc[property] = acc[property] || []; | |
// At this point acc['1991'] doesn't yet exist, so it will be an empty array. This step is important as it checks if acc['1991'] exists, and if not, creates it and assigns a value of an empty array. | |
acc[property].push(obj); | |
// Here, all we're doing is pushing our object into the right group |
function groupBy(key) { | |
return function group(array) { | |
return array.reduce((acc, obj) => { | |
const property = obj[key]; | |
acc[property] = acc[property] || []; | |
acc[property].push(obj); | |
return acc; | |
}, {}); | |
}; | |
} |