Filter array to specific data points

I'm having trouble filtering my data.

The array list looks like this:

{uid: 11111, 22222, 33333, 44444, 55555, 66666, 77777 }

and I want to filter it like this:

filteredData: {
                {'index':1 , 'uid':'11111' } ........

Could someone please help me with this?

I have tried...

export default {
        name: 'extuserList',
        components: {
            DatePicker
        },
        data () {
            return {
                isShowForm: false,
                oid: '',
                uidList: {
                       NO:'',
                       UID:''
                       }
                originData: ['11111',222222','333333','444444' }
            }
        },

filterdData: {
                {'index':1 , 'uid':'11111' } ........

Answer №1

Here’s a different approach to try

const numbers = [11111, 22222, 33333, 44444, 55555, 66666, 77777];
let formattedNumbers = [[Math.floor(numbers[0]/10000), numbers[0]]];
let result = [];

for(let i = 0; i < numbers.length; i++){
    formattedNumbers = [[Math.floor(numbers[i]/10000), numbers[i]]];
    result.push(...formattedNumbers);
}

console.log(result);

Answer №2

Perhaps this can provide some assistance?

let result = ['11111', '222222','333333','444444'].map((element, idx) => {
    return {
       element, idx
    };
  });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Nodejs and javascript are utilized to create dynamic SES emails

I have successfully implemented sending an email using node-ses client.sendEmail({ to: to_id, , cc: cc_id, , bcc: bcc_id, , subject: 'greetings' , message: 'your <b>message</b> goes here' , altText: 'plain text& ...

How is it possible for Vue's controlled `<input />` to accept text input even without a handler specified?

Take a look at these minimal examples showcasing React and Vue Both include an <input />, with the value of the input bound to the state. React import React from "react"; export default function App() { const [value] = React.useState(&q ...

Tips for tallying unique data points in JSON structures

json file {"people":[{"Name":"Ray Parker","Email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94f8e1f7e0e1e7baf1e0bae1f8e0e6fdf7f1e7d4faf5e0fbe5e1f1baf7f5">[email protected]</a>","State":"Wyoming","Country":" ...

When you click on one item in a jQuery selector array, the action is being applied to all elements within the array

I've been working on implementing a cheat function for a minesweeper game that reveals a random non-bomb square (line 279) and its safe neighboring squares (the 8 squares around it without bombs). However, I'm encountering an issue where using $ ...

Verify the type of email domain (personal or corporate)

Here's an example: isPersonalEmail("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0aea1ada580a7ada1a9aceea3afad">[email protected]</a>") // true isPersonalEmail("<a href="/cdn-cgi/l/email- ...

Temporarily assign a placeholder image for any broken image

Is there a way to display a default image instead of a broken image without changing the URL? I have created a template editor where users can input dynamic URLs for images. Initially, the image appears broken, but when the user sends it, the correct imag ...

When the status is set to "Playing," the Discord Audio Player remains silent

So, I'm in the process of updating my Discord audio bot after Discord made changes to their bot API. Despite my best efforts, the bot is not producing any sound. Here's a snippet of the code that is causing trouble: const client = new Discord.Cl ...

What are some tips for using copy and paste with Protractor on a Mac using Chrome?

Is there a way to utilize copy and paste functionality with Protractor on a MAC using Chrome? newInput.sendKeys(protractor.Key.chord(browser.controlKey, "a")); newInput.sendKeys(protractor.Key.chord(browser.controlKey, "c")); newInput.sendKeys(protractor. ...

How do I link data from a boostrap modal in vue.js?

To display a bootstrap modal, we can utilize the data-toggle attribute. For instance: <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#msg">Open Modal</button> I want to show the modal by using a boolean var ...

Discovering the optimal angle and ballistics formula for calculating a projectile's trajectory in Three.js

Utilizing FlyControls.js for my camera perspective I am attempting to incorporate a projectile into my object The projectile is meant to utilize the angles between the camera position and the crosshair/reticle position, moving freely through 3D space My ...

Transforming a decimal number into binary base 2 manually in Javascript without using pre-defined functions

As a newcomer to coding and Javascript, I have been given an assignment that requires me to convert base 10 numbers to binary without using specific built-in methods in Javascript (such as alert(a.toString(16))). The constraints are that I can only use loo ...

Utilizing a combination of a `for` loop and `setInterval

I've been encountering an issue for the past 3-4 hours and have sought solutions in various places like here, here, here, etc... However, I am unable to get it to work in my specific case: var timer_slideshow = {}; var that, that_boss, has_auto, el ...

Toggle the visibility of an element using the onClick() method

I have a unique way of displaying articles on my webpage. Each article is hidden and positioned at the top of the page within different divs, each with a distinct ID. My goal is to allow users to click on a list item and have the corresponding article appe ...

Load only specific columns in jqGrid to enhance performance and streamline data display

When working with jqGrid, I have implemented selectable columns to display only certain columns. Now I need to figure out how to store the selected column names in a database so that when loading the grid again, only those selected columns are displayed. ...

Tips on getting the img tag to function as a link with ajax

I am currently working with two scripts. One script successfully turns links into YouTube players using Ajax. Now, I want to achieve the same functionality with image links, by converting them into img tags. However, this particular script does not work ...

Tips for resolving issues with async-await functions when utilizing Axios

I am trying to implement axios using the async await function in my code. However, I encountered an error when attempting to use async await. useEffect(async() => { await axios .get("https://cryptic-inlet-27003.herokuapp.com/products?size=6" ...

Having trouble with the input search function displaying the wrong date on the material date picker? You may need to convert it

I have customized the MomentDateAdapter to meet my specific requirements. Interestingly, when I choose a date from the calendar, the output is accurate. However, if I enter a date manually in the input field, the output is incorrect. When dealing with the ...

Is there a way to prevent the calculation from showing decimal points?

Is there a way to show the calculated result without any decimals? The number on the slider ranges from 5000 to 100000 and is either divided or multiplied by X. The issue arises when X is something like * 0.0001097, making the resulting number excessivel ...

What are the steps to update my vue-cli global installation to the newest version available?

Vue-cli 3.5.5 is already installed on my system. Upon running vue create myapp, I receive a message stating Update available 3.6.2. Vue CLI v3.5.5 ┌───────────────────────────┐ │ Update availabl ...

What is the best way to connect to the express.js/passport.js API using an Android device as the client

Trying to access an express.js API created with node.js and passport.js. Certain methods only work when the req.user is available. Attempting to log in with Facebook and Twitter from my client app results in a plain cookie being returned. The cookie look ...