Passer au contenu principal
e-Disciplinas
  • Disciplinas »
    2026 2025 2024 2023 2022 2021 2020 2019 2018 2017 2016 2015 2014 2013 2012 AACCs/FFLCH Pró-Reitoria de Pós-Graduação Outros
  • Suporte »
    Acesso Perfis Ouvintes Docentes Criação de Disciplinas da USP Documentação HelpDesk e Contato Guia de uso Sobre
  • Français ‎(fr)‎
    Deutsch ‎(de)‎ English ‎(en)‎ Español - Internacional ‎(es)‎ Français ‎(fr)‎ Italiano ‎(it)‎ Português - Brasil ‎(pt_br)‎
  • Fermer
    Activer/désactiver la saisie de recherche
  • Acessar

SCC0219 - Introdução ao Desenvolvimento Web (2025)

  1. Accueil
  2. Cours
  3. 2025
  4. ICMC
  5. SCC
  6. SCC0219-2025
  7. Module 4: JavaScript
  8. Exercise 7: JavaScript II

Exercise 7: JavaScript II

Conditions d’achèvement
Ouvert le : vendredi 4 avril 2025, 08:00
À rendre : vendredi 4 avril 2025, 12:00

Exercise 7: JavaScript II

Activity: Sorting and Filtering Arrays

Upload one JavaScript file named USPnumber1.USPnumber2.js.

Objective: In this activity, students will practice using JavaScript control structures and functions to manipulate arrays of objects, simulating the processing of raw data.

Instructions:

  1. Create an array of objects: Start by creating an array containing multiple objects. Each object should represent a city with the properties name, population, temperature, and weatherDescription. Here's an example of a city object:
{ name: "New York", population: 8405837, temperature: 20, weatherDescription: "Sunny" }
  1. Write a function to sort the array: Create a function called sortCities() that takes an array of city objects and a sorting criterion (e.g., by name, population, or temperature) as its arguments. The function should return a new array sorted based on the specified criterion.

  2. Write a function to filter the array: Create a function called filterCities() that takes an array of city objects and a filtering criterion (e.g., cities with a population greater than a certain value, or cities with a specific weather description) as its arguments. The function should return a new array containing only the objects that meet the filtering criterion.

  3. Test the functions: Write test cases to ensure that both the sortCities() and filterCities() functions are working correctly. Test various sorting and filtering criteria to verify that the functions produce the expected results.

  4. Combine the functions: Write a new function called processCities() that combines the functionality of the sortCities() and filterCities() functions. The processCities() function should take an array of city objects, a sorting criterion, and a filtering criterion as its arguments. The function should first filter the array using the filtering criterion, then sort the resulting array based on the sorting criterion, and finally return the processed array.

  5. Test the combined function: Write test cases for the processCities() function to ensure that it works correctly when applying both filtering and sorting criteria.

Note: Since this activity is focused on JavaScript and not HTML, you can use console.log() to display the results of your functions in the browser console or a JavaScript environment like Node.js or an online editor (e.g., JSFiddle, CodePen, or Repl.it).


◄ Exercise 6: JavaScript I
Quiz 4 ►

Blocs

Passer Navigation
  • Accueil

    • e-Disciplinas

      • Mes cours

      • Tags

      • Recherche

      • PageSobre

      • PageHelp Desk e Contato

      • PageGuia

    • Mes cours

    • Cours

      • 2025

        • CENA

        • EACH

        • ECA

        • EE

        • EEFE

        • EEFERP

        • EEL

        • EERP

        • EESC

        • EP

        • ESALQ

        • FAU

        • FCF

        • FCFRP

        • FD

        • FDRP

        • FE

        • FEA

        • FEARP

        • FFCLRP

        • FFLCH

        • FM

        • FMBRU

        • FMRP

        • FMVZ

        • FO

        • FOB

        • FORP

        • FSP

        • FZEA

        • IAG

        • IAU

        • IB

        • ICB

        • ICMC

          • SMA

          • SME

          • 550

          • SSC

          • SCC

            • TCCs do SCC

            • SCC0211-2025

            • SCC5920--2025

            • SCC0124-201-2025

            • SCC0283-201-2025

            • SCC0271-201-2025

            • SCC0230-202-2025

            • SCC5878-2025

            • SCC0233-201-2025

            • SCC0295-201-2025

            • ED - SCC0122 - 2025

            • SCC0634-201-2025

            • SCC0245-201-2025

            • SCC0607-201-2025

            • SCC0220-201-2025

            • LabBD-SCC0641-2025

            • SCC0560-201-2025

            • SCC5836--2025

            • SCC0252-201-2025

            • SCC0219-201-2025

            • SCC0202-2025

            • SCC5977--2025

            • SCC5809--2025

            • SCC5960--2025

            • SCC5959--2025

            • SCC5952--2025

            • SCC0277-201-2025

            • SCC0218-2025

            • SCC0227/SCC0229--2025

            • SCC0505--2025

            • SCC5832--2025

            • SCC0205-202-2025

            • SCC0205-201-2025

            • SCC0502-201-2025

            • SCC0223-201-2025

            • SCC0207-2025

            • SCC0580-201-2025

            • SCC0302-2025

            • SCC5949--2025

            • SCC5982--2025

            • SCC0216-2025

            • SCC0219-2025

              • Généralités

              • Group Assignment

              • Course Introduction

              • Module 1: HTTP Protocol

              • Module 2: HTML

              • Module 3: CSS

              • Module 4: JavaScript

                • DevoirExercise 7: JavaScript II

              • Module 5: DOM & Events

              • Module 6: AJAX Calls

              • Milestone 1

              • Module 7: React or Vue

              • Module 8: Node.js/ExpressJS

              • Milestone 2

              • Module 9: NoSQL Databases

              • Final Presentations

              • Final Test

          • EST

          • MAI

          • SMA

        • IEB

        • IEE

        • IF

        • IFQSC

        • IFSC

        • IGc

        • IME

        • IO

        • IP

        • IPEN

        • IQ

        • IQSC

        • IRI

        • HRAC

        • MAC

        • MAE

        • MP

        • MZ

        • RUSP

      • 2026

      • 2024

      • 2023

      • 2022

      • 2021

      • 2020

      • 2019

      • 2018

      • 2017

      • 2016

      • 2015

      • 2014

      • 2013

      • 2012

      • Grupos de Estudos, Pesquisa e Outros

      • PRPG - Pró-Reitoria de Pós-Graduação

      • STI

Blocs supplémentaires

Vous êtes connecté anonymement (Connexion)
Fourni par Moodle