How do you sort a list of words on the 4th character of the word? What"s the shortest solution?
[ "strawberry", "helicopter", "wales", "acorn" ]
should be:
<?php | |
function convertfilename($filename) { | |
$filename = str_replace([ "?", "[", "]", "/", "\\", "=", "<", ">", | |
":", ";", ",", "'", '"', "&", "$", "#", | |
"*", "(", ")", "|", "~" ], "", $filename); | |
$filename = preg_replace("/[\s-]+/", "-", $filename); | |
$filename = trim($filename, ".-_"); | |
return ucwords($filename); | |
} |
How do you sort a list of words on the 4th character of the word? What"s the shortest solution?
[ "strawberry", "helicopter", "wales", "acorn" ]
should be:
In this challenge you get an HTML document that renders a lot of colourful hearts.
And you get a JSON object with the information about all the brown colours that were used:
[
{ | |
"Gore": [ | |
"Blood", "Bloodbath", "Crucifixion", "Bloody", "Flesh", "Bruises", "Car crash", "Corpse", "Crucified", "Cutting", "Decapitate", "Infested", "Gruesome", "Kill (as in Kill la Kill)", "Infected", "Sadist", "Slaughter", "Teratoma", "Tryphophobia", "Wound", "Cronenberg", "Khorne", "Cannibal", "Cannibalism", "Visceral", "Guts", "Bloodshot", "Gory", "Killing", "Surgery", "Vivisection", "Massacre", "Hemoglobin", "Suicide", "Female Body Parts" | |
], | |
"Drugs": [ | |
"Drugs", "Cocaine", "Heroin", "Meth", "Crack" | |
], | |
"Clothing": [ | |
"no clothes", "Speedo", "au naturale", "no shirt", "bare chest", "nude", "barely dressed", "bra", "risqué", "clear", "scantily", "clad", "cleavage", "stripped", "full frontal unclothed", "invisible clothes", "wearing nothing", "lingerie with no shirt", "naked", "without clothes on", "negligee", "zero clothes" | |
], |
/* | |
<section> | |
<ul> | |
<li>HTML</li> | |
<li>CSS</li> | |
<li>JavaScript</li> | |
</ul> | |
<form> | |
<label for="tech">Add a technology</label> | |
<input type="text" name="tech" id="tech"> |
const csvToJSON = (csv) => { | |
const getcsvdata = (csv) => { | |
const csvRegex = /,(?=(?:(?:[^"]*"){2})*[^"]*$)/; | |
const trimQuotes = /^"|"$/g; | |
csv = csv.split(csvRegex).map( | |
h => h.trim().replace(trimQuotes, '') | |
); | |
return csv; | |
} | |
let lines = csv.split('\n'); |