G
G
Genri_Rus2020-02-18 22:14:32
JavaScript
Genri_Rus, 2020-02-18 22:14:32

How to add points to classes?

There is a line: I tried it like this: You need it like this:const str = 'class1 class2';
const newstr = str.replace(/^[^\d]/g, .$1);

'.class1 .class2'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MikMik, 2019-06-19
@MikMik

Does anyone know or is the question too stupid and poorly formulated?

A
Andrey Suha, 2020-02-18
@Genri_Rus

const newstr = str.split(" ").map(cls => '.${cls}').join(" ");

'.${cls}' here, replace with brackets for string interpolation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question