-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (17 loc) · 699 Bytes
/
script.js
File metadata and controls
22 lines (17 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function getNumberOrString(value) {
// Convert a string value to a number if possible
let number_value = Number(value);
if (Number.isNaN(number_value)) {
return value
} else {
return number_value
}
}
document.getElementById('send').addEventListener('click', (event) => {
let element_user_comment = document.getElementById('user_comment');
let new_input = document.createElement('input');
new_input.innerText = getNumberOrString(document.getElementById('name').value);
element_user_comment.appendChild(new_input);
let element_cm_area = document.getElementById('cm_area');
element_cm_area.innerText = getNumberOrString(document.getElementById('cm_area').value);
});