JSFiddle - React, Tailwind, and code Playground

by Igor Cuckovic

JavaScript

var colorFunction =  function (d) {
     return d === 5 ? "red" : 
            d === 10 ? "black" : 
            d === 15 ? "green" : 
            d === 20 ? "darkred" :
     d === 25 ? "steelblue" : "sdfg";
};

var dataset = [5, 10, 15, 20, 25];

d3.select("body").selectAll("p")
    .data(dataset)
    .enter()
    .append("p")
    .text(function (d, i) {
    return "New paragraph is " + colorFunction(d) + " and order is " + (i + 1) + "!";
})
    .style("color", colorFunction);