Answer the question
In order to leave comments, you need to log in
How to generate an object from an array?
There is the following object:
{
one_time: false,
buttons: [
[
{action: {type: 'text',label: 'Профиль1',payload: '{"command": "profile1"}' }, color: 'default'}
],
[
{action: {type: 'text',label: 'Профиль2',payload: '{"command": "profile2"}' }, color: 'default'},
{action: {type: 'text',label: 'Профиль3',payload: '{"command": "profile3"}' }, color: 'default'},
{action: {type: 'text',label: 'Профиль4',payload: '{"command": "profile4"}' }, color: 'default'}
]
]
};
var button1=["Профиль1",'default','{"command": "profile1"}']
//{action: {type: 'text',label: 'Профиль1',payload: '{"command": "profile1"}' }, color: 'default'}
var button2=["Профиль2",'default','{"command": "profile2"}']
var button3=["Профиль3",'default','{"command": "profile3"}']
var button4=["Профиль4",'default','{"command": "profile4"}']
keboard_maker()
Answer the question
In order to leave comments, you need to log in
var button1=["Профиль1",'default','{"command": "profile1"}']
var button2=["Профиль2",'default','{"command": "profile2"}']
var button3=["Профиль3",'default','{"command": "profile3"}']
var button4=["Профиль4",'default','{"command": "profile4"}']
btns = [button1,button2,button3,button4]
obj = {
one_time: false,
buttons: btns.map(btn => ({
action: {
type: 'text',
label: btn[0],
payload: btn[2]
},
color: btn[1]
}))
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question