M
M
MaxYenot2020-04-30 14:31:18
JavaScript
MaxYenot, 2020-04-30 14:31:18

How to change and add a line in js?

Hello. There is a line You need to get the following

var str = "Sorry, ///it is/// in my coat."

var str1 = "Sorry, <b><em>it is</em></b> <input type="text" id="сформированныйУникальныйID"> in my coat."

This is for an online test. The input must then be compared with the correct answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-04-30
@hzzzzl

str.replace(
  /\/\/\/(.+)\/\/\//, 
  (_, match) => `<b><em>${match}</em></b> <input type="text" id="${Math.random()}">`
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question