В массиве для калькулятора у меня есть: x^y (в html это будет x y ), а также x^-1 или x -1 . I can't figure out how to add it to the array for only those two buttons in the array so it displays xy and x-1 respectively instead of x < sup>y< /sup> (without the spaces, obviously) x < sup>-1< /sup>
js (missing the Слушатели и т. Д., Но дает вам представление о том, к чему я стремлюсь): < /p>
const display = document.getElementById("display");
const buttonValues = [
"Rad", "º", "x!", "(", ")", "%", "AC",
"Inv", "sin", "log", "7", "8", "9", "÷",
"π", "cos", "ln", "4", "5", "6", "x",
"e", "tan", "√", "1", "2", "3", "+",
"Ans", "EXP", "^", "0", ".", "=", "-", "+/-", "x^-1",
]
const rightSymbols = [ "÷", "x", "-", "+", "="]
const topSymbols = ["(", ")", "%", "AC"]
const leftSymbols = ["Rad", "º", "x!", "Inv", "sin", "log", "π", "cos", "ln", "e", "tan", "√", "Ans", "EXP", "^", "+/-", "x^-1",]
//A+B, A×B, A-B, A÷B
let A = 0;
let operator = null;
let B = null;
function clearAll() {
A = null;
operator = null;
B = null;
}
for (let i = 0; i < buttonValues.length; i++) {
let value = buttonValues;
let button = document.createElement("button");
button.innerText = value;
//styling button colors
if (value == "=") {
button.style.backgroundColor = "brown";
}
else if (rightSymbols.includes(value)) {
button.style.backgroundColor = "orange";
}
else if (leftSymbols.includes(value)) {
button.style.backgroundColor = "darkorange";
button.style.color = "white";
}
else if (topSymbols.includes(value)) {
button.style.backgroundColor = "orange";
button.style.color = "white";
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... javascript
Как добавить суперпресс в массив в JavaScript ⇐ Javascript
Форум по Javascript
-
Anonymous
1748307158
Anonymous
В массиве для калькулятора у меня есть: x^y (в html это будет x y ), а также x^-1 или x -1 . I can't figure out how to add it to the array for only those two buttons in the array so it displays xy and x-1 respectively instead of x < sup>y< /sup> (without the spaces, obviously) x < sup>-1< /sup>
js (missing the Слушатели и т. Д., Но дает вам представление о том, к чему я стремлюсь): < /p>
const display = document.getElementById("display");
const buttonValues = [
"Rad", "º", "x!", "(", ")", "%", "AC",
"Inv", "sin", "log", "7", "8", "9", "÷",
"π", "cos", "ln", "4", "5", "6", "x",
"e", "tan", "√", "1", "2", "3", "+",
"Ans", "EXP", "^", "0", ".", "=", "-", "+/-", "x^-1",
]
const rightSymbols = [ "÷", "x", "-", "+", "="]
const topSymbols = ["(", ")", "%", "AC"]
const leftSymbols = ["Rad", "º", "x!", "Inv", "sin", "log", "π", "cos", "ln", "e", "tan", "√", "Ans", "EXP", "^", "+/-", "x^-1",]
//A+B, A×B, A-B, A÷B
let A = 0;
let operator = null;
let B = null;
function clearAll() {
A = null;
operator = null;
B = null;
}
for (let i = 0; i < buttonValues.length; i++) {
let value = buttonValues[i];
let button = document.createElement("button");
button.innerText = value;
//styling button colors
if (value == "=") {
button.style.backgroundColor = "brown";
}
else if (rightSymbols.includes(value)) {
button.style.backgroundColor = "orange";
}
else if (leftSymbols.includes(value)) {
button.style.backgroundColor = "darkorange";
button.style.color = "white";
}
else if (topSymbols.includes(value)) {
button.style.backgroundColor = "orange";
button.style.color = "white";
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79639250/how-to-add-a-superscript-to-an-array-in-javascript[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия