Find all combinations of 5 number of list

I have a list of 5 numbers and I need to find combinations that equals to a target number. My resulting coombination looks like this ((x * x) + x) * (x + x). I am trying to think of the most holistic solution that may just return other target number provided that I can use other arithmetic operations like +, -, *, /. This is like Knapsack problem and I know my solution would be much expensive but I just need some guidance or pointing in the right direction.

How to display extJS grid columns after each record, not only on the top

How to display extJS columns after each record not on the top.
I am grouping extJS grid with three columns and grouping is working fine.

Here is the code and we can test in fiddler as well.

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var store = Ext.create('Ext.data.Store', {
            storeId:'employeeStore',
            fields:['name', 'seniority', 'department', 'sort', 'groupsort'],
            grouper: {
               
                 groupFn: function(item) {
                    
                    return 'department: ' + item.get('department');
                }
            },

            // Have members of each group sorted on this field
            sorters: [{
                property: 'name'
            }],

            data: {'employees':[
                { "name": "Michael Scotts",  "seniority": 7, "department": "Management", "groupsort" : "2" },
                { "name": "Dwight Schrute", "seniority": 2, "department": "Sales", "groupsort" : "1" },
                { "name": "Jim Halpert",    "seniority": 3, "department": "Sales", "groupsort" : "1" },
                { "name": "Kevin Malone",   "seniority": 4, "department": "Accounting", "groupsort" : "3" },
                { "name": "Angela Martin",  "seniority": 5, "department": "Accounting", "groupsort" : "3" }
            ]},
            proxy: {
                type: 'memory',
                reader: {
                    type: 'json',
                    rootProperty: 'employees'
                }
            }
        });

        Ext.create('Ext.grid.Panel', {
            title: 'Employees',
            store: Ext.data.StoreManager.lookup('employeeStore'),
            columns: [
                { text: 'Name',     dataIndex: 'name' },
                { text: 'Seniority', dataIndex: 'seniority' },
                { text: 'Department', dataIndex: 'department', sortable: true }
            ],
            features: [{
                ftype: 'grouping'
            }],
            renderTo: Ext.getBody()
        });
    }
});

My requierment is I want show columns not on the top but after the grouping for each record. Is there any workaround for that.

Can i command to server Minecraft with python?

I’ve searched such as this question a lot
but I didn’t get a satisfactory answer

I want to change weather in own server according to temperature sensor value.
But I couldn’t control a command with Python in Minecraft (for example, /weather, /kill)
So, How can i control that? or Can’t?

If there is a way, is there a link related to it?

Thanks

React toDoApp removing a task functionality not working

I am a new to React and trying to make a toDoApp. I’m trying to create an onClick event to remove an element from the tasks state. But it does not seem to work. And can I also ask how to implement id keys so that I can remove the desired task that I want?

import React from 'react';
import './App.css';

class App extends React.Component {
  constructor(){
    super();
    this.state = {
      value: '',
      tasks: []
    };

    this.handleChange = this.handleChange.bind(this)
    this.addItem = this.addItem.bind(this)
    this.removeItem = this.removeItem(this)
  }

  handleChange(event) {
      this.setState({  
        value: event.target.value
      })
  }

  addItem(){
    if(this.state.value === ''){
      alert('Enter a task!')
    } else {
      const newTask = [...this.state.tasks, this.state.value]
      this.setState({
      tasks: newTask,
      value: ''
      })
    }
    }

  removeItem(){
    this.state.tasks.pop()
    this.setState({
      tasks: this.state.tasks,
    })

  }

  render(){

    const itemList = this.state.tasks.map((num) => 
              <li>{num}</li>
            );

    return(
      <div>
              <input type="text" value={this.state.value} onChange={this.handleChange}></input>
              <button onClick={this.addItem}>+</button>
              <button onClick={this.removeItem}>-</button>
              <ul>{itemList}</ul>  
              {this.state.tasks}


      </div>
    )
  }
}


export default App;

strong text

Should the jsconfig.json file be used in every JavaScript project?

I am working with a JavaScript project, and I just wanted to know if it is necessary (or recommended) to use the jsconfig.json file in every JavaScript project.

Will adding the jsconfig.json file make the development process easier, or is it only used for larger JavaScript projects?


Edit: I just noticed that the jsconfig.json file has something to do with Visual Studio Code. How does it improve the developer experience with Visual Studio Code?

what is this javascript error? “Uncaught DOMException: CanvasRenderingContext2D.drawImage: Passed-in image is “broken”

I am making a space shooter style game, and the code I have made so far was working 2 days ago but now I am getting this error: Uncaught DOMException: CanvasRenderingContext2D.drawImage: Passed-in image is “broken”

here is some of the code.
I define the image here:

const baddie = new Image();        
baddie.src = './space_shooter_baddie.jpg'; 

and i am getting the error on this line:

ctx.drawImage(baddie, 0, 0, 28, 28, badx[i],  bady[i], 28, 28);

could someone please tell me what this means? thank you.

How to swap first and last digits of a number using for loop in Javascript

I need to ask user to input a 3 digit number and then swap the first and last numbers using a for loop. This is what I have so far, but I’m stuck. Using a for loop seems illogical, but that is what I have to do:

num = prompt("Please input a number with 3 digits.");
let firstDigit = num[0];
let secondDigit = num[1];
let lastDigit = num[2];

for (firstDigit < 10; secondDigit < 10; lastDigit < 10); {
    console.log(lastDigit + secondDigit + firstDigit);
}

Please help!

Thanks

react – not able to update state in input value

I am learning react and I want to create a simple form where the input value changes and updates once the user types it in. I have this code where the input value updates the state when it is being typed, but when I press enter, the old state returns. I did lots of googling but can’t seem to make it work. I have tried it with a submit button in the form, but that doesn’t make a difference. I would like to make it work without a submit button as in the value changes and updates onChange only. What am I not seeing?

import React, { useState } from 'react';

function App() {
 
  const [value, setValue] = useState('John');
  
  const handleInputOnChange =(e)=> {
    setValue(e.target.value)
  };

  return (
    <div className="App">
      <form>
           <label>
               Name:
               <input value={value} onChange={handleInputOnChange}/>
           </label>
       </form>
      </div>
  );
}

export default App;

Active class for section in view port [closed]

I am building a code to highlight the active section in the viewport along with highlighting the nav element in view using Javascript. I did that by getting dimensions via getBoundingClientRect() and then add “active-class” using classlist. However, the active section is not working on my project.

Can someone review my repository here: https://github.com/Himanshukumar30/Landing-Page
and help me with this. TIA!

Variable isnt displaying in console log outside of function in angular

I am trying to use a variable in another function to create a map marker using angular.
i got the data to be stored in the function and display on the console within one function however when using the data in another function it does not work:

this.getparamformid = this.route.snapshot.paramMap.get('facviewid');
    this.daformfacservice
      .getOneDAFacForm(this.getparamformid)
      .subscribe((daFormFac: DAFormFac) => {
        this.daformfacs = daFormFac;
        console.log(daFormFac, 'response of form');
        this.latitude =  daFormFac['latitude'];
        this.longitude = daFormFac['longitude'];

        console.log(this.latitude, this.longitude, "cords")
      });
    let map = L.map('map').setView([10.536421, -61.311951], 8);
    L.tileLayer(
      'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}',
      {
        attribution:
          'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
        maxZoom: 18,
        id: 'mapbox/streets-v11',
        tileSize: 512,
        zoomOffset: -1,
        accessToken:
          'accesstoken',
      }
    ).addTo(map);
    var marker = L.marker([this.latitude, this.longitude]).addTo(map);
    console.log(this.latitude, this.longitude, "in marker")
  }

This function gets the data entry and stored 2 variables latitude and longitude:

this.daformfacservice
          .getOneDAFacForm(this.getparamformid)
          .subscribe((daFormFac: DAFormFac) => {
            this.daformfacs = daFormFac;
            console.log(daFormFac, 'response of form');
            this.latitude =  daFormFac['latitude'];
            this.longitude = daFormFac['longitude'];
    
            console.log(this.latitude, this.longitude, "cords")
          });

and it results in

data

however when trying to access the data outside the function the console is blank.

var marker = L.marker([this.latitude, this.longitude]).addTo(map);
console.log(this.latitude, this.longitude, "in marker")

It does not display and is not accessible. what should i do?

React creating timetable

I am trying to create a time table for a project and i have 20 hour left can you please help me

app is like this

each empty box needs to store data and while onclick the data must shown in description tab (on the right) and has to changeable how can i do that

i tries to usestate like this

const [data, setData] = useState([
    {
        hour: "08:00 - 09:00",
        id: 1,
        box: [
            {
                id: 1,
                title: "",
                description: ""
            },
            {
                id: 2,
                title: "",
                description: ""
            }, ...other boxes 
        ]    
    }, ...others hours

and my table jxs is

<table> 
                <tbody>               
                    <tr>
                        <th></th>
                        <th>Monday</th>
                        <th>Tuesday</th>
                        <th>Wednesday</th>
                        <th>Thursday</th>
                        <th>Friday</th>
                        <th>Saturday</th>
                        <th>Sunday</th>
                    </tr> 
                </tbody>                   
                {data.map((data, i) => {
                    return (
                        <tbody key={i}>
                            <tr key={i}>                                
                                <th key={i}>{data.hour}  {i}</th>
                                {data.box.map((box, idx) => {
                                    return <td key={idx}>{idx}</td>
                                })}                        
                            </tr>
                        </tbody>    
                    )
                })}                    
            </table>

and sql and some crud operations with django :((

I had to use a for loop to to go through each character in a string but the code is not working properly

These are the instruction for the exercise I am supposed to do:
Start with a prompt that asks the user to enter any string.

Using a for loop, go through each character in the string.

If the string contains the letter A (capital or lowercase), break out of the loop and print the message below to the screen.

If the string does not contain the letter A, print the message below to the screen.

Here is my code

var text= prompt("Enter any string.")
for (var i = 0; i < text.length; i++) {
    if (text[i] === "A")
    {alert("The string contains the letter A.");
}
     if (text[i] === "a")
    {alert("The string contains the letter A.");
}
 else
      {alert("The string does not contain the letter A.");
}
}

How can I edit file in JavaScript?

I want to be able to:

-edit the data of a .dat file on my computer for a website.

-pull data from the file to use it later on.

I know a tiny bit about javascript and heard javascript cannot directly edit databases.

Is a .dat file in my computer a database?

I have done a few things in Javascript for websites but I haven’t done anything complicated completely myself. I created some websites before and I have a basic understanding of HTML and CSS.

Please phrase your response as simply as possible. Explain the meaning of any complicated but necessary terms.